- 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>
This commit is contained in:
Jeff Roberson 2005-08-03 04:33:48 +00:00
parent 8d511e2a05
commit d0f5f62d8b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=148667

View File

@ -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;