Skip to content

Commit 5ec6024

Browse files
dcpleungnashif
authored andcommitted
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 <[email protected]>
1 parent 968f674 commit 5ec6024

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

arch/x86/core/fatal.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,12 @@ bool z_x86_check_guard_page(uintptr_t addr)
121121
#endif /* CONFIG_THREAD_STACK_MEM_MAPPED */
122122

123123
#if defined(CONFIG_ARCH_STACKWALK)
124-
typedef bool (*x86_stacktrace_cb)(void *cookie, unsigned long addr, unsigned long arg);
125-
126124
struct stack_frame {
127125
uintptr_t next;
128126
uintptr_t ret_addr;
129-
#ifndef CONFIG_X86_64
130-
uintptr_t args;
131-
#endif
132127
};
133128

134-
__pinned_func static void walk_stackframe(x86_stacktrace_cb cb, void *cookie,
129+
__pinned_func static void walk_stackframe(stack_trace_callback_fn cb, void *cookie,
135130
const struct arch_esf *esf, int max_frames)
136131
{
137132
uintptr_t base_ptr;
@@ -181,8 +176,7 @@ __pinned_func static void walk_stackframe(x86_stacktrace_cb cb, void *cookie,
181176
break;
182177
}
183178

184-
if (!cb(cookie, frame->ret_addr,
185-
COND_CODE_1(CONFIG_X86_64, (0), (frame->args)))) {
179+
if (!cb(cookie, frame->ret_addr)) {
186180
break;
187181
}
188182

@@ -195,27 +189,26 @@ void arch_stack_walk(stack_trace_callback_fn callback_fn, void *cookie,
195189
{
196190
ARG_UNUSED(thread);
197191

198-
walk_stackframe((x86_stacktrace_cb)callback_fn, cookie, esf,
192+
walk_stackframe(callback_fn, cookie, esf,
199193
CONFIG_ARCH_STACKWALK_MAX_FRAMES);
200194
}
201195
#endif /* CONFIG_ARCH_STACKWALK */
202196

203197
#if defined(CONFIG_EXCEPTION_STACK_TRACE)
204-
static bool print_trace_address(void *arg, unsigned long addr, unsigned long args)
198+
static bool print_trace_address(void *arg, unsigned long addr)
205199
{
206200
int *i = arg;
207201

208202
#ifdef CONFIG_X86_64
209203
LOG_ERR(" %d: 0x%016lx", (*i)++, addr);
210204
#else
211-
LOG_ERR(" %d: 0x%08lx (0x%lx)", (*i)++, addr, args);
205+
LOG_ERR(" %d: 0x%08lx", (*i)++, addr);
212206
#endif
213207

214208
return true;
215209
}
216210

217-
__pinned_func
218-
static void unwind_stack(const struct arch_esf *esf)
211+
static ALWAYS_INLINE void unwind_stack(const struct arch_esf *esf)
219212
{
220213
int i = 0;
221214

0 commit comments

Comments
 (0)