Update for the KDB framework:
o Make debugging code conditional upon KDB instead of DDB. o Call kdb_enter() instead of Debugger(). o Call kdb_backtrace() instead of db_print_backtrace() or backtrace(). kern_mutex.c: o Replace checks for db_active with checks for kdb_active and make them unconditional. kern_shutdown.c: o s/DDB_UNATTENDED/KDB_UNATTENDED/g o s/DDB_TRACE/KDB_TRACE/g o Save the TID of the thread doing the kernel dump so the debugger knows which thread to select as the current when debugging the kernel core file. o Clear kdb_active instead of db_active and do so unconditionally. o Remove backtrace() implementation. kern_synch.c: o Call kdb_reenter() instead of db_error().
This commit is contained in:
parent
89cf7c254d
commit
2d50560abc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=131927
@ -38,12 +38,12 @@
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_ntp.h"
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_watchdog.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/callout.h>
|
||||
#include <sys/kdb.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/ktr.h>
|
||||
@ -69,10 +69,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/gmon.h>
|
||||
#endif
|
||||
|
||||
#ifdef DDB
|
||||
#include <ddb/ddb.h>
|
||||
#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 */
|
||||
|
@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kdb.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/malloc.h>
|
||||
@ -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)) {
|
||||
|
@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/kdb.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/ktr.h>
|
||||
#include <sys/lock.h>
|
||||
@ -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
|
||||
|
@ -37,9 +37,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
__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 <sys/conf.h>
|
||||
#include <sys/cons.h>
|
||||
#include <sys/eventhandler.h>
|
||||
#include <sys/kdb.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/kthread.h>
|
||||
#include <sys/mac.h>
|
||||
@ -70,9 +69,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/smp.h>
|
||||
|
||||
#include <sys/signalvar.h>
|
||||
#ifdef DDB
|
||||
#include <ddb/ddb.h>
|
||||
#endif
|
||||
|
||||
#ifndef PANIC_REBOOT_WAIT_TIME
|
||||
#define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */
|
||||
@ -84,8 +80,8 @@ __FBSDID("$FreeBSD$");
|
||||
*/
|
||||
#include <machine/stdarg.h>
|
||||
|
||||
#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) {
|
||||
|
@ -92,6 +92,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kdb.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/ktr.h>
|
||||
#include <sys/lock.h>
|
||||
@ -715,7 +716,7 @@ void
|
||||
panc(char *string1, char *string2)
|
||||
{
|
||||
printf("%s", string1);
|
||||
Debugger(string2);
|
||||
kdb_enter(string2);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -37,12 +37,12 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_ktrace.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/condvar.h>
|
||||
#include <sys/kdb.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/ktr.h>
|
||||
#include <sys/lock.h>
|
||||
@ -57,9 +57,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/sysproto.h>
|
||||
#include <sys/vmmeter.h>
|
||||
#ifdef DDB
|
||||
#include <ddb/ddb.h>
|
||||
#endif
|
||||
#ifdef KTRACE
|
||||
#include <sys/uio.h>
|
||||
#include <sys/ktrace.h>
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user