aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_kdb.c
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2020-01-31 15:43:33 +0000
committerMark Johnston <markj@FreeBSD.org>2020-01-31 15:43:33 +0000
commit1c29da02798d968eb874b86221333a56393a94c3 (patch)
tree7e7256a063a5f1521e4fccc632f40eaac545c9f4 /sys/kern/subr_kdb.c
parent80ba579b00ba784ced94c0f2f6c374bd2bb2c9e8 (diff)
downloadsrc-1c29da02798d968eb874b86221333a56393a94c3.tar.gz
src-1c29da02798d968eb874b86221333a56393a94c3.zip
Reimplement stack capture of running threads on i386 and amd64.
After r355784 the td_oncpu field is no longer synchronized by the thread lock, so the stack capture interrupt cannot be delievered precisely. Fix this using a loop which drops the thread lock and restarts if the wrong thread was sampled from the stack capture interrupt handler. Change the implementation to use a regular interrupt instead of an NMI. Now that we drop the thread lock, there is no advantage to the latter. Simplify the KPIs. Remove stack_save_td_running() and add a return value to stack_save_td(). On platforms that do not support stack capture of running threads, stack_save_td() returns EOPNOTSUPP. If the target thread is running in user mode, stack_save_td() returns EBUSY. Reviewed by: kib Reported by: mjg, pho Tested by: pho Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D23355
Notes
Notes: svn path=/head/; revision=357334
Diffstat (limited to 'sys/kern/subr_kdb.c')
-rw-r--r--sys/kern/subr_kdb.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c
index 19d88186334b..4e4a55727446 100644
--- a/sys/kern/subr_kdb.c
+++ b/sys/kern/subr_kdb.c
@@ -432,9 +432,8 @@ kdb_backtrace_thread(struct thread *td)
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);
+ if (stack_save_td(&st, td) == 0)
+ stack_print_ddb(&st);
}
#endif
}