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 32*eeb118c5SHe Kuang #ifndef LIBUNWIND__ARCH_REG_ID 33*eeb118c5SHe Kuang #define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arch_reg_id(regnum) 34*eeb118c5SHe Kuang #endif 35*eeb118c5SHe Kuang int LIBUNWIND__ARCH_REG_ID(int regnum); 36d64ec10eSHe Kuang int unwind__prepare_access(struct thread *thread, struct map *map); 37380b5143SNamhyung Kim void unwind__flush_access(struct thread *thread); 3866f066d8SNamhyung Kim void unwind__finish_access(struct thread *thread); 3966f066d8SNamhyung Kim #else 40d64ec10eSHe Kuang static inline int unwind__prepare_access(struct thread *thread __maybe_unused, 41d64ec10eSHe Kuang struct map *map __maybe_unused) 4266f066d8SNamhyung Kim { 4366f066d8SNamhyung Kim return 0; 4466f066d8SNamhyung Kim } 4566f066d8SNamhyung Kim 46380b5143SNamhyung Kim static inline void unwind__flush_access(struct thread *thread __maybe_unused) {} 4766f066d8SNamhyung Kim static inline void unwind__finish_access(struct thread *thread __maybe_unused) {} 489ff125d1SJiri Olsa #endif 4971ad0f5eSJiri Olsa #else 5071ad0f5eSJiri Olsa static inline int 511d037ca1SIrina Tirdea unwind__get_entries(unwind_entry_cb_t cb __maybe_unused, 521d037ca1SIrina Tirdea void *arg __maybe_unused, 531d037ca1SIrina Tirdea struct thread *thread __maybe_unused, 5437676af1SArnaldo Carvalho de Melo struct perf_sample *data __maybe_unused, 5537676af1SArnaldo Carvalho de Melo int max_stack __maybe_unused) 5671ad0f5eSJiri Olsa { 5771ad0f5eSJiri Olsa return 0; 5871ad0f5eSJiri Olsa } 5966f066d8SNamhyung Kim 60d64ec10eSHe Kuang static inline int unwind__prepare_access(struct thread *thread __maybe_unused, 61d64ec10eSHe Kuang struct map *map __maybe_unused) 6266f066d8SNamhyung Kim { 6366f066d8SNamhyung Kim return 0; 6466f066d8SNamhyung Kim } 6566f066d8SNamhyung Kim 66380b5143SNamhyung Kim static inline void unwind__flush_access(struct thread *thread __maybe_unused) {} 6766f066d8SNamhyung Kim static inline void unwind__finish_access(struct thread *thread __maybe_unused) {} 689ff125d1SJiri Olsa #endif /* HAVE_DWARF_UNWIND_SUPPORT */ 6971ad0f5eSJiri Olsa #endif /* __UNWIND_H */ 70