Atsushi Nemoto | 1df0f0f | 2006-09-26 23:44:01 +0900 | [diff] [blame] | 1 | #ifndef _ASM_STACKTRACE_H |
| 2 | #define _ASM_STACKTRACE_H |
| 3 | |
| 4 | #include <asm/ptrace.h> |
| 5 | |
| 6 | #ifdef CONFIG_KALLSYMS |
| 7 | extern int raw_show_trace; |
| 8 | extern unsigned long unwind_stack(struct task_struct *task, unsigned long *sp, |
Atsushi Nemoto | 1924600 | 2006-09-29 18:02:51 +0900 | [diff] [blame] | 9 | unsigned long pc, unsigned long *ra); |
Daniel Kalmar | 94ea09c | 2011-05-13 08:38:04 -0400 | [diff] [blame] | 10 | extern unsigned long unwind_stack_by_address(unsigned long stack_page, |
| 11 | unsigned long *sp, |
| 12 | unsigned long pc, |
| 13 | unsigned long *ra); |
Atsushi Nemoto | 1df0f0f | 2006-09-26 23:44:01 +0900 | [diff] [blame] | 14 | #else |
| 15 | #define raw_show_trace 1 |
Ralf Baechle | de4b214 | 2007-08-07 15:02:55 +0100 | [diff] [blame] | 16 | static inline unsigned long unwind_stack(struct task_struct *task, |
| 17 | unsigned long *sp, unsigned long pc, unsigned long *ra) |
| 18 | { |
Ralf Baechle | a204458 | 2007-08-07 17:30:58 +0100 | [diff] [blame] | 19 | return 0; |
Ralf Baechle | de4b214 | 2007-08-07 15:02:55 +0100 | [diff] [blame] | 20 | } |
Atsushi Nemoto | 1df0f0f | 2006-09-26 23:44:01 +0900 | [diff] [blame] | 21 | #endif |
| 22 | |
| 23 | static __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 */ |