aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/debug
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2012-03-19 20:35:55 -0400
committerJason Wessel <jason.wessel@windriver.com>2012-03-22 16:07:16 -0400
commitbec4d62ead8096e433d624d9339893f50badd992 (patch)
treefd48a6b49acaec668f8b9dfa18c9dedc56d8a0b7 /kernel/debug
parent8f30d411767351656ea62c9e7612120f9b870b59 (diff)
kgdb,debug_core: add the ability to control the reboot notifier
Sometimes it is desirable to stop the kernel debugger before allowing a system to reboot either with kdb or kgdb. This patch adds the ability to turn the reboot notifier on and off or enter the debugger and stop kernel execution before rebooting. It is possible to change the setting after booting the kernel with the following: echo 1 > /sys/module/debug_core/parameters/kgdbreboot It is also possible to change this setting using kdb / kgdb to manipulate the variable directly. Using KDB: mm kgdbreboot 1 Using gdb: set kgdbreboot=1 Reported-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Diffstat (limited to 'kernel/debug')
-rw-r--r--kernel/debug/debug_core.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
index 3c1ad4e0354..3f88a45e6f0 100644
--- a/kernel/debug/debug_core.c
+++ b/kernel/debug/debug_core.c
@@ -76,6 +76,8 @@ static int exception_level;
76struct kgdb_io *dbg_io_ops; 76struct kgdb_io *dbg_io_ops;
77static DEFINE_SPINLOCK(kgdb_registration_lock); 77static DEFINE_SPINLOCK(kgdb_registration_lock);
78 78
79/* Action for the reboot notifiter, a global allow kdb to change it */
80static int kgdbreboot;
79/* kgdb console driver is loaded */ 81/* kgdb console driver is loaded */
80static int kgdb_con_registered; 82static int kgdb_con_registered;
81/* determine if kgdb console output should be used */ 83/* determine if kgdb console output should be used */
@@ -97,6 +99,7 @@ static int __init opt_kgdb_con(char *str)
97early_param("kgdbcon", opt_kgdb_con); 99early_param("kgdbcon", opt_kgdb_con);
98 100
99module_param(kgdb_use_con, int, 0644); 101module_param(kgdb_use_con, int, 0644);
102module_param(kgdbreboot, int, 0644);
100 103
101/* 104/*
102 * Holds information about breakpoints in a kernel. These breakpoints are 105 * Holds information about breakpoints in a kernel. These breakpoints are
@@ -788,8 +791,21 @@ void __init dbg_late_init(void)
788static int 791static int
789dbg_notify_reboot(struct notifier_block *this, unsigned long code, void *x) 792dbg_notify_reboot(struct notifier_block *this, unsigned long code, void *x)
790{ 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 }
791 if (!dbg_kdb_mode) 806 if (!dbg_kdb_mode)
792 gdbstub_exit(code); 807 gdbstub_exit(code);
808done:
793 return NOTIFY_DONE; 809 return NOTIFY_DONE;
794} 810}
795 811