blob: 87bd7caec1cfa038f6dcc2b693723d31066b52bd [file] [log] [blame]
Atsushi Nemoto1df0f0f2006-09-26 23:44:01 +09001#ifndef _ASM_STACKTRACE_H
2#define _ASM_STACKTRACE_H
3
4#include <asm/ptrace.h>
5
6#ifdef CONFIG_KALLSYMS
7extern int raw_show_trace;
8extern unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
Atsushi Nemoto19246002006-09-29 18:02:51 +09009 unsigned long pc, unsigned long *ra);
Atsushi Nemoto1df0f0f2006-09-26 23:44:01 +090010#else
11#define raw_show_trace 1
Ralf Baechlede4b2142007-08-07 15:02:55 +010012static inline unsigned long unwind_stack(struct task_struct *task,
13 unsigned long *sp, unsigned long pc, unsigned long *ra)
14{
15}
Atsushi Nemoto1df0f0f2006-09-26 23:44:01 +090016#endif
17
18static __always_inline void prepare_frametrace(struct pt_regs *regs)
19{
20#ifndef CONFIG_KALLSYMS
21 /*
22 * Remove any garbage that may be in regs (specially func
23 * addresses) to avoid show_raw_backtrace() to report them
24 */
25 memset(regs, 0, sizeof(*regs));
26#endif
27 __asm__ __volatile__(
28 ".set push\n\t"
29 ".set noat\n\t"
30#ifdef CONFIG_64BIT
31 "1: dla $1, 1b\n\t"
32 "sd $1, %0\n\t"
33 "sd $29, %1\n\t"
34 "sd $31, %2\n\t"
35#else
36 "1: la $1, 1b\n\t"
37 "sw $1, %0\n\t"
38 "sw $29, %1\n\t"
39 "sw $31, %2\n\t"
40#endif
41 ".set pop\n\t"
42 : "=m" (regs->cp0_epc),
43 "=m" (regs->regs[29]), "=m" (regs->regs[31])
44 : : "memory");
45}
46
47#endif /* _ASM_STACKTRACE_H */