diff options
author | jhb <jhb@FreeBSD.org> | 2002-09-19 18:49:46 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2002-09-19 18:49:46 +0000 |
commit | c3f8f2462068d0ea9b00cd728620418ac6ac0c5e (patch) | |
tree | faf57b41048f88eab4f0361c45f5985322428679 /sys/kern | |
parent | 03dc7bc4a4835049f8702ae7cd0097de1673c8f5 (diff) | |
download | FreeBSD-src-c3f8f2462068d0ea9b00cd728620418ac6ac0c5e.zip FreeBSD-src-c3f8f2462068d0ea9b00cd728620418ac6ac0c5e.tar.gz |
Add ability to dump stacktraces on kernel panics when DDB is compiled into
the kernel. By default this is turned off since otherwise it could scroll
valuable panic messages off of the screen. This option can be turned on
by the DDB_TRACE kernel option as well as the debug.trace_on_panic sysctl.
Also, fix the DDB_UNATTENDED option to use its own header instead of
abusing opt_ddb.h. This way turning that one option on or off doesn't
force you to recompile all of ddb.
Requested by: many (1), bde (2*)
* - I know bde prefers !abusing option headers in general but can't
remember if he as brought up this specific case.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_shutdown.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 13a9c7a..f8f676e 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -40,6 +40,8 @@ */ #include "opt_ddb.h" +#include "opt_ddb_trace.h" +#include "opt_ddb_unattended.h" #include "opt_hw_wdog.h" #include "opt_panic.h" #include "opt_show_busybufs.h" @@ -91,6 +93,14 @@ int debugger_on_panic = 1; #endif SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RW, &debugger_on_panic, 0, "Run debugger on kernel panic"); + +#ifdef DDB_TRACE +int trace_on_panic = 1; +#else +int trace_on_panic = 0; +#endif +SYSCTL_INT(_debug, OID_AUTO, trace_on_panic, CTLFLAG_RW, + &trace_on_panic, 0, "Print stack trace on kernel panic"); #endif int sync_on_panic = 1; @@ -434,7 +444,7 @@ void panic(const char *fmt, ...) { struct thread *td = curthread; - int bootopt; + int bootopt, newpanic; va_list ap; static char buf[256]; @@ -453,10 +463,13 @@ panic(const char *fmt, ...) #endif bootopt = RB_AUTOBOOT | RB_DUMP; + newpanic = 0; if (panicstr) bootopt |= RB_NOSYNC; - else + else { panicstr = fmt; + newpanic = 1; + } va_start(ap, fmt); (void)vsnprintf(buf, sizeof(buf), fmt, ap); @@ -475,6 +488,8 @@ panic(const char *fmt, ...) #endif #if defined(DDB) + if (newpanic && trace_on_panic) + db_print_backtrace(); if (debugger_on_panic) Debugger ("panic"); #ifdef RESTARTABLE_PANICS |