unwind.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef __UNWIND_H
  2. #define __UNWIND_H
  3. #include <linux/types.h>
  4. #include "event.h"
  5. #include "symbol.h"
  6. #include "thread.h"
  7. struct unwind_entry {
  8. struct map *map;
  9. struct symbol *sym;
  10. u64 ip;
  11. };
  12. typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg);
  13. struct unwind_libunwind_ops {
  14. int (*prepare_access)(struct thread *thread);
  15. void (*flush_access)(struct thread *thread);
  16. void (*finish_access)(struct thread *thread);
  17. int (*get_entries)(unwind_entry_cb_t cb, void *arg,
  18. struct thread *thread,
  19. struct perf_sample *data, int max_stack);
  20. };
  21. #ifdef HAVE_DWARF_UNWIND_SUPPORT
  22. int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
  23. struct thread *thread,
  24. struct perf_sample *data, int max_stack);
  25. /* libunwind specific */
  26. #ifdef HAVE_LIBUNWIND_SUPPORT
  27. #ifndef LIBUNWIND__ARCH_REG_ID
  28. #define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arch_reg_id(regnum)
  29. #endif
  30. #ifndef LIBUNWIND__ARCH_REG_SP
  31. #define LIBUNWIND__ARCH_REG_SP PERF_REG_SP
  32. #endif
  33. #ifndef LIBUNWIND__ARCH_REG_IP
  34. #define LIBUNWIND__ARCH_REG_IP PERF_REG_IP
  35. #endif
  36. int LIBUNWIND__ARCH_REG_ID(int regnum);
  37. int unwind__prepare_access(struct thread *thread, struct map *map,
  38. bool *initialized);
  39. void unwind__flush_access(struct thread *thread);
  40. void unwind__finish_access(struct thread *thread);
  41. #else
  42. static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
  43. struct map *map __maybe_unused,
  44. bool *initialized __maybe_unused)
  45. {
  46. return 0;
  47. }
  48. static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
  49. static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
  50. #endif
  51. #else
  52. static inline int
  53. unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
  54. void *arg __maybe_unused,
  55. struct thread *thread __maybe_unused,
  56. struct perf_sample *data __maybe_unused,
  57. int max_stack __maybe_unused)
  58. {
  59. return 0;
  60. }
  61. static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
  62. struct map *map __maybe_unused,
  63. bool *initialized __maybe_unused)
  64. {
  65. return 0;
  66. }
  67. static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
  68. static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
  69. #endif /* HAVE_DWARF_UNWIND_SUPPORT */
  70. #endif /* __UNWIND_H */