diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 0ca4bec176da..21d627551c31 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -38,12 +38,12 @@ __FBSDID("$FreeBSD$"); #include "opt_ntp.h" -#include "opt_ddb.h" #include "opt_watchdog.h" #include #include #include +#include #include #include #include @@ -69,10 +69,6 @@ __FBSDID("$FreeBSD$"); #include #endif -#ifdef DDB -#include -#endif - #ifdef DEVICE_POLLING extern void hardclock_device_poll(void); #endif /* DEVICE_POLLING */ @@ -543,12 +539,12 @@ watchdog_fire(void) } printf("Total %20ju\n", (uintmax_t)inttotal); -#ifdef DDB - db_print_backtrace(); - Debugger("watchdog timeout"); -#else /* !DDB */ +#ifdef KDB + kdb_backtrace(); + kdb_enter("watchdog timeout"); +#else panic("watchdog timeout"); -#endif /* DDB */ +#endif /* KDB */ } #endif /* SW_WATCHDOG */ diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 4bc3348b92ab..e966a4995358 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -208,7 +209,7 @@ malloc(size, type, flags) static int curerr, once; if (once == 0 && ppsratecheck(&lasterr, &curerr, 1)) { printf("Bad malloc flags: %x\n", indx); - backtrace(); + kdb_backtrace(); flags |= M_WAITOK; once++; } @@ -216,7 +217,7 @@ malloc(size, type, flags) #endif #if 0 if (size == 0) - Debugger("zero size malloc"); + kdb_enter("zero size malloc"); #endif #ifdef MALLOC_MAKE_FAILURES if ((flags & M_NOWAIT) && (malloc_failure_rate != 0)) { diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index 2fc79debf328..662cd4c6c664 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -585,11 +586,7 @@ _mtx_lock_spin(struct mtx *m, int opts, const char *file, int line) } if (i < 60000000) DELAY(1); -#ifdef DDB - else if (!db_active) { -#else - else { -#endif + else if (!kdb_active) { printf("spin lock %s held by %p for > 5 seconds\n", m->mtx_object.lo_name, (void *)m->mtx_lock); #ifdef WITNESS diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index fbf466075d33..edbbfdb1722d 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -37,9 +37,7 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_ddb.h" -#include "opt_ddb_trace.h" -#include "opt_ddb_unattended.h" +#include "opt_kdb.h" #include "opt_hw_wdog.h" #include "opt_mac.h" #include "opt_panic.h" @@ -52,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -70,9 +69,6 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef DDB -#include -#endif #ifndef PANIC_REBOOT_WAIT_TIME #define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */ @@ -84,8 +80,8 @@ __FBSDID("$FreeBSD$"); */ #include -#ifdef DDB -#ifdef DDB_UNATTENDED +#ifdef KDB +#ifdef KDB_UNATTENDED int debugger_on_panic = 0; #else int debugger_on_panic = 1; @@ -93,14 +89,14 @@ int debugger_on_panic = 1; SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RW, &debugger_on_panic, 0, "Run debugger on kernel panic"); -#ifdef DDB_TRACE +#ifdef KDB_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 +#endif /* KDB */ int sync_on_panic = 1; SYSCTL_INT(_kern, OID_AUTO, sync_on_panic, CTLFLAG_RW, @@ -127,7 +123,10 @@ const char *panicstr; int dumping; /* system is dumping */ static struct dumperinfo dumper; /* our selected dumper */ -static struct pcb dumppcb; /* "You Are Here" sign for dump-debuggers */ + +/* Context information for dump-debuggers. */ +static struct pcb dumppcb; /* Registers. */ +static lwpid_t dumptid; /* Thread ID. */ static void boot(int) __dead2; static void poweroff_wait(void *, int); @@ -233,6 +232,7 @@ doadump(void) { savectx(&dumppcb); + dumptid = curthread->td_tid; dumping++; dumpsys(&dumper); } @@ -249,10 +249,8 @@ boot(int howto) /* collect extra flags that shutdown_nice might have set */ howto |= shutdown_howto; -#ifdef DDB /* We are out of the debugger now. */ - db_active = 0; -#endif + kdb_active = 0; #ifdef SMP if (smp_active) @@ -457,22 +455,6 @@ shutdown_reset(void *junk, int howto) /* NOTREACHED */ /* assuming reset worked */ } -/* - * Print a backtrace if we can. - */ - -void -backtrace(void) -{ - -#ifdef DDB - printf("Stack backtrace:\n"); - db_print_backtrace(); -#else - printf("Sorry, need DDB option to print backtrace"); -#endif -} - #ifdef SMP static u_int panic_cpu = NOCPU; #endif @@ -536,11 +518,11 @@ panic(const char *fmt, ...) #endif #endif -#if defined(DDB) +#ifdef KDB if (newpanic && trace_on_panic) - backtrace(); + kdb_backtrace(); if (debugger_on_panic) - Debugger ("panic"); + kdb_enter("panic"); #ifdef RESTARTABLE_PANICS /* See if the user aborted the panic, in which case we continue. */ if (panicstr == NULL) { diff --git a/sys/kern/kern_switch.c b/sys/kern/kern_switch.c index a2fb0d8d2f58..768084c76b8c 100644 --- a/sys/kern/kern_switch.c +++ b/sys/kern/kern_switch.c @@ -92,6 +92,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -715,7 +716,7 @@ void panc(char *string1, char *string2) { printf("%s", string1); - Debugger(string2); + kdb_enter(string2); } void diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index f8f4dd7da22d..701630725e8b 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -37,12 +37,12 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_ddb.h" #include "opt_ktrace.h" #include #include #include +#include #include #include #include @@ -57,9 +57,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef DDB -#include -#endif #ifdef KTRACE #include #include @@ -321,16 +318,15 @@ mi_switch(int flags, struct thread *newtd) td->td_generation++; /* bump preempt-detect counter */ -#ifdef DDB /* * Don't perform context switches from the debugger. */ - if (db_active) { + if (kdb_active) { mtx_unlock_spin(&sched_lock); - db_print_backtrace(); - db_error("Context switches not allowed in the debugger"); + kdb_backtrace(); + kdb_reenter(); + panic("%s: did not reenter debugger", __func__); } -#endif /* * Check if the process exceeds its cpu resource allocation. If