blob: bfbdcc6198c9d85c09f9859866ac7974e8dd61c7 [file] [log] [blame]
Jiri Olsa71ad0f52012-08-07 15:20:46 +02001#ifndef __UNWIND_H
2#define __UNWIND_H
3
Arnaldo Carvalho de Melo3dfed912017-04-19 13:28:30 -03004#include <linux/compiler.h>
Borislav Petkovd944c4e2014-04-25 21:31:02 +02005#include <linux/types.h>
Arnaldo Carvalho de Melo3dfed912017-04-19 13:28:30 -03006
7struct map;
8struct perf_sample;
9struct symbol;
10struct thread;
Jiri Olsa71ad0f52012-08-07 15:20:46 +020011
12struct unwind_entry {
13 struct map *map;
14 struct symbol *sym;
15 u64 ip;
16};
17
18typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg);
19
He Kuangf83c0412016-06-03 03:33:12 +000020struct 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 Olsa9ff125d2014-01-07 13:47:28 +010029#ifdef HAVE_DWARF_UNWIND_SUPPORT
Jiri Olsa71ad0f52012-08-07 15:20:46 +020030int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
Jiri Olsa71ad0f52012-08-07 15:20:46 +020031 struct thread *thread,
Arnaldo Carvalho de Melo37676af2013-11-13 17:40:36 -030032 struct perf_sample *data, int max_stack);
Jiri Olsa9ff125d2014-01-07 13:47:28 +010033/* libunwind specific */
34#ifdef HAVE_LIBUNWIND_SUPPORT
He Kuangeeb118c2016-06-03 03:33:20 +000035#ifndef LIBUNWIND__ARCH_REG_ID
36#define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arch_reg_id(regnum)
37#endif
He Kuang78ff1d62016-06-22 06:57:02 +000038
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 Kuangeeb118c2016-06-03 03:33:20 +000047int LIBUNWIND__ARCH_REG_ID(int regnum);
Jiri Olsaa2873322016-07-04 14:16:22 +020048int unwind__prepare_access(struct thread *thread, struct map *map,
49 bool *initialized);
Namhyung Kim380b5142014-10-06 09:46:01 +090050void unwind__flush_access(struct thread *thread);
Namhyung Kim66f066d82014-10-06 09:46:00 +090051void unwind__finish_access(struct thread *thread);
52#else
He Kuangd64ec102016-06-03 03:33:19 +000053static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
Jiri Olsaa2873322016-07-04 14:16:22 +020054 struct map *map __maybe_unused,
55 bool *initialized __maybe_unused)
Namhyung Kim66f066d82014-10-06 09:46:00 +090056{
57 return 0;
58}
59
Namhyung Kim380b5142014-10-06 09:46:01 +090060static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
Namhyung Kim66f066d82014-10-06 09:46:00 +090061static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
Jiri Olsa9ff125d2014-01-07 13:47:28 +010062#endif
Jiri Olsa71ad0f52012-08-07 15:20:46 +020063#else
64static inline int
Irina Tirdea1d037ca2012-09-11 01:15:03 +030065unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
66 void *arg __maybe_unused,
Irina Tirdea1d037ca2012-09-11 01:15:03 +030067 struct thread *thread __maybe_unused,
Arnaldo Carvalho de Melo37676af2013-11-13 17:40:36 -030068 struct perf_sample *data __maybe_unused,
69 int max_stack __maybe_unused)
Jiri Olsa71ad0f52012-08-07 15:20:46 +020070{
71 return 0;
72}
Namhyung Kim66f066d82014-10-06 09:46:00 +090073
He Kuangd64ec102016-06-03 03:33:19 +000074static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
Jiri Olsaa2873322016-07-04 14:16:22 +020075 struct map *map __maybe_unused,
76 bool *initialized __maybe_unused)
Namhyung Kim66f066d82014-10-06 09:46:00 +090077{
78 return 0;
79}
80
Namhyung Kim380b5142014-10-06 09:46:01 +090081static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
Namhyung Kim66f066d82014-10-06 09:46:00 +090082static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
Jiri Olsa9ff125d2014-01-07 13:47:28 +010083#endif /* HAVE_DWARF_UNWIND_SUPPORT */
Jiri Olsa71ad0f52012-08-07 15:20:46 +020084#endif /* __UNWIND_H */