From 0b6d38e89f73861edc118b9f13efec01813c8e6a Mon Sep 17 00:00:00 2001 From: jeff Date: Wed, 3 Aug 2005 04:33:48 +0000 Subject: - Add support for saving stack traces and displaying them via printf(9) and KTR. Contributed by: Antoine Brodin Concept code from: Neal Fachan --- sys/amd64/amd64/db_trace.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'sys/amd64') 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 #include #include +#include #include #include @@ -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; -- cgit v1.1