stacktrace.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef _ASM_STACKTRACE_H
  2. #define _ASM_STACKTRACE_H
  3. #include <asm/ptrace.h>
  4. #ifdef CONFIG_KALLSYMS
  5. extern int raw_show_trace;
  6. extern unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
  7. unsigned long pc, unsigned long *ra);
  8. extern unsigned long unwind_stack_by_address(unsigned long stack_page,
  9. unsigned long *sp,
  10. unsigned long pc,
  11. unsigned long *ra);
  12. #else
  13. #define raw_show_trace 1
  14. static inline unsigned long unwind_stack(struct task_struct *task,
  15. unsigned long *sp, unsigned long pc, unsigned long *ra)
  16. {
  17. return 0;
  18. }
  19. #endif
  20. static __always_inline void prepare_frametrace(struct pt_regs *regs)
  21. {
  22. #ifndef CONFIG_KALLSYMS
  23. /*
  24. * Remove any garbage that may be in regs (specially func
  25. * addresses) to avoid show_raw_backtrace() to report them
  26. */
  27. memset(regs, 0, sizeof(*regs));
  28. #endif
  29. __asm__ __volatile__(
  30. ".set push\n\t"
  31. ".set noat\n\t"
  32. #ifdef CONFIG_64BIT
  33. "1: dla $1, 1b\n\t"
  34. "sd $1, %0\n\t"
  35. "sd $29, %1\n\t"
  36. "sd $31, %2\n\t"
  37. #else
  38. "1: la $1, 1b\n\t"
  39. "sw $1, %0\n\t"
  40. "sw $29, %1\n\t"
  41. "sw $31, %2\n\t"
  42. #endif
  43. ".set pop\n\t"
  44. : "=m" (regs->cp0_epc),
  45. "=m" (regs->regs[29]), "=m" (regs->regs[31])
  46. : : "memory");
  47. }
  48. #endif /* _ASM_STACKTRACE_H */