diff options
author | Jason Wessel <jason.wessel@windriver.com> | 2010-05-20 22:04:28 -0400 |
---|---|---|
committer | Jason Wessel <jason.wessel@windriver.com> | 2010-05-20 22:04:28 -0400 |
commit | 4402c153cb9c549cd21d6007ef0dfac50c8d148d (patch) | |
tree | 2a2589958e3d5243b265ba2a9fb6f5f2ecb33b57 /kernel/debug | |
parent | 5b778dadcde0d93eb20a67bad8105b6ed8d7810f (diff) |
kdb,debug_core: Allow the debug core to receive a panic notification
It is highly desirable to trap into kdb on panic. The debug core will
attempt to register as the first in line for the panic notifier.
CC: Ingo Molnar <mingo@elte.hu>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Diffstat (limited to 'kernel/debug')
-rw-r--r-- | kernel/debug/debug_core.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index b38bb25dbbb3..64b5588c9638 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c | |||
@@ -762,11 +762,28 @@ static struct sysrq_key_op sysrq_dbg_op = { | |||
762 | }; | 762 | }; |
763 | #endif | 763 | #endif |
764 | 764 | ||
765 | static int kgdb_panic_event(struct notifier_block *self, | ||
766 | unsigned long val, | ||
767 | void *data) | ||
768 | { | ||
769 | if (dbg_kdb_mode) | ||
770 | kdb_printf("PANIC: %s\n", (char *)data); | ||
771 | kgdb_breakpoint(); | ||
772 | return NOTIFY_DONE; | ||
773 | } | ||
774 | |||
775 | static struct notifier_block kgdb_panic_event_nb = { | ||
776 | .notifier_call = kgdb_panic_event, | ||
777 | .priority = INT_MAX, | ||
778 | }; | ||
779 | |||
765 | static void kgdb_register_callbacks(void) | 780 | static void kgdb_register_callbacks(void) |
766 | { | 781 | { |
767 | if (!kgdb_io_module_registered) { | 782 | if (!kgdb_io_module_registered) { |
768 | kgdb_io_module_registered = 1; | 783 | kgdb_io_module_registered = 1; |
769 | kgdb_arch_init(); | 784 | kgdb_arch_init(); |
785 | atomic_notifier_chain_register(&panic_notifier_list, | ||
786 | &kgdb_panic_event_nb); | ||
770 | #ifdef CONFIG_MAGIC_SYSRQ | 787 | #ifdef CONFIG_MAGIC_SYSRQ |
771 | register_sysrq_key('g', &sysrq_dbg_op); | 788 | register_sysrq_key('g', &sysrq_dbg_op); |
772 | #endif | 789 | #endif |
@@ -786,6 +803,8 @@ static void kgdb_unregister_callbacks(void) | |||
786 | */ | 803 | */ |
787 | if (kgdb_io_module_registered) { | 804 | if (kgdb_io_module_registered) { |
788 | kgdb_io_module_registered = 0; | 805 | kgdb_io_module_registered = 0; |
806 | atomic_notifier_chain_unregister(&panic_notifier_list, | ||
807 | &kgdb_panic_event_nb); | ||
789 | kgdb_arch_exit(); | 808 | kgdb_arch_exit(); |
790 | #ifdef CONFIG_MAGIC_SYSRQ | 809 | #ifdef CONFIG_MAGIC_SYSRQ |
791 | unregister_sysrq_key('g', &sysrq_dbg_op); | 810 | unregister_sysrq_key('g', &sysrq_dbg_op); |