diff options
author | jeff <jeff@FreeBSD.org> | 2005-08-03 04:33:48 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2005-08-03 04:33:48 +0000 |
commit | 0b6d38e89f73861edc118b9f13efec01813c8e6a (patch) | |
tree | 62857315d58829734858fc771fb5b0091db01b52 | |
parent | 4a761caec7754f1fc2754466099320c54bf45abb (diff) | |
download | FreeBSD-src-0b6d38e89f73861edc118b9f13efec01813c8e6a.zip FreeBSD-src-0b6d38e89f73861edc118b9f13efec01813c8e6a.tar.gz |
- Add support for saving stack traces and displaying them via printf(9)
and KTR.
Contributed by: Antoine Brodin <antoine.brodin@laposte.net>
Concept code from: Neal Fachan <neal@isilon.com>
-rw-r--r-- | sys/amd64/amd64/db_trace.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c index e48eff8..264daaa 100644 --- a/sys/amd64/amd64/db_trace.c +++ b/sys/amd64/amd64/db_trace.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/kdb.h> #include <sys/proc.h> +#include <sys/stack.h> #include <sys/sysent.h> #include <machine/cpu.h> @@ -495,6 +496,28 @@ db_trace_thread(struct thread *thr, int count) ctx->pcb_rip, count)); } +void +stack_save(struct stack *st) +{ + struct amd64_frame *frame; + vm_offset_t callpc; + register_t rbp; + + stack_zero(st); + __asm __volatile("movq %%rbp,%0" : "=r" (rbp)); + frame = (struct amd64_frame *)rbp; + while (1) { + if (!INKERNEL((long)frame)) + break; + callpc = frame->f_retaddr; + if (!INKERNEL(callpc)) + break; + if (stack_put(st, callpc) == -1) + break; + frame = frame->f_frame; + } +} + int amd64_set_watch(watchnum, watchaddr, size, access, d) int watchnum; |