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);
|
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)
|
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);
|
esf_dump(esf);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ARM64_EXCEPTION_STACK_TRACE
|
#ifdef CONFIG_EXCEPTION_STACK_TRACE
|
||||||
esf_unwind(esf);
|
esf_unwind(esf);
|
||||||
#endif /* CONFIG_ARM64_EXCEPTION_STACK_TRACE */
|
#endif /* CONFIG_EXCEPTION_STACK_TRACE */
|
||||||
#endif /* CONFIG_EXCEPTION_DEBUG */
|
#endif /* CONFIG_EXCEPTION_DEBUG */
|
||||||
|
|
||||||
z_fatal_error(reason, esf);
|
z_fatal_error(reason, esf);
|
||||||
|
|
|
@ -41,7 +41,6 @@ config RISCV_ALWAYS_SWITCH_THROUGH_ECALL
|
||||||
config RISCV_EXCEPTION_STACK_TRACE
|
config RISCV_EXCEPTION_STACK_TRACE
|
||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
depends on EXCEPTION_STACK_TRACE
|
|
||||||
imply THREAD_STACK_INFO
|
imply THREAD_STACK_INFO
|
||||||
help
|
help
|
||||||
Internal config to enable runtime stack traces on fatal exceptions.
|
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_THREAD_LOCAL_STORAGE tls.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_USERSPACE userspace.S)
|
zephyr_library_sources_ifdef(CONFIG_USERSPACE userspace.S)
|
||||||
zephyr_library_sources_ifdef(CONFIG_SEMIHOST semihost.c)
|
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)
|
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("");
|
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);
|
z_riscv_unwind_stack(esf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,6 @@ config X86_EXCEPTION_STACK_TRACE
|
||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
select DEBUG_INFO
|
select DEBUG_INFO
|
||||||
depends on EXCEPTION_STACK_TRACE
|
|
||||||
depends on !OMIT_FRAME_POINTER
|
depends on !OMIT_FRAME_POINTER
|
||||||
help
|
help
|
||||||
Internal config to enable runtime stack traces on fatal exceptions.
|
Internal config to enable runtime stack traces on fatal exceptions.
|
||||||
|
|
|
@ -33,7 +33,6 @@ config X86_EXCEPTION_STACK_TRACE
|
||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
select DEBUG_INFO
|
select DEBUG_INFO
|
||||||
depends on EXCEPTION_STACK_TRACE
|
|
||||||
depends on !OMIT_FRAME_POINTER
|
depends on !OMIT_FRAME_POINTER
|
||||||
depends on NO_OPTIMIZATIONS
|
depends on NO_OPTIMIZATIONS
|
||||||
help
|
help
|
||||||
|
|
|
@ -131,7 +131,7 @@ static inline uintptr_t esf_get_code(const z_arch_esf_t *esf)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_X86_EXCEPTION_STACK_TRACE)
|
#if defined(CONFIG_EXCEPTION_STACK_TRACE)
|
||||||
struct stack_frame {
|
struct stack_frame {
|
||||||
uintptr_t next;
|
uintptr_t next;
|
||||||
uintptr_t ret_addr;
|
uintptr_t ret_addr;
|
||||||
|
@ -186,7 +186,7 @@ static void unwind_stack(uintptr_t base_ptr, uint16_t cs)
|
||||||
base_ptr = frame->next;
|
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)
|
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",
|
LOG_ERR("RSP: 0x%016lx RFLAGS: 0x%016lx CS: 0x%04lx CR3: 0x%016lx",
|
||||||
esf->rsp, esf->rflags, esf->cs & 0xFFFFU, get_cr3(esf));
|
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:");
|
LOG_ERR("call trace:");
|
||||||
#endif
|
#endif
|
||||||
LOG_ERR("RIP: 0x%016lx", esf->rip);
|
LOG_ERR("RIP: 0x%016lx", esf->rip);
|
||||||
#ifdef CONFIG_X86_EXCEPTION_STACK_TRACE
|
#ifdef CONFIG_EXCEPTION_STACK_TRACE
|
||||||
unwind_stack(esf->rbp, esf->cs);
|
unwind_stack(esf->rbp, esf->cs);
|
||||||
#endif
|
#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,
|
LOG_ERR("EFLAGS: 0x%08x CS: 0x%04x CR3: 0x%08lx", esf->eflags,
|
||||||
esf->cs & 0xFFFFU, get_cr3(esf));
|
esf->cs & 0xFFFFU, get_cr3(esf));
|
||||||
|
|
||||||
#ifdef CONFIG_X86_EXCEPTION_STACK_TRACE
|
#ifdef CONFIG_EXCEPTION_STACK_TRACE
|
||||||
LOG_ERR("call trace:");
|
LOG_ERR("call trace:");
|
||||||
#endif
|
#endif
|
||||||
LOG_ERR("EIP: 0x%08x", esf->eip);
|
LOG_ERR("EIP: 0x%08x", esf->eip);
|
||||||
#ifdef CONFIG_X86_EXCEPTION_STACK_TRACE
|
#ifdef CONFIG_EXCEPTION_STACK_TRACE
|
||||||
unwind_stack(esf->ebp, esf->cs);
|
unwind_stack(esf->ebp, esf->cs);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -382,6 +382,9 @@ config SYMTAB
|
||||||
config EXCEPTION_STACK_TRACE
|
config EXCEPTION_STACK_TRACE
|
||||||
bool "Attempt to print stack traces upon exceptions"
|
bool "Attempt to print stack traces upon exceptions"
|
||||||
default y
|
default y
|
||||||
|
depends on (X86_EXCEPTION_STACK_TRACE || \
|
||||||
|
ARM64_EXCEPTION_STACK_TRACE || \
|
||||||
|
RISCV_EXCEPTION_STACK_TRACE)
|
||||||
help
|
help
|
||||||
If the architecture fatal handling code supports it, attempt to
|
If the architecture fatal handling code supports it, attempt to
|
||||||
print a stack trace of function memory addresses when an
|
print a stack trace of function memory addresses when an
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue