KDB_TRACE and no backend
Andriy Gapon
avg at icyb.net.ua
Sat Sep 18 11:23:40 UTC 2010
Here's a small patch that adds support for printing stack trace in form of frame
addresses when KDB_TRACE is enabled, but there is no debugger backend configured.
The patch is styled after "cheap" variant of stack_ktr.
What do you think (useful/useless, correct, etc) ?
--- a/sys/kern/subr_kdb.c
+++ b/sys/kern/subr_kdb.c
@@ -37,6 +37,7 @@
#include <sys/pcpu.h>
#include <sys/proc.h>
#include <sys/smp.h>
+#include <sys/stack.h>
#include <sys/sysctl.h>
#include <machine/kdb.h>
@@ -295,10 +296,16 @@
void
kdb_backtrace(void)
{
+ struct stack st;
+ int i;
- if (kdb_dbbe != NULL && kdb_dbbe->dbbe_trace != NULL) {
- printf("KDB: stack backtrace:\n");
+ printf("KDB: stack backtrace:\n");
+ if (kdb_dbbe != NULL && kdb_dbbe->dbbe_trace != NULL)
kdb_dbbe->dbbe_trace();
+ else {
+ stack_save(&st);
+ for (i = 0; i < st.depth; i++)
+ printf("#%d %p\n", i, (void*)(uintptr_t)st.pcs[i]);
}
}
--
Andriy Gapon
More information about the freebsd-hackers
mailing list