blob: 61fb1e90ff5166c6c1f50f8446650cf302aa610d [file] [log] [blame]
Jiri Olsa71ad0f52012-08-07 15:20:46 +02001#ifndef __UNWIND_H
2#define __UNWIND_H
3
Borislav Petkovd944c4e2014-04-25 21:31:02 +02004#include <linux/types.h>
Jiri Olsa71ad0f52012-08-07 15:20:46 +02005#include "event.h"
6#include "symbol.h"
Namhyung Kim66f066d82014-10-06 09:46:00 +09007#include "thread.h"
Jiri Olsa71ad0f52012-08-07 15:20:46 +02008
9struct unwind_entry {
10 struct map *map;
11 struct symbol *sym;
12 u64 ip;
13};
14
15typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg);
16
He Kuangf83c0412016-06-03 03:33:12 +000017struct unwind_libunwind_ops {
18 int (*prepare_access)(struct thread *thread);
19 void (*flush_access)(struct thread *thread);
20 void (*finish_access)(struct thread *thread);
21 int (*get_entries)(unwind_entry_cb_t cb, void *arg,
22 struct thread *thread,
23 struct perf_sample *data, int max_stack);
24};
25
Jiri Olsa9ff125d2014-01-07 13:47:28 +010026#ifdef HAVE_DWARF_UNWIND_SUPPORT
Jiri Olsa71ad0f52012-08-07 15:20:46 +020027int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
Jiri Olsa71ad0f52012-08-07 15:20:46 +020028 struct thread *thread,
Arnaldo Carvalho de Melo37676af2013-11-13 17:40:36 -030029 struct perf_sample *data, int max_stack);
Jiri Olsa9ff125d2014-01-07 13:47:28 +010030/* libunwind specific */
31#ifdef HAVE_LIBUNWIND_SUPPORT
He Kuangeeb118c2016-06-03 03:33:20 +000032#ifndef LIBUNWIND__ARCH_REG_ID
33#define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arch_reg_id(regnum)
34#endif
He Kuang78ff1d62016-06-22 06:57:02 +000035
36#ifndef LIBUNWIND__ARCH_REG_SP
37#define LIBUNWIND__ARCH_REG_SP PERF_REG_SP
38#endif
39
40#ifndef LIBUNWIND__ARCH_REG_IP
41#define LIBUNWIND__ARCH_REG_IP PERF_REG_IP
42#endif
43
He Kuangeeb118c2016-06-03 03:33:20 +000044int LIBUNWIND__ARCH_REG_ID(int regnum);
Jiri Olsaa2873322016-07-04 14:16:22 +020045int unwind__prepare_access(struct thread *thread, struct map *map,
46 bool *initialized);
Namhyung Kim380b5142014-10-06 09:46:01 +090047void unwind__flush_access(struct thread *thread);
Namhyung Kim66f066d82014-10-06 09:46:00 +090048void unwind__finish_access(struct thread *thread);
49#else
He Kuangd64ec102016-06-03 03:33:19 +000050static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
Jiri Olsaa2873322016-07-04 14:16:22 +020051 struct map *map __maybe_unused,
52 bool *initialized __maybe_unused)
Namhyung Kim66f066d82014-10-06 09:46:00 +090053{
54 return 0;
55}
56
Namhyung Kim380b5142014-10-06 09:46:01 +090057static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
Namhyung Kim66f066d82014-10-06 09:46:00 +090058static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
Jiri Olsa9ff125d2014-01-07 13:47:28 +010059#endif
Jiri Olsa71ad0f52012-08-07 15:20:46 +020060#else
61static inline int
Irina Tirdea1d037ca2012-09-11 01:15:03 +030062unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
63 void *arg __maybe_unused,
Irina Tirdea1d037ca2012-09-11 01:15:03 +030064 struct thread *thread __maybe_unused,
Arnaldo Carvalho de Melo37676af2013-11-13 17:40:36 -030065 struct perf_sample *data __maybe_unused,
66 int max_stack __maybe_unused)
Jiri Olsa71ad0f52012-08-07 15:20:46 +020067{
68 return 0;
69}
Namhyung Kim66f066d82014-10-06 09:46:00 +090070
He Kuangd64ec102016-06-03 03:33:19 +000071static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
Jiri Olsaa2873322016-07-04 14:16:22 +020072 struct map *map __maybe_unused,
73 bool *initialized __maybe_unused)
Namhyung Kim66f066d82014-10-06 09:46:00 +090074{
75 return 0;
76}
77
Namhyung Kim380b5142014-10-06 09:46:01 +090078static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
Namhyung Kim66f066d82014-10-06 09:46:00 +090079static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
Jiri Olsa9ff125d2014-01-07 13:47:28 +010080#endif /* HAVE_DWARF_UNWIND_SUPPORT */
Jiri Olsa71ad0f52012-08-07 15:20:46 +020081#endif /* __UNWIND_H */