x86: skip printing args when unwinding stack
On 32-bit x86, it was supposed to print the first argument to the function during stack trace. However, it only works when code optimizations are totally disabled (i.e. -O0). As such, printing the args is not meaningful to aid with debugging. So change it to simply print the function address, the same as x86 64-bit. Also, since unwind_stack() has exactly one caller, make it ALWAYS_INLINE to skip a function call. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
968f674c66
commit
5ec60249ed
1 changed files with 6 additions and 13 deletions
|
@ -121,17 +121,12 @@ bool z_x86_check_guard_page(uintptr_t addr)
|
||||||
#endif /* CONFIG_THREAD_STACK_MEM_MAPPED */
|
#endif /* CONFIG_THREAD_STACK_MEM_MAPPED */
|
||||||
|
|
||||||
#if defined(CONFIG_ARCH_STACKWALK)
|
#if defined(CONFIG_ARCH_STACKWALK)
|
||||||
typedef bool (*x86_stacktrace_cb)(void *cookie, unsigned long addr, unsigned long arg);
|
|
||||||
|
|
||||||
struct stack_frame {
|
struct stack_frame {
|
||||||
uintptr_t next;
|
uintptr_t next;
|
||||||
uintptr_t ret_addr;
|
uintptr_t ret_addr;
|
||||||
#ifndef CONFIG_X86_64
|
|
||||||
uintptr_t args;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
__pinned_func static void walk_stackframe(x86_stacktrace_cb cb, void *cookie,
|
__pinned_func static void walk_stackframe(stack_trace_callback_fn cb, void *cookie,
|
||||||
const struct arch_esf *esf, int max_frames)
|
const struct arch_esf *esf, int max_frames)
|
||||||
{
|
{
|
||||||
uintptr_t base_ptr;
|
uintptr_t base_ptr;
|
||||||
|
@ -181,8 +176,7 @@ __pinned_func static void walk_stackframe(x86_stacktrace_cb cb, void *cookie,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cb(cookie, frame->ret_addr,
|
if (!cb(cookie, frame->ret_addr)) {
|
||||||
COND_CODE_1(CONFIG_X86_64, (0), (frame->args)))) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,27 +189,26 @@ void arch_stack_walk(stack_trace_callback_fn callback_fn, void *cookie,
|
||||||
{
|
{
|
||||||
ARG_UNUSED(thread);
|
ARG_UNUSED(thread);
|
||||||
|
|
||||||
walk_stackframe((x86_stacktrace_cb)callback_fn, cookie, esf,
|
walk_stackframe(callback_fn, cookie, esf,
|
||||||
CONFIG_ARCH_STACKWALK_MAX_FRAMES);
|
CONFIG_ARCH_STACKWALK_MAX_FRAMES);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_ARCH_STACKWALK */
|
#endif /* CONFIG_ARCH_STACKWALK */
|
||||||
|
|
||||||
#if defined(CONFIG_EXCEPTION_STACK_TRACE)
|
#if defined(CONFIG_EXCEPTION_STACK_TRACE)
|
||||||
static bool print_trace_address(void *arg, unsigned long addr, unsigned long args)
|
static bool print_trace_address(void *arg, unsigned long addr)
|
||||||
{
|
{
|
||||||
int *i = arg;
|
int *i = arg;
|
||||||
|
|
||||||
#ifdef CONFIG_X86_64
|
#ifdef CONFIG_X86_64
|
||||||
LOG_ERR(" %d: 0x%016lx", (*i)++, addr);
|
LOG_ERR(" %d: 0x%016lx", (*i)++, addr);
|
||||||
#else
|
#else
|
||||||
LOG_ERR(" %d: 0x%08lx (0x%lx)", (*i)++, addr, args);
|
LOG_ERR(" %d: 0x%08lx", (*i)++, addr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
__pinned_func
|
static ALWAYS_INLINE void unwind_stack(const struct arch_esf *esf)
|
||||||
static void unwind_stack(const struct arch_esf *esf)
|
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue