diff options
| author | Shell <[email protected]> | 2023-10-21 20:14:45 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-21 20:14:45 +0800 |
| commit | 70a8d1d4656bc678ddada5e56263c9cb4423a623 (patch) | |
| tree | b81b97a4f4cf33df2b1a02742e80de218da51333 /libcpu/risc-v/virt64/trap.c | |
| parent | 90c7089d47755a3edaf9008282225c5019fa188c (diff) | |
[kservice] improve backtrace service in kernel (#8144)
Signed-off-by: Shell <[email protected]>
Diffstat (limited to 'libcpu/risc-v/virt64/trap.c')
| -rw-r--r-- | libcpu/risc-v/virt64/trap.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/libcpu/risc-v/virt64/trap.c b/libcpu/risc-v/virt64/trap.c index 5a7d2bc4c5..6af0c0097d 100644 --- a/libcpu/risc-v/virt64/trap.c +++ b/libcpu/risc-v/virt64/trap.c @@ -149,6 +149,7 @@ static const char *get_exception_msg(int id) } #ifdef RT_USING_SMART +#include "lwp.h" void handle_user(rt_size_t scause, rt_size_t stval, rt_size_t sepc, struct rt_hw_stack_frame *sp) { rt_size_t id = __MASKVALUE(scause, __MASK(63UL)); @@ -221,9 +222,15 @@ void handle_user(rt_size_t scause, rt_size_t stval, rt_size_t sepc, struct rt_hw LOG_E("scause:0x%p,stval:0x%p,sepc:0x%p\n", scause, stval, sepc); dump_regs(sp); - rt_hw_backtrace((uint32_t *)sp->s0_fp, sepc); + rt_thread_t cur_thr = rt_thread_self(); + struct rt_hw_backtrace_frame frame = { + .fp = sp->s0_fp, + .pc = sepc + }; + rt_kprintf("fp = %p\n", frame.fp); + lwp_backtrace_frame(cur_thr, &frame); - LOG_E("User Fault, killing thread: %s", rt_thread_self()->parent.name); + LOG_E("User Fault, killing thread: %s", cur_thr->parent.name); EXIT_TRAP; sys_exit_group(-1); @@ -354,10 +361,14 @@ void handle_trap(rt_size_t scause, rt_size_t stval, rt_size_t sepc, struct rt_hw extern struct rt_thread *rt_current_thread; rt_kprintf("--------------Backtrace--------------\n"); - rt_hw_backtrace((uint32_t *)sp->s0_fp, sepc); + struct rt_hw_backtrace_frame frame = { + .fp = sp->s0_fp, + .pc = sepc + }; + rt_kprintf("fp = %p", frame.fp); + rt_backtrace_frame(&frame); - while (1) - ; + RT_ASSERT(0); } _exit: EXIT_TRAP; |
