Jiri Olsa | 71ad0f5 | 2012-08-07 15:20:46 +0200 | [diff] [blame] | 1 | #ifndef __UNWIND_H |
| 2 | #define __UNWIND_H |
| 3 | |
Arnaldo Carvalho de Melo | 3dfed91 | 2017-04-19 13:28:30 -0300 | [diff] [blame] | 4 | #include <linux/compiler.h> |
Borislav Petkov | d944c4e | 2014-04-25 21:31:02 +0200 | [diff] [blame] | 5 | #include <linux/types.h> |
Arnaldo Carvalho de Melo | 3dfed91 | 2017-04-19 13:28:30 -0300 | [diff] [blame] | 6 | |
| 7 | struct map; |
| 8 | struct perf_sample; |
| 9 | struct symbol; |
| 10 | struct thread; |
Jiri Olsa | 71ad0f5 | 2012-08-07 15:20:46 +0200 | [diff] [blame] | 11 | |
| 12 | struct unwind_entry { |
| 13 | struct map *map; |
| 14 | struct symbol *sym; |
| 15 | u64 ip; |
| 16 | }; |
| 17 | |
| 18 | typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg); |
| 19 | |
He Kuang | f83c041 | 2016-06-03 03:33:12 +0000 | [diff] [blame] | 20 | struct unwind_libunwind_ops { |
| 21 | int (*prepare_access)(struct thread *thread); |
| 22 | void (*flush_access)(struct thread *thread); |
| 23 | void (*finish_access)(struct thread *thread); |
| 24 | int (*get_entries)(unwind_entry_cb_t cb, void *arg, |
| 25 | struct thread *thread, |
| 26 | struct perf_sample *data, int max_stack); |
| 27 | }; |
| 28 | |
Jiri Olsa | 9ff125d | 2014-01-07 13:47:28 +0100 | [diff] [blame] | 29 | #ifdef HAVE_DWARF_UNWIND_SUPPORT |
Jiri Olsa | 71ad0f5 | 2012-08-07 15:20:46 +0200 | [diff] [blame] | 30 | int unwind__get_entries(unwind_entry_cb_t cb, void *arg, |
Jiri Olsa | 71ad0f5 | 2012-08-07 15:20:46 +0200 | [diff] [blame] | 31 | struct thread *thread, |
Arnaldo Carvalho de Melo | 37676af | 2013-11-13 17:40:36 -0300 | [diff] [blame] | 32 | struct perf_sample *data, int max_stack); |
Jiri Olsa | 9ff125d | 2014-01-07 13:47:28 +0100 | [diff] [blame] | 33 | /* libunwind specific */ |
| 34 | #ifdef HAVE_LIBUNWIND_SUPPORT |
He Kuang | eeb118c | 2016-06-03 03:33:20 +0000 | [diff] [blame] | 35 | #ifndef LIBUNWIND__ARCH_REG_ID |
| 36 | #define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arch_reg_id(regnum) |
| 37 | #endif |
He Kuang | 78ff1d6 | 2016-06-22 06:57:02 +0000 | [diff] [blame] | 38 | |
| 39 | #ifndef LIBUNWIND__ARCH_REG_SP |
| 40 | #define LIBUNWIND__ARCH_REG_SP PERF_REG_SP |
| 41 | #endif |
| 42 | |
| 43 | #ifndef LIBUNWIND__ARCH_REG_IP |
| 44 | #define LIBUNWIND__ARCH_REG_IP PERF_REG_IP |
| 45 | #endif |
| 46 | |
He Kuang | eeb118c | 2016-06-03 03:33:20 +0000 | [diff] [blame] | 47 | int LIBUNWIND__ARCH_REG_ID(int regnum); |
Jiri Olsa | a287332 | 2016-07-04 14:16:22 +0200 | [diff] [blame] | 48 | int unwind__prepare_access(struct thread *thread, struct map *map, |
| 49 | bool *initialized); |
Namhyung Kim | 380b514 | 2014-10-06 09:46:01 +0900 | [diff] [blame] | 50 | void unwind__flush_access(struct thread *thread); |
Namhyung Kim | 66f066d8 | 2014-10-06 09:46:00 +0900 | [diff] [blame] | 51 | void unwind__finish_access(struct thread *thread); |
| 52 | #else |
He Kuang | d64ec10 | 2016-06-03 03:33:19 +0000 | [diff] [blame] | 53 | static inline int unwind__prepare_access(struct thread *thread __maybe_unused, |
Jiri Olsa | a287332 | 2016-07-04 14:16:22 +0200 | [diff] [blame] | 54 | struct map *map __maybe_unused, |
| 55 | bool *initialized __maybe_unused) |
Namhyung Kim | 66f066d8 | 2014-10-06 09:46:00 +0900 | [diff] [blame] | 56 | { |
| 57 | return 0; |
| 58 | } |
| 59 | |
Namhyung Kim | 380b514 | 2014-10-06 09:46:01 +0900 | [diff] [blame] | 60 | static inline void unwind__flush_access(struct thread *thread __maybe_unused) {} |
Namhyung Kim | 66f066d8 | 2014-10-06 09:46:00 +0900 | [diff] [blame] | 61 | static inline void unwind__finish_access(struct thread *thread __maybe_unused) {} |
Jiri Olsa | 9ff125d | 2014-01-07 13:47:28 +0100 | [diff] [blame] | 62 | #endif |
Jiri Olsa | 71ad0f5 | 2012-08-07 15:20:46 +0200 | [diff] [blame] | 63 | #else |
| 64 | static inline int |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 65 | unwind__get_entries(unwind_entry_cb_t cb __maybe_unused, |
| 66 | void *arg __maybe_unused, |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 67 | struct thread *thread __maybe_unused, |
Arnaldo Carvalho de Melo | 37676af | 2013-11-13 17:40:36 -0300 | [diff] [blame] | 68 | struct perf_sample *data __maybe_unused, |
| 69 | int max_stack __maybe_unused) |
Jiri Olsa | 71ad0f5 | 2012-08-07 15:20:46 +0200 | [diff] [blame] | 70 | { |
| 71 | return 0; |
| 72 | } |
Namhyung Kim | 66f066d8 | 2014-10-06 09:46:00 +0900 | [diff] [blame] | 73 | |
He Kuang | d64ec10 | 2016-06-03 03:33:19 +0000 | [diff] [blame] | 74 | static inline int unwind__prepare_access(struct thread *thread __maybe_unused, |
Jiri Olsa | a287332 | 2016-07-04 14:16:22 +0200 | [diff] [blame] | 75 | struct map *map __maybe_unused, |
| 76 | bool *initialized __maybe_unused) |
Namhyung Kim | 66f066d8 | 2014-10-06 09:46:00 +0900 | [diff] [blame] | 77 | { |
| 78 | return 0; |
| 79 | } |
| 80 | |
Namhyung Kim | 380b514 | 2014-10-06 09:46:01 +0900 | [diff] [blame] | 81 | static inline void unwind__flush_access(struct thread *thread __maybe_unused) {} |
Namhyung Kim | 66f066d8 | 2014-10-06 09:46:00 +0900 | [diff] [blame] | 82 | static inline void unwind__finish_access(struct thread *thread __maybe_unused) {} |
Jiri Olsa | 9ff125d | 2014-01-07 13:47:28 +0100 | [diff] [blame] | 83 | #endif /* HAVE_DWARF_UNWIND_SUPPORT */ |
Jiri Olsa | 71ad0f5 | 2012-08-07 15:20:46 +0200 | [diff] [blame] | 84 | #endif /* __UNWIND_H */ |