unwind.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef _ASM_X86_UNWIND_H
  2. #define _ASM_X86_UNWIND_H
  3. #include <linux/sched.h>
  4. #include <linux/ftrace.h>
  5. #include <asm/ptrace.h>
  6. #include <asm/stacktrace.h>
  7. struct unwind_state {
  8. struct stack_info stack_info;
  9. unsigned long stack_mask;
  10. struct task_struct *task;
  11. int graph_idx;
  12. #ifdef CONFIG_FRAME_POINTER
  13. unsigned long *bp;
  14. #else
  15. unsigned long *sp;
  16. #endif
  17. };
  18. void __unwind_start(struct unwind_state *state, struct task_struct *task,
  19. struct pt_regs *regs, unsigned long *first_frame);
  20. bool unwind_next_frame(struct unwind_state *state);
  21. unsigned long unwind_get_return_address(struct unwind_state *state);
  22. static inline bool unwind_done(struct unwind_state *state)
  23. {
  24. return state->stack_info.type == STACK_TYPE_UNKNOWN;
  25. }
  26. static inline
  27. void unwind_start(struct unwind_state *state, struct task_struct *task,
  28. struct pt_regs *regs, unsigned long *first_frame)
  29. {
  30. first_frame = first_frame ? : get_stack_pointer(task, regs);
  31. __unwind_start(state, task, regs, first_frame);
  32. }
  33. #ifdef CONFIG_FRAME_POINTER
  34. static inline
  35. unsigned long *unwind_get_return_address_ptr(struct unwind_state *state)
  36. {
  37. if (unwind_done(state))
  38. return NULL;
  39. return state->bp + 1;
  40. }
  41. #else /* !CONFIG_FRAME_POINTER */
  42. static inline
  43. unsigned long *unwind_get_return_address_ptr(struct unwind_state *state)
  44. {
  45. return NULL;
  46. }
  47. #endif /* CONFIG_FRAME_POINTER */
  48. #endif /* _ASM_X86_UNWIND_H */