backtrace.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef __BACKTRACE_H
  2. #define __BACKTRACE_H
  3. #ifndef __ASSEMBLY__
  4. #include <cpuport.h>
  5. /* Unwind reason code according the the ARM EABI documents */
  6. enum unwind_reason_code
  7. {
  8. URC_OK = 0, /* operation completed successfully */
  9. URC_CONTINUE_UNWIND = 8,
  10. URC_FAILURE = 9 /* unspecified failure of some kind */
  11. };
  12. struct unwind_idx
  13. {
  14. unsigned long addr_offset;
  15. unsigned long insn;
  16. };
  17. struct unwind_table
  18. {
  19. const struct unwind_idx *start;
  20. const struct unwind_idx *origin;
  21. const struct unwind_idx *stop;
  22. unsigned long begin_addr;
  23. unsigned long end_addr;
  24. };
  25. struct stackframe
  26. {
  27. /*
  28. * FP member should hold R7 when CONFIG_THUMB2_KERNEL is enabled
  29. * and R11 otherwise.
  30. */
  31. unsigned long fp;
  32. unsigned long sp;
  33. unsigned long lr;
  34. unsigned long pc;
  35. };
  36. struct pt_regs
  37. {
  38. unsigned long uregs[18];
  39. };
  40. #define ARM_cpsr uregs[16]
  41. #define ARM_pc uregs[15]
  42. #define ARM_lr uregs[14]
  43. #define ARM_sp uregs[13]
  44. #define ARM_ip uregs[12]
  45. #define ARM_fp uregs[11]
  46. #define ARM_r10 uregs[10]
  47. #define ARM_r9 uregs[9]
  48. #define ARM_r8 uregs[8]
  49. #define ARM_r7 uregs[7]
  50. #define ARM_r6 uregs[6]
  51. #define ARM_r5 uregs[5]
  52. #define ARM_r4 uregs[4]
  53. #define ARM_r3 uregs[3]
  54. #define ARM_r2 uregs[2]
  55. #define ARM_r1 uregs[1]
  56. #define ARM_r0 uregs[0]
  57. #define ARM_ORIG_r0 uregs[17]
  58. #define instruction_pointer(regs) (regs)->ARM_pc
  59. #ifdef CONFIG_THUMB2_KERNEL
  60. #define frame_pointer(regs) (regs)->ARM_r7
  61. #else
  62. #define frame_pointer(regs) (regs)->ARM_fp
  63. #endif
  64. int unwind_frame(struct stackframe *frame, const struct unwind_idx **origin_idx, const struct unwind_idx exidx_start[], const struct unwind_idx exidx_end[]);
  65. void unwind_backtrace(struct pt_regs *regs, const struct unwind_idx exidx_start[], const struct unwind_idx exidx_end[]);
  66. void rt_unwind(struct rt_hw_exp_stack *regs, unsigned int pc_adj);
  67. rt_err_t rt_backtrace(void);
  68. #endif /* !__ASSEMBLY__ */
  69. #endif /* __BACKTRACE_H */