debug: EXCEPTION_STACK_TRACE should depend on arch Kconfigs
Fix the dependencies of `CONFIG_EXCEPTION_STACK_TRACE`: - Architecture-specific Kconfig, i.e. `X86_EXCEPTION_STACK_TRACE`, will be enabled automatically when all the dependencies are met. - `EXCEPTION_STACK_TRACE` depends on architecture-specific Kconfig to be enabled. - The stack trace implementations should be compiled only if user enables `CONFIG_EXCEPTION_STACK_TRACE`. Signed-off-by: Yong Cong Sin <ycsin@meta.com>
This commit is contained in:
parent
190777dccf
commit
02770ad963
8 changed files with 14 additions and 14 deletions
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue