xiaoxiang781216 commented on code in PR #7875: URL: https://github.com/apache/nuttx/pull/7875#discussion_r1050389062
########## arch/arm/src/nrf52/nrf52_sdc.c: ########## @@ -238,7 +238,7 @@ static int bt_hci_send(struct bt_driver_s *btdev, static void sdc_fault_handler(const char *file, const uint32_t line) { _alert("SoftDevice Controller Fault\n"); - up_assert(file, line); + up_assert(); Review Comment: let's call _assert instead ########## arch/ceva/src/common/ceva_assert.c: ########## @@ -35,80 +35,19 @@ * Private Data ****************************************************************************/ -#ifdef CONFIG_ARCH_STACKDUMP static uint32_t s_last_regs[XCPTCONTEXT_REGS]; -#endif /**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_stackdump - ****************************************************************************/ - -#ifdef CONFIG_ARCH_STACKDUMP -static void up_stackdump(uint32_t sp, uint32_t stack_base) -{ - uint32_t stack; - - for (stack = sp; stack < stack_base; stack += 8 * sizeof(uint32_t)) - { - uint32_t *ptr = (uint32_t *)stack; - _alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n", - stack, ptr[0], ptr[1], ptr[2], ptr[3], - ptr[4], ptr[5], ptr[6], ptr[7]); - } -} -#else -# define up_stackdump(sp, stack_base) -#endif - -/**************************************************************************** - * Name: up_taskdump + * Public Functions ****************************************************************************/ -#ifdef CONFIG_STACK_COLORATION -static void up_taskdump(struct tcb_s *tcb, void *arg) -{ - /* Dump interesting properties of this task */ - -#if CONFIG_TASK_NAME_SIZE > 0 - _alert("%s: PID=%d Stack Used=%lu of %lu\n", - tcb->name, tcb->pid, up_check_tcbstack(tcb), - tcb->adj_stack_size); -#else - _alert("PID: %d Stack Used=%lu of %lu\n", - tcb->pid, up_check_tcbstack(tcb), - tcb->adj_stack_size); -#endif -} -#endif - /**************************************************************************** - * Name: up_showtasks - ****************************************************************************/ - -#ifdef CONFIG_STACK_COLORATION -static inline void up_showtasks(void) -{ - /* Dump interesting properties of each task in the crash environment */ - - sched_foreach(up_taskdump, NULL); -} -#else -# define up_showtasks() -#endif - -/**************************************************************************** - * Name: up_registerdump + * Name: up_assert ****************************************************************************/ -#ifdef CONFIG_ARCH_STACKDUMP -static inline void up_registerdump(void) +void up_assert(const uint8_t *filename, int lineno) Review Comment: ```suggestion void up_assert(void) ``` ########## sched/misc/assert.c: ########## @@ -174,7 +478,20 @@ void _assert(FAR const char *filename, int linenum) syslog_flush(); - up_assert(filename, linenum); + /* Show back trace */ + +#ifdef CONFIG_SCHED_BACKTRACE + sched_dumpstack(running_task()->pid); +#endif + + up_assert(); + +#ifdef CONFIG_ARCH_STACKDUMP + showstacks(); +#endif + + showtasks(); Review Comment: dup with line 490 ########## arch/xtensa/src/common/xtensa_assert.c: ########## @@ -208,6 +222,6 @@ void xtensa_user_panic(int exccause, uint32_t *regs) _alert("User Exception: EXCCAUSE=%04x\n", exccause); #endif - xtensa_assert(); /* Should not return */ + xtensa_registerdump(regs); /* Should not return */ Review Comment: _assert ########## arch/arm/src/nrf52/nrf52_sdc.c: ########## @@ -248,7 +248,7 @@ static void sdc_fault_handler(const char *file, const uint32_t line) static void mpsl_assert_handler(const char *const file, const uint32_t line) { _alert("MPSL assertion failed\n"); - up_assert(file, line); + up_assert(); Review Comment: let's call _assert instead ########## arch/z16/src/z16f/Make.defs: ########## @@ -22,7 +22,7 @@ HEAD_SSRC = z16f_head.S CMN_CSRCS = z16_allocateheap.c z16_initialize.c z16_schedulesigaction.c CMN_CSRCS += z16_assert.c z16_initialstate.c z16_sigdeliver.c -CMN_CSRCS += z16_stackdump.c z16_copystate.c Review Comment: merge to previous line ########## arch/xtensa/src/common/xtensa_assert.c: ########## @@ -105,7 +119,7 @@ void xtensa_panic(int xptcode, uint32_t *regs) _alert("Unhandled Exception %d\n", xptcode); #endif - xtensa_assert(); /* Should not return */ + xtensa_registerdump(regs); /* Should not return */ Review Comment: _assert ########## arch/ceva/src/common/ceva_registerdump.c: ########## @@ -24,60 +24,42 @@ #include <nuttx/config.h> -#include <stdint.h> #include <debug.h> -#include "sched/sched.h" -#include "z80_internal.h" +#include <nuttx/arch.h> -#ifdef CONFIG_ARCH_STACKDUMP +#include "sched/sched.h" +#include "ceva_internal.h" /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: z80_stackdump + * Name: up_getusrsp ****************************************************************************/ -void z80_stackdump(void) +#if CONFIG_ARCH_INTERRUPTSTACK > 3 +uintptr_t up_getusrsp(void) { - FAR struct tcb_s *rtcb = running_task(); - uintptr_t sp = up_getsp(); - uintptr_t stack_base = (uintptr_t)rtcb->stack_base_ptr; - uintptr_t stack_size = (uintptr_t)rtcb->adj_stack_size; - uintptr_t stack; - uintptr_t stack_top; - - _alert("stack_base: %06x\n", stack_base); - _alert("stack_size: %06x\n", stack_size); - _alert("sp: %06x\n", sp); - - if (sp >= stack_base && sp < stack_base + stack_size) - { - stack = sp; - } - else - { - _alert("ERROR: Stack pointer is not within allocated stack\n"); - stack = stack_base; - } + return CURRENT_REGS; Review Comment: not fix yet ########## arch/arm64/src/common/arm64_assert.c: ########## @@ -39,317 +39,48 @@ #endif /**************************************************************************** - * Name: arm_registerdump - ****************************************************************************/ - -static void arm64_registerdump(struct regs_context * regs) -{ - _alert("stack = %p\n", regs); - _alert("x0: 0x%-16"PRIx64" x1: 0x%"PRIx64"\n", - regs->regs[REG_X0], regs->regs[REG_X1]); - _alert("x2: 0x%-16"PRIx64" x3: 0x%"PRIx64"\n", - regs->regs[REG_X2], regs->regs[REG_X3]); - _alert("x4: 0x%-16"PRIx64" x5: 0x%"PRIx64"\n", - regs->regs[REG_X4], regs->regs[REG_X5]); - _alert("x6: 0x%-16"PRIx64" x7: 0x%"PRIx64"\n", - regs->regs[REG_X6], regs->regs[REG_X7]); - _alert("x8: 0x%-16"PRIx64" x9: 0x%"PRIx64"\n", - regs->regs[REG_X8], regs->regs[REG_X9]); - _alert("x10: 0x%-16"PRIx64" x11: 0x%"PRIx64"\n", - regs->regs[REG_X10], regs->regs[REG_X11]); - _alert("x12: 0x%-16"PRIx64" x13: 0x%"PRIx64"\n", - regs->regs[REG_X12], regs->regs[REG_X13]); - _alert("x14: 0x%-16"PRIx64" x15: 0x%"PRIx64"\n", - regs->regs[REG_X14], regs->regs[REG_X15]); - _alert("x16: 0x%-16"PRIx64" x17: 0x%"PRIx64"\n", - regs->regs[REG_X16], regs->regs[REG_X17]); - _alert("x18: 0x%-16"PRIx64" x19: 0x%"PRIx64"\n", - regs->regs[REG_X18], regs->regs[REG_X19]); - _alert("x20: 0x%-16"PRIx64" x21: 0x%"PRIx64"\n", - regs->regs[REG_X20], regs->regs[REG_X21]); - _alert("x22: 0x%-16"PRIx64" x23: 0x%"PRIx64"\n", - regs->regs[REG_X22], regs->regs[REG_X23]); - _alert("x24: 0x%-16"PRIx64" x25: 0x%"PRIx64"\n", - regs->regs[REG_X24], regs->regs[REG_X25]); - _alert("x26: 0x%-16"PRIx64" x27: 0x%"PRIx64"\n", - regs->regs[REG_X26], regs->regs[REG_X27]); - _alert("x28: 0x%-16"PRIx64" x29: 0x%"PRIx64"\n", - regs->regs[REG_X28], regs->regs[REG_X29]); - _alert("x30: 0x%-16"PRIx64"\n", regs->regs[REG_X30]); - - _alert("\n"); - _alert("STATUS Registers:\n"); - _alert("SPSR: 0x%-16"PRIx64"\n", regs->spsr); - _alert("ELR: 0x%-16"PRIx64"\n", regs->elr); - _alert("SP_EL0: 0x%-16"PRIx64"\n", regs->sp_el0); - _alert("SP_ELX: 0x%-16"PRIx64"\n", regs->sp_elx); - _alert("TPIDR_EL0: 0x%-16"PRIx64"\n", regs->tpidr_el0); - _alert("TPIDR_EL1: 0x%-16"PRIx64"\n", regs->tpidr_el1); - _alert("EXE_DEPTH: 0x%-16"PRIx64"\n", regs->exe_depth); -} - -#ifdef CONFIG_ARCH_STACKDUMP - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_stackdump + * Public Functions ****************************************************************************/ -static void arm64_stackdump(uint64_t sp, uint64_t stack_top) -{ - uint64_t stack; - - for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 64) - { - uint64_t *ptr = (uint64_t *)stack; - _alert("%08" PRIx64 ": %08" PRIx64 " %08" PRIx64 " %08" PRIx64 - " %08" PRIx64 " %08" PRIx64 " %08" PRIx64 " %08" PRIx64 - " %08" PRIx64 "\n", - stack, ptr[0], ptr[1], ptr[2], ptr[3], - ptr[4], ptr[5], ptr[6], ptr[7]); - } -} - /**************************************************************************** - * Name: arm_dump_task + * Name: arm64_dump_fatal ****************************************************************************/ -static void arm64_dump_task(struct tcb_s *tcb, void *arg) +void arm64_dump_fatal(struct regs_context * regs) Review Comment: ```suggestion void arm64_dump_fatal(struct regs_context *regs) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org