aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/debug/debug_core.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2012-03-26 11:18:44 -0400
committerIngo Molnar <mingo@kernel.org>2012-03-26 11:19:03 -0400
commit7fd52392c56361a40f0c630a82b36b95ca31eac6 (patch)
tree14091de24c6b28ea4cae9826f98aeedb7be091f5 /kernel/debug/debug_core.c
parentb01c3a0010aabadf745f3e7fdb9cab682e0a28a2 (diff)
parente22057c8599373e5caef0bc42bdb95d2a361ab0d (diff)
Merge branch 'linus' into perf/urgent
Merge reason: we need to fix a non-trivial merge conflict. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/debug/debug_core.c')
-rw-r--r--kernel/debug/debug_core.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
index 0d7c08784ef..3f88a45e6f0 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>
@@ -75,6 +76,8 @@ static int exception_level;
75struct kgdb_io *dbg_io_ops; 76struct kgdb_io *dbg_io_ops;
76static DEFINE_SPINLOCK(kgdb_registration_lock); 77static DEFINE_SPINLOCK(kgdb_registration_lock);
77 78
79/* Action for the reboot notifiter, a global allow kdb to change it */
80static int kgdbreboot;
78/* kgdb console driver is loaded */ 81/* kgdb console driver is loaded */
79static int kgdb_con_registered; 82static int kgdb_con_registered;
80/* determine if kgdb console output should be used */ 83/* determine if kgdb console output should be used */
@@ -96,6 +99,7 @@ static int __init opt_kgdb_con(char *str)
96early_param("kgdbcon", opt_kgdb_con); 99early_param("kgdbcon", opt_kgdb_con);
97 100
98module_param(kgdb_use_con, int, 0644); 101module_param(kgdb_use_con, int, 0644);
102module_param(kgdbreboot, int, 0644);
99 103
100/* 104/*
101 * Holds information about breakpoints in a kernel. These breakpoints are 105 * Holds information about breakpoints in a kernel. These breakpoints are
@@ -784,6 +788,33 @@ void __init dbg_late_init(void)
784 kdb_init(KDB_INIT_FULL); 788 kdb_init(KDB_INIT_FULL);
785} 789}
786 790
791static int
792dbg_notify_reboot(struct notifier_block *this, unsigned long code, void *x)
793{
794 /*
795 * Take the following action on reboot notify depending on value:
796 * 1 == Enter debugger
797 * 0 == [the default] detatch debug client
798 * -1 == Do nothing... and use this until the board resets
799 */
800 switch (kgdbreboot) {
801 case 1:
802 kgdb_breakpoint();
803 case -1:
804 goto done;
805 }
806 if (!dbg_kdb_mode)
807 gdbstub_exit(code);
808done:
809 return NOTIFY_DONE;
810}
811
812static struct notifier_block dbg_reboot_notifier = {
813 .notifier_call = dbg_notify_reboot,
814 .next = NULL,
815 .priority = INT_MAX,
816};
817
787static void kgdb_register_callbacks(void) 818static void kgdb_register_callbacks(void)
788{ 819{
789 if (!kgdb_io_module_registered) { 820 if (!kgdb_io_module_registered) {
@@ -791,6 +822,7 @@ static void kgdb_register_callbacks(void)
791 kgdb_arch_init(); 822 kgdb_arch_init();
792 if (!dbg_is_early) 823 if (!dbg_is_early)
793 kgdb_arch_late(); 824 kgdb_arch_late();
825 register_reboot_notifier(&dbg_reboot_notifier);
794 atomic_notifier_chain_register(&panic_notifier_list, 826 atomic_notifier_chain_register(&panic_notifier_list,
795 &kgdb_panic_event_nb); 827 &kgdb_panic_event_nb);
796#ifdef CONFIG_MAGIC_SYSRQ 828#ifdef CONFIG_MAGIC_SYSRQ
@@ -812,6 +844,7 @@ static void kgdb_unregister_callbacks(void)
812 */ 844 */
813 if (kgdb_io_module_registered) { 845 if (kgdb_io_module_registered) {
814 kgdb_io_module_registered = 0; 846 kgdb_io_module_registered = 0;
847 unregister_reboot_notifier(&dbg_reboot_notifier);
815 atomic_notifier_chain_unregister(&panic_notifier_list, 848 atomic_notifier_chain_unregister(&panic_notifier_list,
816 &kgdb_panic_event_nb); 849 &kgdb_panic_event_nb);
817 kgdb_arch_exit(); 850 kgdb_arch_exit();