stacktrace.h 1.1 KB

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