Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __UNWIND_H
3#define __UNWIND_H
4
5#include <linux/compiler.h>
6#include <linux/types.h>
7#include "util/map_symbol.h"
8
9struct maps;
10struct perf_sample;
11struct thread;
12
13struct unwind_entry {
14 struct map_symbol ms;
15 u64 ip;
16};
17
18typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg);
19
20struct unwind_libunwind_ops {
21 int (*prepare_access)(struct maps *maps);
22 void (*flush_access)(struct maps *maps);
23 void (*finish_access)(struct maps *maps);
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
29#ifdef HAVE_DWARF_UNWIND_SUPPORT
30int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
31 struct thread *thread,
32 struct perf_sample *data, int max_stack);
33/* libunwind specific */
34#ifdef HAVE_LIBUNWIND_SUPPORT
35#ifndef LIBUNWIND__ARCH_REG_ID
36#define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arch_reg_id(regnum)
37#endif
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
47int LIBUNWIND__ARCH_REG_ID(int regnum);
48int unwind__prepare_access(struct maps *maps, struct map *map, bool *initialized);
49void unwind__flush_access(struct maps *maps);
50void unwind__finish_access(struct maps *maps);
51#else
52static inline int unwind__prepare_access(struct maps *maps __maybe_unused,
53 struct map *map __maybe_unused,
54 bool *initialized __maybe_unused)
55{
56 return 0;
57}
58
59static inline void unwind__flush_access(struct maps *maps __maybe_unused) {}
60static inline void unwind__finish_access(struct maps *maps __maybe_unused) {}
61#endif
62#else
63static inline int
64unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
65 void *arg __maybe_unused,
66 struct thread *thread __maybe_unused,
67 struct perf_sample *data __maybe_unused,
68 int max_stack __maybe_unused)
69{
70 return 0;
71}
72
73static inline int unwind__prepare_access(struct maps *maps __maybe_unused,
74 struct map *map __maybe_unused,
75 bool *initialized __maybe_unused)
76{
77 return 0;
78}
79
80static inline void unwind__flush_access(struct maps *maps __maybe_unused) {}
81static inline void unwind__finish_access(struct maps *maps __maybe_unused) {}
82#endif /* HAVE_DWARF_UNWIND_SUPPORT */
83#endif /* __UNWIND_H */
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __UNWIND_H
3#define __UNWIND_H
4
5#include <linux/compiler.h>
6#include <linux/types.h>
7
8struct map;
9struct perf_sample;
10struct symbol;
11struct thread;
12
13struct unwind_entry {
14 struct map *map;
15 struct symbol *sym;
16 u64 ip;
17};
18
19typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg);
20
21struct 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
30#ifdef HAVE_DWARF_UNWIND_SUPPORT
31int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
32 struct thread *thread,
33 struct perf_sample *data, int max_stack);
34/* libunwind specific */
35#ifdef HAVE_LIBUNWIND_SUPPORT
36#ifndef LIBUNWIND__ARCH_REG_ID
37#define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arch_reg_id(regnum)
38#endif
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
48int LIBUNWIND__ARCH_REG_ID(int regnum);
49int unwind__prepare_access(struct thread *thread, struct map *map,
50 bool *initialized);
51void unwind__flush_access(struct thread *thread);
52void unwind__finish_access(struct thread *thread);
53#else
54static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
55 struct map *map __maybe_unused,
56 bool *initialized __maybe_unused)
57{
58 return 0;
59}
60
61static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
62static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
63#endif
64#else
65static inline int
66unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
67 void *arg __maybe_unused,
68 struct thread *thread __maybe_unused,
69 struct perf_sample *data __maybe_unused,
70 int max_stack __maybe_unused)
71{
72 return 0;
73}
74
75static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
76 struct map *map __maybe_unused,
77 bool *initialized __maybe_unused)
78{
79 return 0;
80}
81
82static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
83static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
84#endif /* HAVE_DWARF_UNWIND_SUPPORT */
85#endif /* __UNWIND_H */