stacktrace.h 982 B

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