mips/ddb: fix MIPS backtrace truncation and MIPS32 register printing.
- Cast 32-bit register values to uintmax_t for use with %jx. - Add special-case return address handling for MipsKernGenException to avoid early termination of stack walking in the exception handler stack frame. Submitted by: Michael Zhilin <mizhka@gmail.com> Reviewed by: ray Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D6907
This commit is contained in:
parent
692f593c23
commit
494fa6b933
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=302603
@ -144,6 +144,7 @@ stacktrace_subr(register_t pc, register_t sp, register_t ra,
|
||||
unsigned instr, mask;
|
||||
unsigned int frames = 0;
|
||||
int more, stksize, j;
|
||||
register_t next_ra;
|
||||
|
||||
/* Jump here when done with a frame, to start a new one */
|
||||
loop:
|
||||
@ -155,6 +156,7 @@ stacktrace_subr(register_t pc, register_t sp, register_t ra,
|
||||
valid_args[1] = 0;
|
||||
valid_args[2] = 0;
|
||||
valid_args[3] = 0;
|
||||
next_ra = 0;
|
||||
/* Jump here after a nonstandard (interrupt handler) frame */
|
||||
stksize = 0;
|
||||
subr = 0;
|
||||
@ -288,9 +290,17 @@ stacktrace_subr(register_t pc, register_t sp, register_t ra,
|
||||
/* look for saved registers on the stack */
|
||||
if (i.IType.rs != 29)
|
||||
break;
|
||||
/* only restore the first one */
|
||||
if (mask & (1 << i.IType.rt))
|
||||
/*
|
||||
* only restore the first one except RA for
|
||||
* MipsKernGenException case
|
||||
*/
|
||||
if (mask & (1 << i.IType.rt)) {
|
||||
if (subr == (uintptr_t)MipsKernGenException &&
|
||||
i.IType.rt == 31)
|
||||
next_ra = kdbpeek((int *)(sp +
|
||||
(short)i.IType.imm));
|
||||
break;
|
||||
}
|
||||
mask |= (1 << i.IType.rt);
|
||||
switch (i.IType.rt) {
|
||||
case 4:/* a0 */
|
||||
@ -374,7 +384,10 @@ stacktrace_subr(register_t pc, register_t sp, register_t ra,
|
||||
(*printfn)("?");
|
||||
}
|
||||
|
||||
(*printfn) (") ra %jx sp %jx sz %d\n", ra, sp, stksize);
|
||||
(*printfn) (") ra %jx sp %jx sz %d\n",
|
||||
(uintmax_t)(u_register_t) ra,
|
||||
(uintmax_t)(u_register_t) sp,
|
||||
stksize);
|
||||
|
||||
if (ra) {
|
||||
if (pc == ra && stksize == 0)
|
||||
@ -382,7 +395,7 @@ stacktrace_subr(register_t pc, register_t sp, register_t ra,
|
||||
else {
|
||||
pc = ra;
|
||||
sp += stksize;
|
||||
ra = 0;
|
||||
ra = next_ra;
|
||||
goto loop;
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user