1 #ifndef _ASM_STACKTRACE_H 2 #define _ASM_STACKTRACE_H 3 4 #include <asm/ptrace.h> 5 #include <asm/asm.h> 6 #include <linux/stringify.h> 7 8 #ifdef CONFIG_KALLSYMS 9 extern int raw_show_trace; 10 extern unsigned long unwind_stack(struct task_struct *task, unsigned long *sp, 11 unsigned long pc, unsigned long *ra); 12 extern unsigned long unwind_stack_by_address(unsigned long stack_page, 13 unsigned long *sp, 14 unsigned long pc, 15 unsigned long *ra); 16 #else 17 #define raw_show_trace 1 18 static inline unsigned long unwind_stack(struct task_struct *task, 19 unsigned long *sp, unsigned long pc, unsigned long *ra) 20 { 21 return 0; 22 } 23 #endif 24 25 #define STR_PTR_LA __stringify(PTR_LA) 26 #define STR_LONG_S __stringify(LONG_S) 27 #define STR_LONG_L __stringify(LONG_L) 28 #define STR_LONGSIZE __stringify(LONGSIZE) 29 30 #define STORE_ONE_REG(r) \ 31 STR_LONG_S " $" __stringify(r)",("STR_LONGSIZE"*"__stringify(r)")(%1)\n\t" 32 33 static __always_inline void prepare_frametrace(struct pt_regs *regs) 34 { 35 #ifndef CONFIG_KALLSYMS 36 /* 37 * Remove any garbage that may be in regs (specially func 38 * addresses) to avoid show_raw_backtrace() to report them 39 */ 40 memset(regs, 0, sizeof(*regs)); 41 #endif 42 __asm__ __volatile__( 43 ".set push\n\t" 44 ".set noat\n\t" 45 /* Store $1 so we can use it */ 46 STR_LONG_S " $1,"STR_LONGSIZE"(%1)\n\t" 47 /* Store the PC */ 48 "1: " STR_PTR_LA " $1, 1b\n\t" 49 STR_LONG_S " $1,%0\n\t" 50 STORE_ONE_REG(2) 51 STORE_ONE_REG(3) 52 STORE_ONE_REG(4) 53 STORE_ONE_REG(5) 54 STORE_ONE_REG(6) 55 STORE_ONE_REG(7) 56 STORE_ONE_REG(8) 57 STORE_ONE_REG(9) 58 STORE_ONE_REG(10) 59 STORE_ONE_REG(11) 60 STORE_ONE_REG(12) 61 STORE_ONE_REG(13) 62 STORE_ONE_REG(14) 63 STORE_ONE_REG(15) 64 STORE_ONE_REG(16) 65 STORE_ONE_REG(17) 66 STORE_ONE_REG(18) 67 STORE_ONE_REG(19) 68 STORE_ONE_REG(20) 69 STORE_ONE_REG(21) 70 STORE_ONE_REG(22) 71 STORE_ONE_REG(23) 72 STORE_ONE_REG(24) 73 STORE_ONE_REG(25) 74 STORE_ONE_REG(26) 75 STORE_ONE_REG(27) 76 STORE_ONE_REG(28) 77 STORE_ONE_REG(29) 78 STORE_ONE_REG(30) 79 STORE_ONE_REG(31) 80 /* Restore $1 */ 81 STR_LONG_L " $1,"STR_LONGSIZE"(%1)\n\t" 82 ".set pop\n\t" 83 : "=m" (regs->cp0_epc) 84 : "r" (regs->regs) 85 : "memory"); 86 } 87 88 #endif /* _ASM_STACKTRACE_H */ 89