Fix stack traces in DDB for the debugger thread.
When the kernel debugger is entered, makectx() is called to store appropriate state from the trapframe for the debugger into a global kdb_pcb used as the thread context of the thread entering the debugger. Stack unwinders for DDB called via db_trace_thread() are supposed to then use this saved context so that the stack trace for the current thread starts at the location of the event that triggered debugger entry. MIPS was instead starting the stack trace of the current thread from the context of db_trace_thread itself and unwinding back out through the debugger to the original frame. Fix a couple of things to bring MIPS inline with other platforms: - Fix makectx() to store the PC, SP, and RA in the right portion of the PCB used by db_trace_thread(). - Fix db_trace_thread() to always use kdb_thr_ctx() (and thus kdb_pcb for the debugger thread). - Move the logic for tracing curthread from within the current function into db_trace_self() to match other architectures. Sponsored by: DARPA / AFRL
This commit is contained in:
parent
2aca18c7ae
commit
2aa82aeacc
@ -431,18 +431,9 @@ db_md_list_watchpoints()
|
||||
|
||||
void
|
||||
db_trace_self(void)
|
||||
{
|
||||
db_trace_thread (curthread, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
db_trace_thread(struct thread *thr, int count)
|
||||
{
|
||||
register_t pc, ra, sp;
|
||||
struct pcb *ctx;
|
||||
|
||||
if (thr == curthread) {
|
||||
sp = (register_t)(intptr_t)__builtin_frame_address(0);
|
||||
ra = (register_t)(intptr_t)__builtin_return_address(0);
|
||||
|
||||
@ -454,16 +445,21 @@ db_trace_thread(struct thread *thr, int count)
|
||||
"move $31, %1\n" /* restore ra */
|
||||
: "=r" (pc)
|
||||
: "r" (ra));
|
||||
stacktrace_subr(pc, sp, ra, db_printf);
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
db_trace_thread(struct thread *thr, int count)
|
||||
{
|
||||
register_t pc, ra, sp;
|
||||
struct pcb *ctx;
|
||||
|
||||
} else {
|
||||
ctx = kdb_thr_ctx(thr);
|
||||
sp = (register_t)ctx->pcb_context[PCB_REG_SP];
|
||||
pc = (register_t)ctx->pcb_context[PCB_REG_PC];
|
||||
ra = (register_t)ctx->pcb_context[PCB_REG_RA];
|
||||
}
|
||||
|
||||
stacktrace_subr(pc, sp, ra,
|
||||
(int (*) (const char *, ...))db_printf);
|
||||
stacktrace_subr(pc, sp, ra, db_printf);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -292,9 +292,9 @@ void
|
||||
makectx(struct trapframe *tf, struct pcb *pcb)
|
||||
{
|
||||
|
||||
pcb->pcb_regs.ra = tf->ra;
|
||||
pcb->pcb_regs.pc = tf->pc;
|
||||
pcb->pcb_regs.sp = tf->sp;
|
||||
pcb->pcb_context[PCB_REG_RA] = tf->ra;
|
||||
pcb->pcb_context[PCB_REG_PC] = tf->pc;
|
||||
pcb->pcb_context[PCB_REG_SP] = tf->sp;
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user