backtrace.h 2.0 KB

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