171ad0f5eSJiri Olsa #ifndef __UNWIND_H 271ad0f5eSJiri Olsa #define __UNWIND_H 371ad0f5eSJiri Olsa 4d944c4eeSBorislav Petkov #include <linux/types.h> 571ad0f5eSJiri Olsa #include "event.h" 671ad0f5eSJiri Olsa #include "symbol.h" 766f066d8SNamhyung Kim #include "thread.h" 871ad0f5eSJiri Olsa 971ad0f5eSJiri Olsa struct unwind_entry { 1071ad0f5eSJiri Olsa struct map *map; 1171ad0f5eSJiri Olsa struct symbol *sym; 1271ad0f5eSJiri Olsa u64 ip; 1371ad0f5eSJiri Olsa }; 1471ad0f5eSJiri Olsa 1571ad0f5eSJiri Olsa typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg); 1671ad0f5eSJiri Olsa 17f83c0415SHe Kuang struct unwind_libunwind_ops { 18f83c0415SHe Kuang int (*prepare_access)(struct thread *thread); 19f83c0415SHe Kuang void (*flush_access)(struct thread *thread); 20f83c0415SHe Kuang void (*finish_access)(struct thread *thread); 21f83c0415SHe Kuang int (*get_entries)(unwind_entry_cb_t cb, void *arg, 22f83c0415SHe Kuang struct thread *thread, 23f83c0415SHe Kuang struct perf_sample *data, int max_stack); 24f83c0415SHe Kuang }; 25f83c0415SHe Kuang 269ff125d1SJiri Olsa #ifdef HAVE_DWARF_UNWIND_SUPPORT 2771ad0f5eSJiri Olsa int unwind__get_entries(unwind_entry_cb_t cb, void *arg, 2871ad0f5eSJiri Olsa struct thread *thread, 2937676af1SArnaldo Carvalho de Melo struct perf_sample *data, int max_stack); 309ff125d1SJiri Olsa /* libunwind specific */ 319ff125d1SJiri Olsa #ifdef HAVE_LIBUNWIND_SUPPORT 32eeb118c5SHe Kuang #ifndef LIBUNWIND__ARCH_REG_ID 33eeb118c5SHe Kuang #define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arch_reg_id(regnum) 34eeb118c5SHe Kuang #endif 35*78ff1d6dSHe Kuang 36*78ff1d6dSHe Kuang #ifndef LIBUNWIND__ARCH_REG_SP 37*78ff1d6dSHe Kuang #define LIBUNWIND__ARCH_REG_SP PERF_REG_SP 38*78ff1d6dSHe Kuang #endif 39*78ff1d6dSHe Kuang 40*78ff1d6dSHe Kuang #ifndef LIBUNWIND__ARCH_REG_IP 41*78ff1d6dSHe Kuang #define LIBUNWIND__ARCH_REG_IP PERF_REG_IP 42*78ff1d6dSHe Kuang #endif 43*78ff1d6dSHe Kuang 44eeb118c5SHe Kuang int LIBUNWIND__ARCH_REG_ID(int regnum); 45d64ec10eSHe Kuang int unwind__prepare_access(struct thread *thread, struct map *map); 46380b5143SNamhyung Kim void unwind__flush_access(struct thread *thread); 4766f066d8SNamhyung Kim void unwind__finish_access(struct thread *thread); 4866f066d8SNamhyung Kim #else 49d64ec10eSHe Kuang static inline int unwind__prepare_access(struct thread *thread __maybe_unused, 50d64ec10eSHe Kuang struct map *map __maybe_unused) 5166f066d8SNamhyung Kim { 5266f066d8SNamhyung Kim return 0; 5366f066d8SNamhyung Kim } 5466f066d8SNamhyung Kim 55380b5143SNamhyung Kim static inline void unwind__flush_access(struct thread *thread __maybe_unused) {} 5666f066d8SNamhyung Kim static inline void unwind__finish_access(struct thread *thread __maybe_unused) {} 579ff125d1SJiri Olsa #endif 5871ad0f5eSJiri Olsa #else 5971ad0f5eSJiri Olsa static inline int 601d037ca1SIrina Tirdea unwind__get_entries(unwind_entry_cb_t cb __maybe_unused, 611d037ca1SIrina Tirdea void *arg __maybe_unused, 621d037ca1SIrina Tirdea struct thread *thread __maybe_unused, 6337676af1SArnaldo Carvalho de Melo struct perf_sample *data __maybe_unused, 6437676af1SArnaldo Carvalho de Melo int max_stack __maybe_unused) 6571ad0f5eSJiri Olsa { 6671ad0f5eSJiri Olsa return 0; 6771ad0f5eSJiri Olsa } 6866f066d8SNamhyung Kim 69d64ec10eSHe Kuang static inline int unwind__prepare_access(struct thread *thread __maybe_unused, 70d64ec10eSHe Kuang struct map *map __maybe_unused) 7166f066d8SNamhyung Kim { 7266f066d8SNamhyung Kim return 0; 7366f066d8SNamhyung Kim } 7466f066d8SNamhyung Kim 75380b5143SNamhyung Kim static inline void unwind__flush_access(struct thread *thread __maybe_unused) {} 7666f066d8SNamhyung Kim static inline void unwind__finish_access(struct thread *thread __maybe_unused) {} 779ff125d1SJiri Olsa #endif /* HAVE_DWARF_UNWIND_SUPPORT */ 7871ad0f5eSJiri Olsa #endif /* __UNWIND_H */ 79