mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-02 08:42:48 +00:00
Implement db_print_backtrace() if DDB is compiled into the kernel. This
MD function is just a wrapper around db_stack_trace_cmd() that prints out a backtrace of curthread. Currently, this function is only implemented on i386 and alpha (and the alpha version isn't quite tested yet, will do that in a bit). Other changes: - For i386, fix a bug in the raw frame address case. The eip we extract from the passed in frame address does not match the frame we received. Thus, instead of printing a bogus frame with the wrong eip, go ahead and advance frame down to the same frame as the eip we are using. - For alpha, attempt to add a way of doing a raw trace for alpha. Instead of passing a frame address in 'addr', pass in a pointer to a structure containing PC and KSP and use those to start the backtrace. The alpha db_print_backtrace() uses asm to read in the current PC and KSP values into such a request. Tested on: i386 Requested by: many
This commit is contained in:
parent
37ee08bcab
commit
c79408a059
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=103646
@ -60,6 +60,11 @@
|
||||
#include <ddb/db_output.h>
|
||||
#include <alpha/alpha/db_instruction.h>
|
||||
|
||||
struct trace_request {
|
||||
register_t ksp;
|
||||
register_t pc;
|
||||
};
|
||||
|
||||
/*
|
||||
* Information about the `standard' Alpha function prologue.
|
||||
*/
|
||||
@ -260,8 +265,16 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *m
|
||||
frame = addr;
|
||||
}
|
||||
} else {
|
||||
db_printf("alpha trace requires known PC =eject=\n");
|
||||
return;
|
||||
struct trace_request *tr;
|
||||
|
||||
tr = (struct trace_request *)addr;
|
||||
if (tr->ksp >= KERNBASE && tr->pc >= KERNBASE) {
|
||||
db_printf("alpha trace requires known PC =eject=\n");
|
||||
return;
|
||||
}
|
||||
callpc = tr->pc;
|
||||
addr = tr->ksp;
|
||||
frame = addr;
|
||||
}
|
||||
|
||||
while (count--) {
|
||||
@ -377,7 +390,17 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *m
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
db_stack_trace_cmd(void)
|
||||
{
|
||||
struct trace_request tr;
|
||||
|
||||
__asm __volatile(
|
||||
" stq sp,%0 \n"
|
||||
" stq pc,%1 \n"
|
||||
: "=r" (tr.ksp), "=r" (tr.pc));
|
||||
db_stack_trace_cmd(&tr, 1, -1, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
db_md_set_watchpoint(addr, size)
|
||||
|
@ -350,6 +350,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif)
|
||||
p = NULL;
|
||||
frame = (struct i386_frame *)addr;
|
||||
callpc = (db_addr_t)db_get_value((int)&frame->f_retaddr, 4, FALSE);
|
||||
frame = frame->f_frame;
|
||||
}
|
||||
|
||||
first = TRUE;
|
||||
@ -470,6 +471,14 @@ DB_DRX_FUNC(dr6)
|
||||
DB_DRX_FUNC(dr7)
|
||||
|
||||
|
||||
void
|
||||
db_print_backtrace(void)
|
||||
{
|
||||
register_t ebp;
|
||||
|
||||
__asm __volatile("mov %%ebp,%0\n" : "=r" (ebp));
|
||||
db_stack_trace_cmd(ebp, 1, -1, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
i386_set_watch(watchnum, watchaddr, size, access, d)
|
||||
|
@ -134,6 +134,9 @@ db_cmdfcn_t ipc_port_print;
|
||||
db_cmdfcn_t vm_page_print;
|
||||
#endif
|
||||
|
||||
/* Scare the user with backtrace of curthread to console. */
|
||||
void db_print_backtrace(void);
|
||||
|
||||
/*
|
||||
* Command table.
|
||||
*/
|
||||
|
@ -350,6 +350,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif)
|
||||
p = NULL;
|
||||
frame = (struct i386_frame *)addr;
|
||||
callpc = (db_addr_t)db_get_value((int)&frame->f_retaddr, 4, FALSE);
|
||||
frame = frame->f_frame;
|
||||
}
|
||||
|
||||
first = TRUE;
|
||||
@ -470,6 +471,14 @@ DB_DRX_FUNC(dr6)
|
||||
DB_DRX_FUNC(dr7)
|
||||
|
||||
|
||||
void
|
||||
db_print_backtrace(void)
|
||||
{
|
||||
register_t ebp;
|
||||
|
||||
__asm __volatile("mov %%ebp,%0\n" : "=r" (ebp));
|
||||
db_stack_trace_cmd(ebp, 1, -1, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
i386_set_watch(watchnum, watchaddr, size, access, d)
|
||||
|
@ -134,6 +134,11 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *m
|
||||
ia64_free_unwind_state(us);
|
||||
}
|
||||
|
||||
void
|
||||
db_print_backtrace(void)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
db_md_set_watchpoint(addr, size)
|
||||
db_expr_t addr;
|
||||
|
@ -291,3 +291,7 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
|
||||
db_stack_trace_print(addr, have_addr, count, modif, db_printf);
|
||||
}
|
||||
|
||||
void
|
||||
db_print_backtrace(void)
|
||||
{
|
||||
}
|
||||
|
@ -305,3 +305,8 @@ db_utrace(struct thread *td, struct trapframe *tf)
|
||||
}
|
||||
db_printf("done\n");
|
||||
}
|
||||
|
||||
void
|
||||
db_stack_trace_cmd(void)
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user