summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_kdb.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2012-04-12 17:43:59 +0000
committerjhb <jhb@FreeBSD.org>2012-04-12 17:43:59 +0000
commit20ac4e4f812f8a1caca5d5d792b599580c95d8e4 (patch)
tree26b9e2e550fbe63d131bb05f09fe4a80cd0e9c8c /sys/kern/subr_kdb.c
parent8840b80b150a66caf96c13d04b34664655ca1b7c (diff)
downloadFreeBSD-src-20ac4e4f812f8a1caca5d5d792b599580c95d8e4.zip
FreeBSD-src-20ac4e4f812f8a1caca5d5d792b599580c95d8e4.tar.gz
- Extend the KDB interface to add a per-debugger callback to print a
backtrace for an arbitrary thread (rather than the calling thread). A kdb_backtrace_thread() wrapper function uses the configured debugger if possible, otherwise it falls back to using stack(9) if that is available. - Replace a direct call to db_trace_thread() in propagate_priority() with a call to kdb_backtrace_thread() instead. MFC after: 1 week
Diffstat (limited to 'sys/kern/subr_kdb.c')
-rw-r--r--sys/kern/subr_kdb.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c
index 9ca34b1..59d6258 100644
--- a/sys/kern/subr_kdb.c
+++ b/sys/kern/subr_kdb.c
@@ -73,7 +73,7 @@ struct trapframe *kdb_frame = NULL;
static int kdb_break_to_debugger = KDB_BREAK_TO_DEBUGGER;
static int kdb_alt_break_to_debugger = KDB_ALT_BREAK_TO_DEBUGGER;
-KDB_BACKEND(null, NULL, NULL, NULL);
+KDB_BACKEND(null, NULL, NULL, NULL, NULL);
SET_DECLARE(kdb_dbbe_set, struct kdb_dbbe);
static int kdb_sysctl_available(SYSCTL_HANDLER_ARGS);
@@ -376,6 +376,7 @@ kdb_backtrace(void)
struct stack st;
printf("KDB: stack backtrace:\n");
+ stack_zero(&st);
stack_save(&st);
stack_print_ddb(&st);
}
@@ -383,6 +384,30 @@ kdb_backtrace(void)
}
/*
+ * Similar to kdb_backtrace() except that it prints a backtrace of an
+ * arbitrary thread rather than the calling thread.
+ */
+void
+kdb_backtrace_thread(struct thread *td)
+{
+
+ if (kdb_dbbe != NULL && kdb_dbbe->dbbe_trace_thread != NULL) {
+ printf("KDB: stack backtrace of thread %d:\n", td->td_tid);
+ kdb_dbbe->dbbe_trace_thread(td);
+ }
+#ifdef STACK
+ else {
+ struct stack st;
+
+ printf("KDB: stack backtrace of thread %d:\n", td->td_tid);
+ stack_zero(&st);
+ stack_save_td(&st, td);
+ stack_print_ddb(&st);
+ }
+#endif
+}
+
+/*
* Set/change the current backend.
*/
OpenPOWER on IntegriCloud