Fix backtrace for MIPS64:

- Properly print 64-bit addresses
    - Get whole 64 bits of address using kdbpeekd
    - Make check for kernel address compatible with MIPS64
This commit is contained in:
Oleksandr Tymoshenko 2012-01-13 23:31:36 +00:00
parent 3ab1c5a619
commit 547cfad16d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=230094
3 changed files with 38 additions and 15 deletions

View File

@ -93,6 +93,7 @@ db_addr_t next_instr_address(db_addr_t, boolean_t);
int db_inst_type(int);
db_addr_t branch_taken(int inst, db_addr_t pc);
void stacktrace_subr(register_t pc, register_t sp, register_t ra, int (*)(const char *, ...));
int kdbpeek(int *);
int32_t kdbpeek(int *);
int64_t kdbpeekd(int *);
#endif /* !_MIPS_DB_MACHDEP_H_ */

View File

@ -49,10 +49,13 @@ extern char edata[];
*/
#define MIPS_END_OF_FUNCTION(ins) ((ins) == 0x03e00008)
/*
* kdbpeekD(addr) - skip one word starting at 'addr', then read the second word
*/
#define kdbpeekD(addr) kdbpeek(((int *)(addr)) + 1)
#if defined(__mips_n64)
# define MIPS_IS_VALID_KERNELADDR(reg) ((((reg) & 3) == 0) && \
((vm_offset_t)(reg) >= MIPS_XKPHYS_START))
#else
# define MIPS_IS_VALID_KERNELADDR(reg) ((((reg) & 3) == 0) && \
((vm_offset_t)(reg) >= MIPS_KSEG0_START))
#endif
/*
* Functions ``special'' enough to print by name
@ -141,8 +144,8 @@ stacktrace_subr(register_t pc, register_t sp, register_t ra,
}
/* check for bad SP: could foul up next frame */
/*XXX MIPS64 bad: this hard-coded SP is lame */
if (sp & 3 || (uintptr_t)sp < 0x80000000u) {
(*printfn) ("SP 0x%x: not in kernel\n", sp);
if (!MIPS_IS_VALID_KERNELADDR(sp)) {
(*printfn) ("SP 0x%jx: not in kernel\n", sp);
ra = 0;
subr = 0;
goto done;
@ -182,8 +185,8 @@ stacktrace_subr(register_t pc, register_t sp, register_t ra,
}
/* check for bad PC */
/*XXX MIPS64 bad: These hard coded constants are lame */
if (pc & 3 || pc < (uintptr_t)0x80000000) {
(*printfn) ("PC 0x%x: not in kernel\n", pc);
if (!MIPS_IS_VALID_KERNELADDR(pc)) {
(*printfn) ("PC 0x%jx: not in kernel\n", pc);
ra = 0;
goto done;
}
@ -304,27 +307,27 @@ stacktrace_subr(register_t pc, register_t sp, register_t ra,
mask |= (1 << i.IType.rt);
switch (i.IType.rt) {
case 4:/* a0 */
args[0] = kdbpeekD((int *)(sp + (short)i.IType.imm));
args[0] = kdbpeekd((int *)(sp + (short)i.IType.imm));
valid_args[0] = 1;
break;
case 5:/* a1 */
args[1] = kdbpeekD((int *)(sp + (short)i.IType.imm));
args[1] = kdbpeekd((int *)(sp + (short)i.IType.imm));
valid_args[1] = 1;
break;
case 6:/* a2 */
args[2] = kdbpeekD((int *)(sp + (short)i.IType.imm));
args[2] = kdbpeekd((int *)(sp + (short)i.IType.imm));
valid_args[2] = 1;
break;
case 7:/* a3 */
args[3] = kdbpeekD((int *)(sp + (short)i.IType.imm));
args[3] = kdbpeekd((int *)(sp + (short)i.IType.imm));
valid_args[3] = 1;
break;
case 31: /* ra */
ra = kdbpeekD((int *)(sp + (short)i.IType.imm));
ra = kdbpeekd((int *)(sp + (short)i.IType.imm));
}
break;
@ -350,7 +353,7 @@ stacktrace_subr(register_t pc, register_t sp, register_t ra,
(*printfn)("?");
}
(*printfn) (") ra %x sp %x sz %d\n", ra, sp, stksize);
(*printfn) (") ra %jx sp %jx sz %d\n", ra, sp, stksize);
if (ra) {
if (pc == ra && stksize == 0)

View File

@ -1340,6 +1340,25 @@ LEAF(kdbpeek)
PTR_S zero, U_PCB_ONFAULT(t1)
END(kdbpeek)
LEAF(kdbpeekd)
PTR_LA v1, ddberr
and v0, a0, 3 # unaligned ?
GET_CPU_PCPU(t1)
PTR_L t1, PC_CURPCB(t1)
bne v0, zero, 1f
PTR_S v1, U_PCB_ONFAULT(t1)
ld v0, (a0)
jr ra
PTR_S zero, U_PCB_ONFAULT(t1)
1:
REG_LHI v0, 0(a0)
REG_LLO v0, 7(a0)
jr ra
PTR_S zero, U_PCB_ONFAULT(t1)
END(kdbpeekd)
ddberr:
jr ra
nop