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