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, | |
26 | struct perf_sample *data, int max_stack); | |
27 | }; | |
28 | ||
9ff125d1 | 29 | #ifdef HAVE_DWARF_UNWIND_SUPPORT |
71ad0f5e | 30 | int unwind__get_entries(unwind_entry_cb_t cb, void *arg, |
71ad0f5e | 31 | struct thread *thread, |
37676af1 | 32 | struct perf_sample *data, int max_stack); |
9ff125d1 JO |
33 | /* libunwind specific */ |
34 | #ifdef HAVE_LIBUNWIND_SUPPORT | |
eeb118c5 HK |
35 | #ifndef LIBUNWIND__ARCH_REG_ID |
36 | #define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arch_reg_id(regnum) | |
37 | #endif | |
78ff1d6d HK |
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 | ||
eeb118c5 | 47 | int LIBUNWIND__ARCH_REG_ID(int regnum); |
79b6bb73 ACM |
48 | int unwind__prepare_access(struct maps *maps, struct map *map, bool *initialized); |
49 | void unwind__flush_access(struct maps *maps); | |
50 | void unwind__finish_access(struct maps *maps); | |
66f066d8 | 51 | #else |
79b6bb73 | 52 | static inline int unwind__prepare_access(struct maps *maps __maybe_unused, |
a2873325 JO |
53 | struct map *map __maybe_unused, |
54 | bool *initialized __maybe_unused) | |
66f066d8 NK |
55 | { |
56 | return 0; | |
57 | } | |
58 | ||
79b6bb73 ACM |
59 | static inline void unwind__flush_access(struct maps *maps __maybe_unused) {} |
60 | static inline void unwind__finish_access(struct maps *maps __maybe_unused) {} | |
9ff125d1 | 61 | #endif |
71ad0f5e JO |
62 | #else |
63 | static inline int | |
1d037ca1 IT |
64 | unwind__get_entries(unwind_entry_cb_t cb __maybe_unused, |
65 | void *arg __maybe_unused, | |
1d037ca1 | 66 | struct thread *thread __maybe_unused, |
37676af1 ACM |
67 | struct perf_sample *data __maybe_unused, |
68 | int max_stack __maybe_unused) | |
71ad0f5e JO |
69 | { |
70 | return 0; | |
71 | } | |
66f066d8 | 72 | |
79b6bb73 | 73 | static inline int unwind__prepare_access(struct maps *maps __maybe_unused, |
a2873325 JO |
74 | struct map *map __maybe_unused, |
75 | bool *initialized __maybe_unused) | |
66f066d8 NK |
76 | { |
77 | return 0; | |
78 | } | |
79 | ||
79b6bb73 ACM |
80 | static inline void unwind__flush_access(struct maps *maps __maybe_unused) {} |
81 | static inline void unwind__finish_access(struct maps *maps __maybe_unused) {} | |
9ff125d1 | 82 | #endif /* HAVE_DWARF_UNWIND_SUPPORT */ |
71ad0f5e | 83 | #endif /* __UNWIND_H */ |