diff options
author | Per Fogelstrom <pefo@cvs.openbsd.org> | 2004-09-15 16:05:19 +0000 |
---|---|---|
committer | Per Fogelstrom <pefo@cvs.openbsd.org> | 2004-09-15 16:05:19 +0000 |
commit | a678f6f8c07a0de721b20bab35929cd5f4347867 (patch) | |
tree | 0d7419c9e9ded3ab0aaef1be7ac1d651d0e0776d /sys/arch | |
parent | 09f3e009a96eb4249a879b768a4ea5884e5dcf94 (diff) |
Make trace work better. Don't hope for a good stacktrace without symbols
loaded. GCC 3.x really moves things around.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/mips64/mips64/db_disasm.c | 6 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/db_machdep.c | 25 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/lcore_ddb.S | 43 |
3 files changed, 60 insertions, 14 deletions
diff --git a/sys/arch/mips64/mips64/db_disasm.c b/sys/arch/mips64/mips64/db_disasm.c index 108ed73330f..d0d6808a80f 100644 --- a/sys/arch/mips64/mips64/db_disasm.c +++ b/sys/arch/mips64/mips64/db_disasm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_disasm.c,v 1.2 2004/08/10 20:15:47 deraadt Exp $ */ +/* $OpenBSD: db_disasm.c,v 1.3 2004/09/15 16:05:18 pefo Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)kadb.c 8.1 (Berkeley) 6/10/93 - * $Id: db_disasm.c,v 1.2 2004/08/10 20:15:47 deraadt Exp $ + * $Id: db_disasm.c,v 1.3 2004/09/15 16:05:18 pefo Exp $ */ #include <sys/param.h> @@ -97,7 +97,7 @@ static char *fmt_name[16] = { static char *reg_name[32] = { "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", - "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", + "ta0", "ta1", "ta2", "ta3", "t0", "t1", "t2", "t3", "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra" }; diff --git a/sys/arch/mips64/mips64/db_machdep.c b/sys/arch/mips64/mips64/db_machdep.c index 10c6e3368f4..83bf04ec2b6 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.5 2004/09/09 22:11:38 pefo Exp $ */ +/* $OpenBSD: db_machdep.c,v 1.6 2004/09/15 16:05:18 pefo Exp $ */ /* * Copyright (c) 1998-2003 Opsycon AB (www.opsycon.se) @@ -54,11 +54,13 @@ u_long MipsEmulateBranch(db_regs_t *, int, int, u_int); void stacktrace_subr(db_regs_t *, int (*)(const char*, ...)); int kdbpeek(void *); +int64_t kdbpeekd(void *); short kdbpeekw(void *); char kdbpeekb(void *); -void kdbpoke(int, int); -void kdbpokew(int, short); -void kdbpokeb(int, char); +void kdbpoke(vaddr_t, int); +void kdbpoked(vaddr_t, int64_t); +void kdbpokew(vaddr_t, short); +void kdbpokeb(vaddr_t, char); int kdb_trap(int, struct trap_frame *); void db_trap_trace_cmd(db_expr_t, int, db_expr_t, char *); @@ -273,8 +275,11 @@ loop: /* * Dig out the function from the symbol table. + * Watch out for function tail optimizations. */ sym = db_search_symbol(pc, DB_STGY_ANY, &diff); + if (sym != DB_SYM_NULL && diff == 0) + sym = db_search_symbol(pc - 4, DB_STGY_ANY, &diff); db_symbol_values(sym, &symname, 0); if (sym != DB_SYM_NULL) { subr = pc - diff; @@ -358,23 +363,23 @@ loop: mask |= (1 << i.IType.rt); switch (i.IType.rt) { case 4: /* a0 */ - a0 = kdbpeek((int *)(sp + (short)i.IType.imm)); + a0 = kdbpeekd((long *)(sp + (short)i.IType.imm)); break; case 5: /* a1 */ - a1 = kdbpeek((int *)(sp + (short)i.IType.imm)); + a1 = kdbpeekd((long *)(sp + (short)i.IType.imm)); break; case 6: /* a2 */ - a2 = kdbpeek((int *)(sp + (short)i.IType.imm)); + a2 = kdbpeekd((long *)(sp + (short)i.IType.imm)); break; case 7: /* a3 */ - a3 = kdbpeek((int *)(sp + (short)i.IType.imm)); + a3 = kdbpeekd((long *)(sp + (short)i.IType.imm)); break; case 31: /* ra */ - ra = kdbpeek((int *)(sp + (short)i.IType.imm)); + ra = kdbpeekd((long *)(sp + (short)i.IType.imm)); break; } break; @@ -399,7 +404,7 @@ done: } else { (*pr)("%s+%p ", symname, diff); } - (*pr)("(%x,%x,%x,%x) sp %x ra %x, sz %d\n", a0, a1, a2, a3, sp, ra, stksize); + (*pr)("(%llx,%llx,%llx,%llx) sp %llx ra %llx, sz %d\n", a0, a1, a2, a3, sp, ra, stksize); if (subr == (long)k_intr || subr == (long)k_general) { if (subr == (long)k_intr) diff --git a/sys/arch/mips64/mips64/lcore_ddb.S b/sys/arch/mips64/mips64/lcore_ddb.S index 1324b8aad5a..d0071ac7b43 100644 --- a/sys/arch/mips64/mips64/lcore_ddb.S +++ b/sys/arch/mips64/mips64/lcore_ddb.S @@ -1,4 +1,4 @@ -/* $OpenBSD: lcore_ddb.S,v 1.4 2004/09/10 08:58:27 pefo Exp $ */ +/* $OpenBSD: lcore_ddb.S,v 1.5 2004/09/15 16:05:18 pefo Exp $ */ /* * Copyright (c) 2001-2003 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -42,6 +42,26 @@ #define ITLBNOPFIX nop;nop;nop;nop;nop;nop;nop;nop;nop;nop; +#ifdef __LP64__ +LEAF(kdbpeekd, 0) + PTR_L t0, curprocpaddr + li v0, KT_DDBERR + and v1, a0, 7 # unaligned ? + bne v1, zero, 1f + sw v0, U_PCB_ONFAULT(t0) + + ld v0, (a0) + jr ra + sw zero, U_PCB_ONFAULT(t0) + +1: + LDHI v0, 0(a0) + LDLO v0, 7(a0) + jr ra + sw zero, U_PCB_ONFAULT(t0) +END(kdbpeekd) +#endif + LEAF(kdbpeek, 0) PTR_L t0, curprocpaddr li v0, KT_DDBERR @@ -91,6 +111,27 @@ kt_ddberr: jr ra li v0, -1 +#ifdef __LP64__ +LEAF(kdbpoked, 0) + PTR_L t0, curprocpaddr + li v0, KT_DDBERR + and v1, a0, 7 # unaligned ? + bne v1, zero, 1f + sw v0, U_PCB_ONFAULT(t0) + + sd a1, (a0) + jr ra + sw zero, U_PCB_ONFAULT(t0) + +1: + SDHI a1, 0(a0) + SDLO a1, 7(a0) + jr ra + sw zero, U_PCB_ONFAULT(t0) +END(kdbpoke) +#endif + + LEAF(kdbpoke, 0) PTR_L t0, curprocpaddr li v0, KT_DDBERR |