diff options
author | peter <peter@FreeBSD.org> | 2008-05-04 23:29:38 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2008-05-04 23:29:38 +0000 |
commit | 5a3c5f632b4461dbf60ab538e16453104b937231 (patch) | |
tree | dec162871c2e0c2defef809d28858069fac12065 /sys/kern | |
parent | 40ba3f0b054237aea1c061c7ae1d4a9b1b5dd800 (diff) | |
download | FreeBSD-src-5a3c5f632b4461dbf60ab538e16453104b937231.zip FreeBSD-src-5a3c5f632b4461dbf60ab538e16453104b937231.tar.gz |
Expand kdb_alt_break a little, most commonly used with the option
ALT_BREAK_TO_DEBUGGER. In addition to "Enter ~ ctrl-B" (to enter the
debugger), there is now "Enter ~ ctrl-P" (force panic) and
"Enter ~ ctrl-R" (request clean reboot, ala ctrl-alt-del on syscons).
We've used variations of this at work. The force panic sequence is
best used with KDB_UNATTENDED for when you just want it to dump and
get on with it.
The reboot request is a safer way of getting into single user than
a power cycle. eg: you've hosed the ability to log in (pam, rtld, etc).
It gives init the reboot signal, which causes an orderly reboot.
I've taken my best guess at what the !x86 and non-sio code changes
should be.
This also makes sio release its spinlock before calling KDB/DDB.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/subr_kdb.c | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index 8b66a58..602093b 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -221,6 +221,25 @@ kdb_sysctl_trap_code(SYSCTL_HANDLER_ARGS) return (0); } +void +kdb_panic(const char *msg) +{ + +#ifdef SMP + stop_cpus(PCPU_GET(other_cpus)); +#endif + printf("KDB: panic\n"); + panic(msg); +} + +void +kdb_reboot(void) +{ + + printf("KDB: reboot requested\n"); + shutdown_nice(0); +} + /* * Solaris implements a new BREAK which is initiated by a character sequence * CR ~ ^b which is similar to a familiar pattern used on Sun servers by the @@ -235,6 +254,8 @@ kdb_sysctl_trap_code(SYSCTL_HANDLER_ARGS) #define KEY_CR 13 /* CR '\r' */ #define KEY_TILDE 126 /* ~ */ #define KEY_CRTLB 2 /* ^B */ +#define KEY_CRTLP 16 /* ^P */ +#define KEY_CRTLR 18 /* ^R */ int kdb_alt_break(int key, int *state) @@ -242,20 +263,23 @@ kdb_alt_break(int key, int *state) int brk; brk = 0; - switch (key) { - case KEY_CR: - *state = KEY_TILDE; + switch (*state) { + case 0: + if (key == KEY_CR) + *state = 1; break; - case KEY_TILDE: - *state = (*state == KEY_TILDE) ? KEY_CRTLB : 0; + case 1: + if (key == KEY_TILDE) + *state = 2; break; - case KEY_CRTLB: - if (*state == KEY_CRTLB) - brk = 1; - /* FALLTHROUGH */ - default: + case 2: + if (key == KEY_CRTLB) + brk = KDB_REQ_DEBUGGER; + else if (key == KEY_CRTLP) + brk = KDB_REQ_PANIC; + else if (key == KEY_CRTLR) + brk = KDB_REQ_REBOOT; *state = 0; - break; } return (brk); } |