From df0d8b4230394a04b97482a9ea546e26e46b72a8 Mon Sep 17 00:00:00 2001 From: geniusgogo <2041245+geniusgogo@users.noreply.github.com> Date: Wed, 8 Nov 2023 19:11:10 +0800 Subject: fix aarch64 backtrace print --- libcpu/aarch64/common/trap.c | 50 ++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) (limited to 'libcpu') diff --git a/libcpu/aarch64/common/trap.c b/libcpu/aarch64/common/trap.c index 325fe1e8ba..d408b64163 100644 --- a/libcpu/aarch64/common/trap.c +++ b/libcpu/aarch64/common/trap.c @@ -34,52 +34,29 @@ extern long list_thread(void); static void _check_fault(struct rt_hw_exp_stack *regs, uint32_t pc_adj, char *info) { - uint32_t mode = regs->cpsr; + uint32_t is_user_fault; + rt_thread_t th; - if ((mode & 0x1f) == 0x00) + is_user_fault = !(regs->cpsr & 0x1f); + if (is_user_fault) { rt_kprintf("%s! pc = 0x%x\n", info, regs->pc - pc_adj); + } - /* user stack backtrace */ - #ifdef RT_USING_LWP - { - rt_thread_t th; - - th = rt_thread_self(); - if (th && th->lwp) - { - arch_backtrace_uthread(th); - } - } - #endif + /* user stack backtrace */ + th = rt_thread_self(); + if (th && th->lwp) + { + arch_backtrace_uthread(th); + } + if (is_user_fault) + { #ifdef LWP_USING_CORE_DUMP lwp_core_dump(regs, pc_adj); #endif sys_exit_group(-1); } - else - { - /* user stack backtrace */ - #ifdef RT_USING_LWP - { - rt_thread_t th; - - th = rt_thread_self(); - if (th && th->lwp) - { - arch_backtrace_uthread(th); - } - } - #endif - - /* kernel stack backtrace */ - struct rt_hw_backtrace_frame frame = { - .fp = regs->x29, - .pc = regs->pc - }; - rt_backtrace_frame(&frame); - } } rt_inline int _get_type(unsigned long esr) @@ -383,7 +360,6 @@ void rt_hw_trap_exception(struct rt_hw_exp_stack *regs) rt_hw_cpu_shutdown(); } - void rt_hw_trap_serror(struct rt_hw_exp_stack *regs) { rt_kprintf("SError\n"); -- cgit v1.3.1