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.
This commit is contained in:
jhb 2002-09-19 18:49:46 +00:00
parent 03dc7bc4a4
commit c3f8f24620

View File

@ -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