diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2001-12-06 23:45:24 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2001-12-06 23:45:24 +0000 |
commit | ea8811d7032f18e3ecbd46ca987803f455da6a39 (patch) | |
tree | 4ed03a690b8d7c8dba06b3f2ddb73fe147a6ac97 /sys | |
parent | efb4dc8bcd9edd35a637e0e92391977287ef886e (diff) |
DDB disassembly fixes and trace improvements from NetBSD.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/m68k/m68k/db_disasm.c | 13 | ||||
-rw-r--r-- | sys/arch/m68k/m68k/db_trace.c | 71 |
2 files changed, 65 insertions, 19 deletions
diff --git a/sys/arch/m68k/m68k/db_disasm.c b/sys/arch/m68k/m68k/db_disasm.c index be8302f0ed1..0a3da150603 100644 --- a/sys/arch/m68k/m68k/db_disasm.c +++ b/sys/arch/m68k/m68k/db_disasm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_disasm.c,v 1.7 2001/05/15 01:43:15 millert Exp $ */ +/* $OpenBSD: db_disasm.c,v 1.8 2001/12/06 23:45:23 miod Exp $ */ /* $NetBSD: db_disasm.c,v 1.19 1996/10/30 08:22:39 is Exp $ */ /* @@ -647,6 +647,10 @@ opcode_misc(dbuf, opc) get_modregstr(dbuf, 2, AR_DIR, 0, 0); } return; + case SWAP_INST: + addstr(dbuf, "swap\t"); + get_modregstr(dbuf, 2, DR_DIR, 0, 0); + return; case UNLK_INST: addstr(dbuf, "unlk\t"); get_modregstr(dbuf, 2, AR_DIR, 0, 0); @@ -907,11 +911,11 @@ opcode_addsub(dbuf, opc) } } - if (IS_INST(ADDX,opc) || IS_INST(SUBX,opc)) { + if (!amode && (IS_INST(ADDX,opc) || IS_INST(SUBX,opc))) { if (IS_INST(ADDX,opc)) addstr(dbuf,"addx"); else - addstr(dbuf,"addx"); + addstr(dbuf,"subx"); addchar(ch); addchar('\t'); @@ -2095,6 +2099,9 @@ print_reglist(dbuf, mod, rl) } } } + if (list > 1) + addstr(dbuf, regs[15]); + if (dbuf->casm[-1] == '/' || dbuf->casm[-1] == '-') dbuf->casm--; *dbuf->casm = 0; diff --git a/sys/arch/m68k/m68k/db_trace.c b/sys/arch/m68k/m68k/db_trace.c index 7dfe0aef267..9048eb24e37 100644 --- a/sys/arch/m68k/m68k/db_trace.c +++ b/sys/arch/m68k/m68k/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.13 2001/11/16 22:04:45 mickey Exp $ */ +/* $OpenBSD: db_trace.c,v 1.14 2001/12/06 23:45:23 miod Exp $ */ /* $NetBSD: db_trace.c,v 1.20 1997/02/05 05:10:25 scottr Exp $ */ /* @@ -99,6 +99,8 @@ extern int curpcb; #define get(addr, space) \ (db_get_value((db_addr_t)(addr), sizeof(int), FALSE)) +#define get16(addr, space) \ + (db_get_value((db_addr_t)(addr), sizeof(u_short), FALSE)) #define NREGISTERS 16 @@ -125,8 +127,8 @@ static void stacktop __P((db_regs_t *, struct stackpos *)); static void stacktop(regs, sp) - register db_regs_t *regs; - register struct stackpos *sp; + db_regs_t *regs; + struct stackpos *sp; { int i; @@ -170,9 +172,7 @@ stacktop(regs, sp) #define JSRPC 0x4eba0000 /* jsr PC@( ) */ #define LONGBIT 0x00010000 #define BSR 0x61000000 /* bsr x */ -#ifdef mc68020 #define BSRL 0x61ff0000 /* bsrl x */ -#endif /* mc68020 */ #define BYTE3 0x0000ff00 #define LOBYTE 0x000000ff #define ADQMSK 0xf1ff0000 @@ -184,7 +184,7 @@ struct nlist * funcsym = 0; static int nextframe(sp, kerneltrace) - register struct stackpos *sp; + struct stackpos *sp; int kerneltrace; { int i; @@ -260,7 +260,7 @@ nextframe(sp, kerneltrace) static void findentry(sp) - register struct stackpos *sp; + struct stackpos *sp; { /* * Set the k_nargs and k_entry fields in the stackpos structure. This @@ -303,12 +303,10 @@ findentry(sp) /* longword offset here */ sp->k_caller = addr - 6; sp->k_entry = nextword; -#ifdef mc68020 } else if ((instruc & HIWORD) == BSRL) { /* longword self-relative offset */ sp->k_caller = addr - 6; sp->k_entry = nextword + (addr - 4); -#endif /* mc68020 */ } else { instruc = nextword; if ((instruc & HIWORD) == JSR) { @@ -405,10 +403,10 @@ findentry(sp) */ static void findregs(sp, addr) - register struct stackpos *sp; - register db_addr_t addr; + struct stackpos *sp; + db_addr_t addr; { - register long instruc, val, i; + long instruc, val, i; int regp; regp = 0; @@ -480,10 +478,11 @@ db_stack_trace_cmd(addr, have_addr, count, modif) char * name; struct stackpos pos; boolean_t kernel_only = TRUE; + int fault_pc = 0; { - register char *cp = modif; - register char c; + char *cp = modif; + char c; while ((c = *cp++) != 0) if (c == 'u') @@ -501,8 +500,8 @@ db_stack_trace_cmd(addr, have_addr, count, modif) /* * Only have user register state. */ - register pcb_t t_pcb; - register db_regs_t *user_regs; + pcb_t t_pcb; + db_regs_t *user_regs; t_pcb = (pcb_t) get(&th->pcb, 0); user_regs = (db_regs_t *) @@ -540,6 +539,46 @@ db_stack_trace_cmd(addr, have_addr, count, modif) name = "?"; } } + + /* + * Since faultstkadj doesn't set up a valid stack frame, + * we would assume it was the source of the fault. To + * get around this we peek at the fourth argument of + * "trap()" (the stack frame at the time of the fault) + * to determine the _real_ value of PC when things wen + * wrong. + * + * NOTE: If the argument list for 'trap()' ever changes, + * we lose. + */ + if (strcmp("_trap", name) == 0) { + int tfp; + + /* Point to 'trap()'s 4th argument (frame structure) */ + tfp = pos.k_fp + FR_SAVFP + 4 + (4 * 4); + + /* Determine if fault was from kernel or user mode */ + regp = tfp + offsetof(struct frame, f_sr); + if (!USERMODE(get16(regp, DSP))) { + /* + * Definitely a kernel mode fault, + * so get the PC at the time of the fault. + */ + regp = tfp + offsetof(struct frame, f_pc); + fault_pc = get(regp, DSP); + } + } else + if (fault_pc) { + if (strcmp("faultstkadj", name) == 0) { + db_find_sym_and_offset(fault_pc, &name, &val); + if (name == 0) { + val = MAXINT; + name = "?"; + } + } + fault_pc = 0; + } + db_printf("%s", name); if (pos.k_entry != MAXINT && name) { char * entry_name; |