aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/debug
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2012-10-12 07:37:33 -0400
committerJason Wessel <jason.wessel@windriver.com>2012-10-12 07:37:33 -0400
commitf30fed10c440a25937e509860fa207399b26efe5 (patch)
tree7697f5e044f1a870d0ddd1e5953d494cb3d9643e /kernel/debug
parenta0d271cbfed1dd50278c6b06bead3d00ba0a88f9 (diff)
kgdb: Add module event hooks
Allow gdb to auto load kernel modules when it is attached, which makes it trivially easy to debug module init functions or pre-set breakpoints in a kernel module that has not loaded yet. Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Diffstat (limited to 'kernel/debug')
-rw-r--r--kernel/debug/debug_core.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
index 0557f24c6bca..8bfa373cd5fd 100644
--- a/kernel/debug/debug_core.c
+++ b/kernel/debug/debug_core.c
@@ -688,6 +688,22 @@ kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs)
688 return kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER); 688 return kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER);
689} 689}
690 690
691/*
692 * GDB places a breakpoint at this function to know dynamically
693 * loaded objects. It's not defined static so that only one instance with this
694 * name exists in the kernel.
695 */
696
697static int module_event(struct notifier_block *self, unsigned long val,
698 void *data)
699{
700 return 0;
701}
702
703static struct notifier_block dbg_module_load_nb = {
704 .notifier_call = module_event,
705};
706
691int kgdb_nmicallback(int cpu, void *regs) 707int kgdb_nmicallback(int cpu, void *regs)
692{ 708{
693#ifdef CONFIG_SMP 709#ifdef CONFIG_SMP
@@ -816,6 +832,7 @@ static void kgdb_register_callbacks(void)
816 kgdb_arch_init(); 832 kgdb_arch_init();
817 if (!dbg_is_early) 833 if (!dbg_is_early)
818 kgdb_arch_late(); 834 kgdb_arch_late();
835 register_module_notifier(&dbg_module_load_nb);
819 register_reboot_notifier(&dbg_reboot_notifier); 836 register_reboot_notifier(&dbg_reboot_notifier);
820 atomic_notifier_chain_register(&panic_notifier_list, 837 atomic_notifier_chain_register(&panic_notifier_list,
821 &kgdb_panic_event_nb); 838 &kgdb_panic_event_nb);
@@ -839,6 +856,7 @@ static void kgdb_unregister_callbacks(void)
839 if (kgdb_io_module_registered) { 856 if (kgdb_io_module_registered) {
840 kgdb_io_module_registered = 0; 857 kgdb_io_module_registered = 0;
841 unregister_reboot_notifier(&dbg_reboot_notifier); 858 unregister_reboot_notifier(&dbg_reboot_notifier);
859 unregister_module_notifier(&dbg_module_load_nb);
842 atomic_notifier_chain_unregister(&panic_notifier_list, 860 atomic_notifier_chain_unregister(&panic_notifier_list,
843 &kgdb_panic_event_nb); 861 &kgdb_panic_event_nb);
844 kgdb_arch_exit(); 862 kgdb_arch_exit();