Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RISCV64: Fix 'bt' output when no ra on the stack top
Same as the Linux commit f766f77a74f5 ("riscv/stacktrace: Fix stack output without ra on the stack top"). When a function doesn't have a callee, then it will not push ra into the stack, such as lkdtm functions, so correct the FP of the second frame and use pt_regs to get the right PC of the second frame. Before this patch, the `bt -f` outputs only the first frame with the wrong PC and FP of next frame: ``` crash> bt -f PID: 1 TASK: ff600000000e0000 CPU: 1 COMMAND: "sh" #0 [ff20000000013cf0] lkdtm_EXCEPTION at ffffffff805303c0 [PC: ffffffff805303c0 RA: ff20000000013d10 SP: ff20000000013cf0 SIZE: 16] <- wrong next PC ff20000000013cf0: 0000000000000001 ff20000000013d10 <- next FP ff20000000013d00: ff20000000013d40 crash> ``` After this patch, the `bt` outputs the full frames: ``` crash> bt PID: 1 TASK: ff600000000e0000 CPU: 1 COMMAND: "sh" #0 [ff20000000013cf0] lkdtm_EXCEPTION at ffffffff805303c0 crash-utility#1 [ff20000000013d00] lkdtm_do_action at ffffffff8052fe36 crash-utility#2 [ff20000000013d10] direct_entry at ffffffff80530018 crash-utility#3 [ff20000000013d40] full_proxy_write at ffffffff80305044 crash-utility#4 [ff20000000013d80] vfs_write at ffffffff801b68b4 crash-utility#5 [ff20000000013e30] ksys_write at ffffffff801b6c4a crash-utility#6 [ff20000000013e80] __riscv_sys_write at ffffffff801b6cc4 crash-utility#7 [ff20000000013e90] do_trap_ecall_u at ffffffff80836798 crash> ``` Acked-by: Kazuhito Hagio <[email protected]> Signed-off-by: Song Shuai <[email protected]>
- Loading branch information