diff --git a/sys/alpha/alpha/db_trace.c b/sys/alpha/alpha/db_trace.c index f84d1b9b291e..b8a200ceca18 100644 --- a/sys/alpha/alpha/db_trace.c +++ b/sys/alpha/alpha/db_trace.c @@ -60,6 +60,11 @@ #include #include +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) diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c index 8ac4c01ab645..f3688c51c9a1 100644 --- a/sys/amd64/amd64/db_trace.c +++ b/sys/amd64/amd64/db_trace.c @@ -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) diff --git a/sys/ddb/ddb.h b/sys/ddb/ddb.h index ce3ffc41278a..1eb87ba0ce27 100644 --- a/sys/ddb/ddb.h +++ b/sys/ddb/ddb.h @@ -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. */ diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c index 8ac4c01ab645..f3688c51c9a1 100644 --- a/sys/i386/i386/db_trace.c +++ b/sys/i386/i386/db_trace.c @@ -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) diff --git a/sys/ia64/ia64/db_trace.c b/sys/ia64/ia64/db_trace.c index ffd8302217d9..df630b254e13 100644 --- a/sys/ia64/ia64/db_trace.c +++ b/sys/ia64/ia64/db_trace.c @@ -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; diff --git a/sys/powerpc/powerpc/db_trace.c b/sys/powerpc/powerpc/db_trace.c index fe5efce57212..0ea97589317f 100644 --- a/sys/powerpc/powerpc/db_trace.c +++ b/sys/powerpc/powerpc/db_trace.c @@ -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) +{ +} diff --git a/sys/sparc64/sparc64/db_trace.c b/sys/sparc64/sparc64/db_trace.c index 417cb809c38f..92f7ccb6a307 100644 --- a/sys/sparc64/sparc64/db_trace.c +++ b/sys/sparc64/sparc64/db_trace.c @@ -305,3 +305,8 @@ db_utrace(struct thread *td, struct trapframe *tf) } db_printf("done\n"); } + +void +db_stack_trace_cmd(void) +{ +}