summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2007-12-25 17:52:02 +0000
committerrwatson <rwatson@FreeBSD.org>2007-12-25 17:52:02 +0000
commitbdee30611dab246a5227856892385a02c7352f12 (patch)
treeae45f86ab6fb75519ba2d9dbc206616dba84cc13 /sys/kern
parente3b63ab4174a215e3a606c591d7a3f41490e75e6 (diff)
downloadFreeBSD-src-bdee30611dab246a5227856892385a02c7352f12.zip
FreeBSD-src-bdee30611dab246a5227856892385a02c7352f12.tar.gz
Add a new 'why' argument to kdb_enter(), and a set of constants to use
for that argument. This will allow DDB to detect the broad category of reason why the debugger has been entered, which it can use for the purposes of deciding which DDB script to run. Assign approximate why values to all current consumers of the kdb_enter() interface.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_clock.c2
-rw-r--r--sys/kern/kern_shutdown.c2
-rw-r--r--sys/kern/subr_kdb.c16
-rw-r--r--sys/kern/subr_witness.c4
-rw-r--r--sys/kern/vfs_subr.c4
5 files changed, 18 insertions, 10 deletions
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c
index 217e2ef..fb0ca7e 100644
--- a/sys/kern/kern_clock.c
+++ b/sys/kern/kern_clock.c
@@ -637,7 +637,7 @@ watchdog_fire(void)
#if defined(KDB) && !defined(KDB_UNATTENDED)
kdb_backtrace();
- kdb_enter("watchdog timeout");
+ kdb_enter(KDB_WHY_WATCHDOG, "watchdog timeout");
#else
panic("watchdog timeout");
#endif
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index 088e781..baeed23 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -544,7 +544,7 @@ panic(const char *fmt, ...)
if (newpanic && trace_on_panic)
kdb_backtrace();
if (debugger_on_panic)
- kdb_enter("panic");
+ kdb_enter(KDB_WHY_PANIC, "panic");
#ifdef RESTARTABLE_PANICS
/* See if the user aborted the panic, in which case we continue. */
if (panicstr == NULL) {
diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c
index 0ab79fb..8b66a58 100644
--- a/sys/kern/subr_kdb.c
+++ b/sys/kern/subr_kdb.c
@@ -97,6 +97,11 @@ SYSCTL_INT(_debug_kdb, OID_AUTO, stop_cpus, CTLTYPE_INT | CTLFLAG_RW,
TUNABLE_INT("debug.kdb.stop_cpus", &kdb_stop_cpus);
#endif
+/*
+ * Flag to indicate to debuggers why the debugger was entered.
+ */
+const char * volatile kdb_why = KDB_WHY_UNSET;
+
static int
kdb_sysctl_available(SYSCTL_HANDLER_ARGS)
{
@@ -163,7 +168,7 @@ kdb_sysctl_enter(SYSCTL_HANDLER_ARGS)
return (error);
if (kdb_active)
return (EBUSY);
- kdb_enter("sysctl debug.kdb.enter");
+ kdb_enter(KDB_WHY_SYSCTL, "sysctl debug.kdb.enter");
return (0);
}
@@ -295,17 +300,20 @@ kdb_dbbe_select(const char *name)
* Enter the currently selected debugger. If a message has been provided,
* it is printed first. If the debugger does not support the enter method,
* it is entered by using breakpoint(), which enters the debugger through
- * kdb_trap().
+ * kdb_trap(). The 'why' argument will contain a more mechanically usable
+ * string than 'msg', and is relied upon by DDB scripting to identify the
+ * reason for entering the debugger so that the right script can be run.
*/
-
void
-kdb_enter(const char *msg)
+kdb_enter(const char *why, const char *msg)
{
if (kdb_dbbe != NULL && kdb_active == 0) {
if (msg != NULL)
printf("KDB: enter: %s\n", msg);
+ kdb_why = why;
breakpoint();
+ kdb_why = KDB_WHY_UNSET;
}
}
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 3019a7a..c5402c7 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -1123,7 +1123,7 @@ debugger:
if (witness_trace)
kdb_backtrace();
if (witness_kdb)
- kdb_enter(__func__);
+ kdb_enter(KDB_WHY_WITNESS, __func__);
#endif
}
@@ -1396,7 +1396,7 @@ witness_warn(int flags, struct lock_object *lock, const char *fmt, ...)
panic("witness_warn");
#ifdef KDB
else if (witness_kdb && n)
- kdb_enter(__func__);
+ kdb_enter(KDB_WHY_WITNESS, __func__);
else if (witness_trace && n)
kdb_backtrace();
#endif
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 0e3a0ac..e912006 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -3456,7 +3456,7 @@ vfs_badlock(const char *msg, const char *str, struct vnode *vp)
if (vfs_badlock_print)
printf("%s: %p %s\n", str, (void *)vp, msg);
if (vfs_badlock_ddb)
- kdb_enter("lock violation");
+ kdb_enter(KDB_WHY_VFSLOCK, "lock violation");
}
void
@@ -3576,7 +3576,7 @@ vop_strategy_pre(void *ap)
printf(
"VOP_STRATEGY: bp is not locked but should be\n");
if (vfs_badlock_ddb)
- kdb_enter("lock violation");
+ kdb_enter(KDB_WHY_VFSLOCK, "lock violation");
}
#endif
}
OpenPOWER on IntegriCloud