diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-11-21 23:56:57 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-11-21 23:56:57 +0000 |
commit | 0c9a904c641786e3e1a2e6befa424fea77632345 (patch) | |
tree | f7f3fbf9523768a990806b7b6fa31f8952aa49de /sys/arch | |
parent | 418e63ba22272cb8f88b936c711fe21354811ecd (diff) |
Fix uninitialized variables in db_stack_trace_print(), and honour the
frame count argument.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/mips64/mips64/db_machdep.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/sys/arch/mips64/mips64/db_machdep.c b/sys/arch/mips64/mips64/db_machdep.c index 85db69eb418..ed82826b099 100644 --- a/sys/arch/mips64/mips64/db_machdep.c +++ b/sys/arch/mips64/mips64/db_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_machdep.c,v 1.19 2009/11/19 20:16:27 miod Exp $ */ +/* $OpenBSD: db_machdep.c,v 1.20 2009/11/21 23:56:56 miod Exp $ */ /* * Copyright (c) 1998-2003 Opsycon AB (www.opsycon.se) @@ -202,6 +202,10 @@ db_write_bytes(addr, size, data) } } +#define VALID_ADDRESS(va) \ + (((va) >= VM_MIN_KERNEL_ADDRESS && (va) < VM_MAX_KERNEL_ADDRESS) || \ + IS_XKPHYS(va) || ((va) >= CKSEG0_BASE && (va) < CKSSEG_BASE)) + void db_stack_trace_print(addr, have_addr, count, modif, pr) db_expr_t addr; @@ -219,7 +223,6 @@ db_stack_trace_print(addr, have_addr, count, modif, pr) unsigned instr, mask; InstFmt i; int more, stksize; - extern char edata[]; extern char k_intr[]; extern char k_general[]; struct trap_frame *regs = &ddb_regs; @@ -240,42 +243,23 @@ db_stack_trace_print(addr, have_addr, count, modif, pr) /* Jump here when done with a frame, to start a new one */ loop: - -/* Jump here after a nonstandard (interrupt handler) frame */ + symname = NULL; + ra = 0; + subr = 0; stksize = 0; + if (count-- == 0) + goto end; + /* check for bad SP: could foul up next frame */ - if (sp & 3 || (!IS_XKPHYS(sp) && sp < CKSEG0_BASE)) { + if (sp & 3 || !VALID_ADDRESS(sp)) { (*pr)("SP %p: not in kernel\n", sp); - ra = 0; - subr = 0; goto done; } -#if 0 - /* Backtraces should contine through interrupts from kernel mode */ - if (pc >= (vaddr_t)MipsKernIntr && pc < (vaddr_t)MipsUserIntr) { - (*pr)("MipsKernIntr+%x: (%x, %x ,%x) -------\n", - pc - (vaddr_t)MipsKernIntr, a0, a1, a2); - regs = (struct trap_frame *)(sp + STAND_ARG_SIZE); - a0 = kdbpeek(®s->a0); - a1 = kdbpeek(®s->a1); - a2 = kdbpeek(®s->a2); - a3 = kdbpeek(®s->a3); - - pc = kdbpeek(®s->pc); /* exc_pc - pc at time of exception */ - ra = kdbpeek(®s->ra); /* ra at time of exception */ - sp = kdbpeek(®s->sp); - goto specialframe; - } -#endif - - /* check for bad PC */ - if (pc & 3 || (!IS_XKPHYS(pc) && pc < CKSEG0_BASE) || - pc >= (vaddr_t)edata) { + if (pc & 3 || !VALID_ADDRESS(pc)) { (*pr)("PC %p: not in kernel\n", pc); - ra = 0; goto done; } @@ -418,6 +402,7 @@ done: goto loop; } +end: if (ra) { if (pc == ra && stksize == 0) (*pr)("stacktrace: loop!\n"); @@ -435,6 +420,8 @@ done: } } +#undef VALID_ADDRESS + /* * To do a single step ddb needs to know the next address * that we will get to. It means that we need to find out |