171ad0f5eSJiri Olsa #ifndef __UNWIND_H 271ad0f5eSJiri Olsa #define __UNWIND_H 371ad0f5eSJiri Olsa 4*3dfed910SArnaldo Carvalho de Melo #include <linux/compiler.h> 5d944c4eeSBorislav Petkov #include <linux/types.h> 6*3dfed910SArnaldo Carvalho de Melo 7*3dfed910SArnaldo Carvalho de Melo struct map; 8*3dfed910SArnaldo Carvalho de Melo struct perf_sample; 9*3dfed910SArnaldo Carvalho de Melo struct symbol; 10*3dfed910SArnaldo Carvalho de Melo struct thread; 1171ad0f5eSJiri Olsa 1271ad0f5eSJiri Olsa struct unwind_entry { 1371ad0f5eSJiri Olsa struct map *map; 1471ad0f5eSJiri Olsa struct symbol *sym; 1571ad0f5eSJiri Olsa u64 ip; 1671ad0f5eSJiri Olsa }; 1771ad0f5eSJiri Olsa 1871ad0f5eSJiri Olsa typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg); 1971ad0f5eSJiri Olsa 20f83c0415SHe Kuang struct unwind_libunwind_ops { 21f83c0415SHe Kuang int (*prepare_access)(struct thread *thread); 22f83c0415SHe Kuang void (*flush_access)(struct thread *thread); 23f83c0415SHe Kuang void (*finish_access)(struct thread *thread); 24f83c0415SHe Kuang int (*get_entries)(unwind_entry_cb_t cb, void *arg, 25f83c0415SHe Kuang struct thread *thread, 26f83c0415SHe Kuang struct perf_sample *data, int max_stack); 27f83c0415SHe Kuang }; 28f83c0415SHe Kuang 299ff125d1SJiri Olsa #ifdef HAVE_DWARF_UNWIND_SUPPORT 3071ad0f5eSJiri Olsa int unwind__get_entries(unwind_entry_cb_t cb, void *arg, 3171ad0f5eSJiri Olsa struct thread *thread, 3237676af1SArnaldo Carvalho de Melo struct perf_sample *data, int max_stack); 339ff125d1SJiri Olsa /* libunwind specific */ 349ff125d1SJiri Olsa #ifdef HAVE_LIBUNWIND_SUPPORT 35eeb118c5SHe Kuang #ifndef LIBUNWIND__ARCH_REG_ID 36eeb118c5SHe Kuang #define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arch_reg_id(regnum) 37eeb118c5SHe Kuang #endif 3878ff1d6dSHe Kuang 3978ff1d6dSHe Kuang #ifndef LIBUNWIND__ARCH_REG_SP 4078ff1d6dSHe Kuang #define LIBUNWIND__ARCH_REG_SP PERF_REG_SP 4178ff1d6dSHe Kuang #endif 4278ff1d6dSHe Kuang 4378ff1d6dSHe Kuang #ifndef LIBUNWIND__ARCH_REG_IP 4478ff1d6dSHe Kuang #define LIBUNWIND__ARCH_REG_IP PERF_REG_IP 4578ff1d6dSHe Kuang #endif 4678ff1d6dSHe Kuang 47eeb118c5SHe Kuang int LIBUNWIND__ARCH_REG_ID(int regnum); 48a2873325SJiri Olsa int unwind__prepare_access(struct thread *thread, struct map *map, 49a2873325SJiri Olsa bool *initialized); 50380b5143SNamhyung Kim void unwind__flush_access(struct thread *thread); 5166f066d8SNamhyung Kim void unwind__finish_access(struct thread *thread); 5266f066d8SNamhyung Kim #else 53d64ec10eSHe Kuang static inline int unwind__prepare_access(struct thread *thread __maybe_unused, 54a2873325SJiri Olsa struct map *map __maybe_unused, 55a2873325SJiri Olsa bool *initialized __maybe_unused) 5666f066d8SNamhyung Kim { 5766f066d8SNamhyung Kim return 0; 5866f066d8SNamhyung Kim } 5966f066d8SNamhyung Kim 60380b5143SNamhyung Kim static inline void unwind__flush_access(struct thread *thread __maybe_unused) {} 6166f066d8SNamhyung Kim static inline void unwind__finish_access(struct thread *thread __maybe_unused) {} 629ff125d1SJiri Olsa #endif 6371ad0f5eSJiri Olsa #else 6471ad0f5eSJiri Olsa static inline int 651d037ca1SIrina Tirdea unwind__get_entries(unwind_entry_cb_t cb __maybe_unused, 661d037ca1SIrina Tirdea void *arg __maybe_unused, 671d037ca1SIrina Tirdea struct thread *thread __maybe_unused, 6837676af1SArnaldo Carvalho de Melo struct perf_sample *data __maybe_unused, 6937676af1SArnaldo Carvalho de Melo int max_stack __maybe_unused) 7071ad0f5eSJiri Olsa { 7171ad0f5eSJiri Olsa return 0; 7271ad0f5eSJiri Olsa } 7366f066d8SNamhyung Kim 74d64ec10eSHe Kuang static inline int unwind__prepare_access(struct thread *thread __maybe_unused, 75a2873325SJiri Olsa struct map *map __maybe_unused, 76a2873325SJiri Olsa bool *initialized __maybe_unused) 7766f066d8SNamhyung Kim { 7866f066d8SNamhyung Kim return 0; 7966f066d8SNamhyung Kim } 8066f066d8SNamhyung Kim 81380b5143SNamhyung Kim static inline void unwind__flush_access(struct thread *thread __maybe_unused) {} 8266f066d8SNamhyung Kim static inline void unwind__finish_access(struct thread *thread __maybe_unused) {} 839ff125d1SJiri Olsa #endif /* HAVE_DWARF_UNWIND_SUPPORT */ 8471ad0f5eSJiri Olsa #endif /* __UNWIND_H */ 85