From d0f5f62d8b8081e25133db2bebcdb43edd51573e Mon Sep 17 00:00:00 2001 From: Jeff Roberson Date: Wed, 3 Aug 2005 04:33:48 +0000 Subject: [PATCH] - 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(+) diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c index e48eff8bb264..264daaa1d1f2 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;