summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorhiren <hiren@FreeBSD.org>2016-09-16 00:14:26 +0000
committerhiren <hiren@FreeBSD.org>2016-09-16 00:14:26 +0000
commit6d45a159b0dbfb46fbfa40bf87fab0cb4028491e (patch)
tree5cb038f48a31a613bfb02edd0a887c4c2eb7bf68 /sys/kern
parent0042789fce224f7387a9a1e82ef4ebeddb5dd2ec (diff)
downloadFreeBSD-src-6d45a159b0dbfb46fbfa40bf87fab0cb4028491e.zip
FreeBSD-src-6d45a159b0dbfb46fbfa40bf87fab0cb4028491e.tar.gz
MFC r301522 (by bz)
Implement a `show panic` command to DDB which will helpfully print the panic string again if set, in case it scrolled out of the active window. This avoids having to remember the symbol name. Also add a show callout <addr> command to DDB in order to inspect some struct callout fields in case of panics in the callout code. This may help to see if there was memory corruption or to further ease debugging problems. No objection by: bz
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_shutdown.c11
-rw-r--r--sys/kern/kern_timeout.c37
2 files changed, 48 insertions, 0 deletions
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index 8139c8c..d590555 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -1031,3 +1031,14 @@ mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver,
strlcpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
kdh->parity = kerneldump_parity(kdh);
}
+
+#ifdef DDB
+DB_SHOW_COMMAND(panic, db_show_panic)
+{
+
+ if (panicstr == NULL)
+ db_printf("panicstr not set\n");
+ else
+ db_printf("panic: %s\n", panicstr);
+}
+#endif
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c
index 7e5aab7..f3c4e78 100644
--- a/sys/kern/kern_timeout.c
+++ b/sys/kern/kern_timeout.c
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include "opt_callout_profiling.h"
#include "opt_kdtrace.h"
+#include "opt_ddb.h"
#if defined(__arm__)
#include "opt_timer.h"
#endif
@@ -60,6 +61,11 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/smp.h>
+#ifdef DDB
+#include <ddb/ddb.h>
+#include <machine/_inttypes.h>
+#endif
+
#ifdef SMP
#include <machine/cpu.h>
#endif
@@ -1576,3 +1582,34 @@ SYSCTL_PROC(_kern, OID_AUTO, callout_stat,
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE,
0, 0, sysctl_kern_callout_stat, "I",
"Dump immediate statistic snapshot of the scheduled callouts");
+
+#ifdef DDB
+static void
+_show_callout(struct callout *c)
+{
+
+ db_printf("callout %p\n", c);
+#define C_DB_PRINTF(f, e) db_printf(" %s = " f "\n", #e, c->e);
+ db_printf(" &c_links = %p\n", &(c->c_links));
+ C_DB_PRINTF("%" PRId64, c_time);
+ C_DB_PRINTF("%" PRId64, c_precision);
+ C_DB_PRINTF("%p", c_arg);
+ C_DB_PRINTF("%p", c_func);
+ C_DB_PRINTF("%p", c_lock);
+ C_DB_PRINTF("%#x", c_flags);
+ C_DB_PRINTF("%#x", c_iflags);
+ C_DB_PRINTF("%d", c_cpu);
+#undef C_DB_PRINTF
+}
+
+DB_SHOW_COMMAND(callout, db_show_callout)
+{
+
+ if (!have_addr) {
+ db_printf("usage: show callout <struct callout *>\n");
+ return;
+ }
+
+ _show_callout((struct callout *)addr);
+}
+#endif /* DDB */
OpenPOWER on IntegriCloud