diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2010-09-27 10:08:29 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2010-09-27 10:08:29 +0000 |
commit | 4063d978c6296e826d1c61d09f011b37d5996663 (patch) | |
tree | a7da8f3f0b2a4ab76deea15eaa16948fa948de94 /sys | |
parent | c98ae35867e0450bf110754dadc99a99934b56f3 (diff) |
add support for tracing process stacks in ddb (trace /p).
due to the way arguments are parsed, pid has to be specified
in the hexadecimal notation.
tested by me and sthen, ok sthen kettenis
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/db_trace.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/sys/arch/amd64/amd64/db_trace.c b/sys/arch/amd64/amd64/db_trace.c index a790cf9a110..b784e72172f 100644 --- a/sys/arch/amd64/amd64/db_trace.c +++ b/sys/arch/amd64/amd64/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.6 2009/06/04 22:56:13 kettenis Exp $ */ +/* $OpenBSD: db_trace.c,v 1.7 2010/09/27 10:08:28 mikeb Exp $ */ /* $NetBSD: db_trace.c,v 1.1 2003/04/26 18:39:27 fvdl Exp $ */ /* @@ -209,7 +209,7 @@ db_stack_trace_print(db_expr_t addr, boolean_t have_addr, db_expr_t count, db_addr_t callpc; int is_trap = 0; boolean_t kernel_only = TRUE; - boolean_t trace_thread = FALSE; + boolean_t trace_proc = FALSE; #if 0 if (!db_trace_symbols_found) @@ -221,8 +221,8 @@ db_stack_trace_print(db_expr_t addr, boolean_t have_addr, db_expr_t count, char c; while ((c = *cp++) != 0) { - if (c == 't') - trace_thread = TRUE; + if (c == 'p') + trace_proc = TRUE; if (c == 'u') kernel_only = FALSE; } @@ -232,28 +232,16 @@ db_stack_trace_print(db_expr_t addr, boolean_t have_addr, db_expr_t count, frame = (struct x86_64_frame *)ddb_regs.tf_rbp; callpc = (db_addr_t)ddb_regs.tf_rip; } else { -#if 0 - if (trace_thread) { - struct proc *p; - struct user *u; - struct lwp *l; - (*pr)("trace: pid %d ", (int)addr); - p = pfind(addr); + if (trace_proc) { + struct proc *p = pfind((pid_t)addr); if (p == NULL) { - (*pr)("not found\n"); - return; - } - l = proc_representative_lwp(p); - if (!(l->l_flag&L_INMEM)) { - (*pr)("swapped out\n"); + (*pr) ("db_trace.c: process not found\n"); return; } - u = l->l_addr; - frame = (struct x86_64_frame *) u->u_pcb.pcb_rbp; - (*pr)("at %p\n", frame); - } else -#endif + frame = (struct x86_64_frame *)p->p_addr->u_pcb.pcb_rbp; + } else { frame = (struct x86_64_frame *)addr; + } callpc = (db_addr_t) db_get_value((db_addr_t)&frame->f_retaddr, 8, FALSE); frame = (struct x86_64_frame *)frame->f_frame; |