From 578a8e5138fd4ff718793601773e4d890ce3b34d Mon Sep 17 00:00:00 2001 From: Yong Cong Sin Date: Fri, 14 Jun 2024 11:47:35 +0800 Subject: [PATCH] arch: riscv: stacktrace: conditionally check stack_info Check if an address is in the thread stack only when `CONFIG_THREAD_STACK_INFO` is enabled, since otherwise the `stack_info` will not be available. This fixes compilation error when `CONFIG_THREAD_STACK_INFO` is explicitly disabled. Signed-off-by: Yong Cong Sin --- arch/riscv/core/stacktrace.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/riscv/core/stacktrace.c b/arch/riscv/core/stacktrace.c index 7a684a9bae9e7..563d6cad14454 100644 --- a/arch/riscv/core/stacktrace.c +++ b/arch/riscv/core/stacktrace.c @@ -36,12 +36,19 @@ static inline bool in_irq_stack_bound(uintptr_t addr, uint8_t cpu_id) static inline bool in_kernel_thread_stack_bound(uintptr_t addr, const struct k_thread *const thread) { +#ifdef CONFIG_THREAD_STACK_INFO uintptr_t start, end; start = thread->stack_info.start; end = Z_STACK_PTR_ALIGN(thread->stack_info.start + thread->stack_info.size); return (addr >= start) && (addr < end); +#else + ARG_UNUSED(addr); + ARG_UNUSED(thread); + /* Return false as we can't check if the addr is in the thread stack without stack info */ + return false; +#endif } #ifdef CONFIG_USERSPACE