blob: b074662403464278976d3ced8c2b999670223e91 [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
35int LIBUNWIND__ARCH_REG_ID(int regnum);
He Kuangd64ec102016-06-03 03:33:19 +000036int unwind__prepare_access(struct thread *thread, struct map *map);
Namhyung Kim380b5142014-10-06 09:46:01 +090037void unwind__flush_access(struct thread *thread);
Namhyung Kim66f066d82014-10-06 09:46:00 +090038void unwind__finish_access(struct thread *thread);
39#else
He Kuangd64ec102016-06-03 03:33:19 +000040static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
41 struct map *map __maybe_unused)
Namhyung Kim66f066d82014-10-06 09:46:00 +090042{
43 return 0;
44}
45
Namhyung Kim380b5142014-10-06 09:46:01 +090046static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
Namhyung Kim66f066d82014-10-06 09:46:00 +090047static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
Jiri Olsa9ff125d2014-01-07 13:47:28 +010048#endif
Jiri Olsa71ad0f52012-08-07 15:20:46 +020049#else
50static inline int
Irina Tirdea1d037ca2012-09-11 01:15:03 +030051unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
52 void *arg __maybe_unused,
Irina Tirdea1d037ca2012-09-11 01:15:03 +030053 struct thread *thread __maybe_unused,
Arnaldo Carvalho de Melo37676af2013-11-13 17:40:36 -030054 struct perf_sample *data __maybe_unused,
55 int max_stack __maybe_unused)
Jiri Olsa71ad0f52012-08-07 15:20:46 +020056{
57 return 0;
58}
Namhyung Kim66f066d82014-10-06 09:46:00 +090059
He Kuangd64ec102016-06-03 03:33:19 +000060static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
61 struct map *map __maybe_unused)
Namhyung Kim66f066d82014-10-06 09:46:00 +090062{
63 return 0;
64}
65
Namhyung Kim380b5142014-10-06 09:46:01 +090066static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
Namhyung Kim66f066d82014-10-06 09:46:00 +090067static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
Jiri Olsa9ff125d2014-01-07 13:47:28 +010068#endif /* HAVE_DWARF_UNWIND_SUPPORT */
Jiri Olsa71ad0f52012-08-07 15:20:46 +020069#endif /* __UNWIND_H */