diff options
Diffstat (limited to 'kernel/debug/debug_core.c')
| -rw-r--r-- | kernel/debug/debug_core.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 0d7c08784ef..3c1ad4e0354 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c | |||
| @@ -41,6 +41,7 @@ | |||
| 41 | #include <linux/delay.h> | 41 | #include <linux/delay.h> |
| 42 | #include <linux/sched.h> | 42 | #include <linux/sched.h> |
| 43 | #include <linux/sysrq.h> | 43 | #include <linux/sysrq.h> |
| 44 | #include <linux/reboot.h> | ||
| 44 | #include <linux/init.h> | 45 | #include <linux/init.h> |
| 45 | #include <linux/kgdb.h> | 46 | #include <linux/kgdb.h> |
| 46 | #include <linux/kdb.h> | 47 | #include <linux/kdb.h> |
| @@ -784,6 +785,20 @@ void __init dbg_late_init(void) | |||
| 784 | kdb_init(KDB_INIT_FULL); | 785 | kdb_init(KDB_INIT_FULL); |
| 785 | } | 786 | } |
| 786 | 787 | ||
| 788 | static int | ||
| 789 | dbg_notify_reboot(struct notifier_block *this, unsigned long code, void *x) | ||
| 790 | { | ||
| 791 | if (!dbg_kdb_mode) | ||
| 792 | gdbstub_exit(code); | ||
| 793 | return NOTIFY_DONE; | ||
| 794 | } | ||
| 795 | |||
| 796 | static struct notifier_block dbg_reboot_notifier = { | ||
| 797 | .notifier_call = dbg_notify_reboot, | ||
| 798 | .next = NULL, | ||
| 799 | .priority = INT_MAX, | ||
| 800 | }; | ||
| 801 | |||
| 787 | static void kgdb_register_callbacks(void) | 802 | static void kgdb_register_callbacks(void) |
| 788 | { | 803 | { |
| 789 | if (!kgdb_io_module_registered) { | 804 | if (!kgdb_io_module_registered) { |
| @@ -791,6 +806,7 @@ static void kgdb_register_callbacks(void) | |||
| 791 | kgdb_arch_init(); | 806 | kgdb_arch_init(); |
| 792 | if (!dbg_is_early) | 807 | if (!dbg_is_early) |
| 793 | kgdb_arch_late(); | 808 | kgdb_arch_late(); |
| 809 | register_reboot_notifier(&dbg_reboot_notifier); | ||
| 794 | atomic_notifier_chain_register(&panic_notifier_list, | 810 | atomic_notifier_chain_register(&panic_notifier_list, |
| 795 | &kgdb_panic_event_nb); | 811 | &kgdb_panic_event_nb); |
| 796 | #ifdef CONFIG_MAGIC_SYSRQ | 812 | #ifdef CONFIG_MAGIC_SYSRQ |
| @@ -812,6 +828,7 @@ static void kgdb_unregister_callbacks(void) | |||
| 812 | */ | 828 | */ |
| 813 | if (kgdb_io_module_registered) { | 829 | if (kgdb_io_module_registered) { |
| 814 | kgdb_io_module_registered = 0; | 830 | kgdb_io_module_registered = 0; |
| 831 | unregister_reboot_notifier(&dbg_reboot_notifier); | ||
| 815 | atomic_notifier_chain_unregister(&panic_notifier_list, | 832 | atomic_notifier_chain_unregister(&panic_notifier_list, |
| 816 | &kgdb_panic_event_nb); | 833 | &kgdb_panic_event_nb); |
| 817 | kgdb_arch_exit(); | 834 | kgdb_arch_exit(); |
