blob: 780ee2c2a2ac54afb0f4adad265387cfe2285f7d [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);
Daniel Kalmar94ea09c2011-05-13 08:38:04 -040010extern unsigned long unwind_stack_by_address(unsigned long stack_page,
11 unsigned long *sp,
12 unsigned long pc,
13 unsigned long *ra);
Atsushi Nemoto1df0f0f2006-09-26 23:44:01 +090014#else
15#define raw_show_trace 1
Ralf Baechlede4b2142007-08-07 15:02:55 +010016static inline unsigned long unwind_stack(struct task_struct *task,
17 unsigned long *sp, unsigned long pc, unsigned long *ra)
18{
Ralf Baechlea2044582007-08-07 17:30:58 +010019 return 0;
Ralf Baechlede4b2142007-08-07 15:02:55 +010020}
Atsushi Nemoto1df0f0f2006-09-26 23:44:01 +090021#endif
22
23static __always_inline void prepare_frametrace(struct pt_regs *regs)
24{
25#ifndef CONFIG_KALLSYMS
26 /*
27 * Remove any garbage that may be in regs (specially func
28 * addresses) to avoid show_raw_backtrace() to report them
29 */
30 memset(regs, 0, sizeof(*regs));
31#endif
32 __asm__ __volatile__(
33 ".set push\n\t"
34 ".set noat\n\t"
35#ifdef CONFIG_64BIT
36 "1: dla $1, 1b\n\t"
37 "sd $1, %0\n\t"
38 "sd $29, %1\n\t"
39 "sd $31, %2\n\t"
40#else
41 "1: la $1, 1b\n\t"
42 "sw $1, %0\n\t"
43 "sw $29, %1\n\t"
44 "sw $31, %2\n\t"
45#endif
46 ".set pop\n\t"
47 : "=m" (regs->cp0_epc),
48 "=m" (regs->regs[29]), "=m" (regs->regs[31])
49 : : "memory");
50}
51
52#endif /* _ASM_STACKTRACE_H */