diff --git a/arch/arm64/core/fatal.c b/arch/arm64/core/fatal.c index 0dbc13228de..f921c4ccf5a 100644 --- a/arch/arm64/core/fatal.c +++ b/arch/arm64/core/fatal.c @@ -195,7 +195,7 @@ static void esf_dump(const z_arch_esf_t *esf) LOG_ERR("x18: 0x%016llx lr: 0x%016llx", esf->x18, esf->lr); } -#ifdef CONFIG_ARM64_EXCEPTION_STACK_TRACE +#ifdef CONFIG_EXCEPTION_STACK_TRACE static void esf_unwind(const z_arch_esf_t *esf) { /* @@ -363,9 +363,9 @@ void z_arm64_fatal_error(unsigned int reason, z_arch_esf_t *esf) esf_dump(esf); } -#ifdef CONFIG_ARM64_EXCEPTION_STACK_TRACE +#ifdef CONFIG_EXCEPTION_STACK_TRACE esf_unwind(esf); -#endif /* CONFIG_ARM64_EXCEPTION_STACK_TRACE */ +#endif /* CONFIG_EXCEPTION_STACK_TRACE */ #endif /* CONFIG_EXCEPTION_DEBUG */ z_fatal_error(reason, esf); diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 4d964905e42..0993189b99c 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -41,7 +41,6 @@ config RISCV_ALWAYS_SWITCH_THROUGH_ECALL config RISCV_EXCEPTION_STACK_TRACE bool default y - depends on EXCEPTION_STACK_TRACE imply THREAD_STACK_INFO help Internal config to enable runtime stack traces on fatal exceptions. diff --git a/arch/riscv/core/CMakeLists.txt b/arch/riscv/core/CMakeLists.txt index 7ffcffd65c8..07eae41a6e0 100644 --- a/arch/riscv/core/CMakeLists.txt +++ b/arch/riscv/core/CMakeLists.txt @@ -25,5 +25,5 @@ zephyr_library_sources_ifdef(CONFIG_RISCV_PMP pmp.c pmp.S) zephyr_library_sources_ifdef(CONFIG_THREAD_LOCAL_STORAGE tls.c) zephyr_library_sources_ifdef(CONFIG_USERSPACE userspace.S) zephyr_library_sources_ifdef(CONFIG_SEMIHOST semihost.c) -zephyr_library_sources_ifdef(CONFIG_RISCV_EXCEPTION_STACK_TRACE stacktrace.c) +zephyr_library_sources_ifdef(CONFIG_EXCEPTION_STACK_TRACE stacktrace.c) zephyr_linker_sources(ROM_START SORT_KEY 0x0vectors vector_table.ld) diff --git a/arch/riscv/core/fatal.c b/arch/riscv/core/fatal.c index b8736f36144..bd4ed3dca36 100644 --- a/arch/riscv/core/fatal.c +++ b/arch/riscv/core/fatal.c @@ -107,7 +107,7 @@ FUNC_NORETURN void z_riscv_fatal_error_csf(unsigned int reason, const z_arch_esf LOG_ERR(""); } - if (IS_ENABLED(CONFIG_RISCV_EXCEPTION_STACK_TRACE) && (esf != NULL)) { + if (IS_ENABLED(CONFIG_EXCEPTION_STACK_TRACE) && (esf != NULL)) { z_riscv_unwind_stack(esf); } diff --git a/arch/x86/core/Kconfig.ia32 b/arch/x86/core/Kconfig.ia32 index 770f6ff4d6d..2e2cf1d0fc2 100644 --- a/arch/x86/core/Kconfig.ia32 +++ b/arch/x86/core/Kconfig.ia32 @@ -167,7 +167,6 @@ config X86_EXCEPTION_STACK_TRACE bool default y select DEBUG_INFO - depends on EXCEPTION_STACK_TRACE depends on !OMIT_FRAME_POINTER help Internal config to enable runtime stack traces on fatal exceptions. diff --git a/arch/x86/core/Kconfig.intel64 b/arch/x86/core/Kconfig.intel64 index 36e7110f79a..a287de6eb09 100644 --- a/arch/x86/core/Kconfig.intel64 +++ b/arch/x86/core/Kconfig.intel64 @@ -33,7 +33,6 @@ config X86_EXCEPTION_STACK_TRACE bool default y select DEBUG_INFO - depends on EXCEPTION_STACK_TRACE depends on !OMIT_FRAME_POINTER depends on NO_OPTIMIZATIONS help diff --git a/arch/x86/core/fatal.c b/arch/x86/core/fatal.c index a2aea657498..5db20eb5deb 100644 --- a/arch/x86/core/fatal.c +++ b/arch/x86/core/fatal.c @@ -131,7 +131,7 @@ static inline uintptr_t esf_get_code(const z_arch_esf_t *esf) #endif } -#if defined(CONFIG_X86_EXCEPTION_STACK_TRACE) +#if defined(CONFIG_EXCEPTION_STACK_TRACE) struct stack_frame { uintptr_t next; uintptr_t ret_addr; @@ -186,7 +186,7 @@ static void unwind_stack(uintptr_t base_ptr, uint16_t cs) base_ptr = frame->next; } } -#endif /* CONFIG_X86_EXCEPTION_STACK_TRACE */ +#endif /* CONFIG_EXCEPTION_STACK_TRACE */ static inline uintptr_t get_cr3(const z_arch_esf_t *esf) { @@ -226,11 +226,11 @@ static void dump_regs(const z_arch_esf_t *esf) LOG_ERR("RSP: 0x%016lx RFLAGS: 0x%016lx CS: 0x%04lx CR3: 0x%016lx", esf->rsp, esf->rflags, esf->cs & 0xFFFFU, get_cr3(esf)); -#ifdef CONFIG_X86_EXCEPTION_STACK_TRACE +#ifdef CONFIG_EXCEPTION_STACK_TRACE LOG_ERR("call trace:"); #endif LOG_ERR("RIP: 0x%016lx", esf->rip); -#ifdef CONFIG_X86_EXCEPTION_STACK_TRACE +#ifdef CONFIG_EXCEPTION_STACK_TRACE unwind_stack(esf->rbp, esf->cs); #endif } @@ -245,11 +245,11 @@ static void dump_regs(const z_arch_esf_t *esf) LOG_ERR("EFLAGS: 0x%08x CS: 0x%04x CR3: 0x%08lx", esf->eflags, esf->cs & 0xFFFFU, get_cr3(esf)); -#ifdef CONFIG_X86_EXCEPTION_STACK_TRACE +#ifdef CONFIG_EXCEPTION_STACK_TRACE LOG_ERR("call trace:"); #endif LOG_ERR("EIP: 0x%08x", esf->eip); -#ifdef CONFIG_X86_EXCEPTION_STACK_TRACE +#ifdef CONFIG_EXCEPTION_STACK_TRACE unwind_stack(esf->ebp, esf->cs); #endif } diff --git a/subsys/debug/Kconfig b/subsys/debug/Kconfig index 4ba285b613c..dc9da0efc30 100644 --- a/subsys/debug/Kconfig +++ b/subsys/debug/Kconfig @@ -382,6 +382,9 @@ config SYMTAB config EXCEPTION_STACK_TRACE bool "Attempt to print stack traces upon exceptions" default y + depends on (X86_EXCEPTION_STACK_TRACE || \ + ARM64_EXCEPTION_STACK_TRACE || \ + RISCV_EXCEPTION_STACK_TRACE) help If the architecture fatal handling code supports it, attempt to print a stack trace of function memory addresses when an