1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_STACKTRACE_H
3 #define _ASM_STACKTRACE_H
5 #include <asm/ptrace.h>
7 #include <linux/stringify.h>
10 extern int raw_show_trace;
11 extern unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
12 unsigned long pc, unsigned long *ra);
13 extern unsigned long unwind_stack_by_address(unsigned long stack_page,
18 #define raw_show_trace 1
19 static inline unsigned long unwind_stack(struct task_struct *task,
20 unsigned long *sp, unsigned long pc, unsigned long *ra)
26 #define STR_PTR_LA __stringify(PTR_LA)
27 #define STR_LONG_S __stringify(LONG_S)
28 #define STR_LONG_L __stringify(LONG_L)
29 #define STR_LONGSIZE __stringify(LONGSIZE)
31 #define STORE_ONE_REG(r) \
32 STR_LONG_S " $" __stringify(r)",("STR_LONGSIZE"*"__stringify(r)")(%1)\n\t"
34 static __always_inline void prepare_frametrace(struct pt_regs *regs)
36 #ifndef CONFIG_KALLSYMS
38 * Remove any garbage that may be in regs (specially func
39 * addresses) to avoid show_raw_backtrace() to report them
41 memset(regs, 0, sizeof(*regs));
46 /* Store $1 so we can use it */
47 STR_LONG_S " $1,"STR_LONGSIZE"(%1)\n\t"
49 "1: " STR_PTR_LA " $1, 1b\n\t"
50 STR_LONG_S " $1,%0\n\t"
82 STR_LONG_L " $1,"STR_LONGSIZE"(%1)\n\t"
84 : "=m" (regs->cp0_epc)
89 #endif /* _ASM_STACKTRACE_H */