Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
71ad0f5e JO |
2 | #ifndef __UNWIND_H |
3 | #define __UNWIND_H | |
4 | ||
3dfed910 | 5 | #include <linux/compiler.h> |
d944c4ee | 6 | #include <linux/types.h> |
c1529738 | 7 | #include "util/map_symbol.h" |
3dfed910 | 8 | |
79b6bb73 | 9 | struct maps; |
3dfed910 | 10 | struct perf_sample; |
3dfed910 | 11 | struct thread; |
71ad0f5e JO |
12 | |
13 | struct unwind_entry { | |
c1529738 ACM |
14 | struct map_symbol ms; |
15 | u64 ip; | |
71ad0f5e JO |
16 | }; |
17 | ||
18 | typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg); | |
19 | ||
f83c0415 | 20 | struct unwind_libunwind_ops { |
79b6bb73 ACM |
21 | int (*prepare_access)(struct maps *maps); |
22 | void (*flush_access)(struct maps *maps); | |
23 | void (*finish_access)(struct maps *maps); | |
f83c0415 HK |
24 | int (*get_entries)(unwind_entry_cb_t cb, void *arg, |
25 | struct thread *thread, | |
fa7095c5 | 26 | struct perf_sample *data, int max_stack, bool best_effort); |
f83c0415 HK |
27 | }; |
28 | ||
9ff125d1 | 29 | #ifdef HAVE_DWARF_UNWIND_SUPPORT |
fa7095c5 JC |
30 | /* |
31 | * When best_effort is set, don't report errors and fail silently. This could | |
32 | * be expanded in the future to be more permissive about things other than | |
33 | * error messages. | |
34 | */ | |
71ad0f5e | 35 | int unwind__get_entries(unwind_entry_cb_t cb, void *arg, |
71ad0f5e | 36 | struct thread *thread, |
fa7095c5 JC |
37 | struct perf_sample *data, int max_stack, |
38 | bool best_effort); | |
9ff125d1 JO |
39 | /* libunwind specific */ |
40 | #ifdef HAVE_LIBUNWIND_SUPPORT | |
eeb118c5 HK |
41 | #ifndef LIBUNWIND__ARCH_REG_ID |
42 | #define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arch_reg_id(regnum) | |
43 | #endif | |
78ff1d6d | 44 | |
eeb118c5 | 45 | int LIBUNWIND__ARCH_REG_ID(int regnum); |
79b6bb73 ACM |
46 | int unwind__prepare_access(struct maps *maps, struct map *map, bool *initialized); |
47 | void unwind__flush_access(struct maps *maps); | |
48 | void unwind__finish_access(struct maps *maps); | |
66f066d8 | 49 | #else |
79b6bb73 | 50 | static inline int unwind__prepare_access(struct maps *maps __maybe_unused, |
a2873325 JO |
51 | struct map *map __maybe_unused, |
52 | bool *initialized __maybe_unused) | |
66f066d8 NK |
53 | { |
54 | return 0; | |
55 | } | |
56 | ||
79b6bb73 ACM |
57 | static inline void unwind__flush_access(struct maps *maps __maybe_unused) {} |
58 | static inline void unwind__finish_access(struct maps *maps __maybe_unused) {} | |
9ff125d1 | 59 | #endif |
71ad0f5e JO |
60 | #else |
61 | static inline int | |
1d037ca1 IT |
62 | unwind__get_entries(unwind_entry_cb_t cb __maybe_unused, |
63 | void *arg __maybe_unused, | |
1d037ca1 | 64 | struct thread *thread __maybe_unused, |
37676af1 | 65 | struct perf_sample *data __maybe_unused, |
fa7095c5 JC |
66 | int max_stack __maybe_unused, |
67 | bool best_effort __maybe_unused) | |
71ad0f5e JO |
68 | { |
69 | return 0; | |
70 | } | |
66f066d8 | 71 | |
79b6bb73 | 72 | static inline int unwind__prepare_access(struct maps *maps __maybe_unused, |
a2873325 JO |
73 | struct map *map __maybe_unused, |
74 | bool *initialized __maybe_unused) | |
66f066d8 NK |
75 | { |
76 | return 0; | |
77 | } | |
78 | ||
79b6bb73 ACM |
79 | static inline void unwind__flush_access(struct maps *maps __maybe_unused) {} |
80 | static inline void unwind__finish_access(struct maps *maps __maybe_unused) {} | |
9ff125d1 | 81 | #endif /* HAVE_DWARF_UNWIND_SUPPORT */ |
71ad0f5e | 82 | #endif /* __UNWIND_H */ |