blob: bf9f5937caee17b6eb64f771bf946e26b8fdac7e [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
Jiri Olsaea3da692014-01-07 13:47:27 +010032int libunwind__arch_reg_id(int regnum);
He Kuangd64ec102016-06-03 03:33:19 +000033int unwind__prepare_access(struct thread *thread, struct map *map);
Namhyung Kim380b5142014-10-06 09:46:01 +090034void unwind__flush_access(struct thread *thread);
Namhyung Kim66f066d82014-10-06 09:46:00 +090035void unwind__finish_access(struct thread *thread);
36#else
He Kuangd64ec102016-06-03 03:33:19 +000037static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
38 struct map *map __maybe_unused)
Namhyung Kim66f066d82014-10-06 09:46:00 +090039{
40 return 0;
41}
42
Namhyung Kim380b5142014-10-06 09:46:01 +090043static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
Namhyung Kim66f066d82014-10-06 09:46:00 +090044static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
Jiri Olsa9ff125d2014-01-07 13:47:28 +010045#endif
Jiri Olsa71ad0f52012-08-07 15:20:46 +020046#else
47static inline int
Irina Tirdea1d037ca2012-09-11 01:15:03 +030048unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
49 void *arg __maybe_unused,
Irina Tirdea1d037ca2012-09-11 01:15:03 +030050 struct thread *thread __maybe_unused,
Arnaldo Carvalho de Melo37676af2013-11-13 17:40:36 -030051 struct perf_sample *data __maybe_unused,
52 int max_stack __maybe_unused)
Jiri Olsa71ad0f52012-08-07 15:20:46 +020053{
54 return 0;
55}
Namhyung Kim66f066d82014-10-06 09:46:00 +090056
He Kuangd64ec102016-06-03 03:33:19 +000057static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
58 struct map *map __maybe_unused)
Namhyung Kim66f066d82014-10-06 09:46:00 +090059{
60 return 0;
61}
62
Namhyung Kim380b5142014-10-06 09:46:01 +090063static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
Namhyung Kim66f066d82014-10-06 09:46:00 +090064static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
Jiri Olsa9ff125d2014-01-07 13:47:28 +010065#endif /* HAVE_DWARF_UNWIND_SUPPORT */
Jiri Olsa71ad0f52012-08-07 15:20:46 +020066#endif /* __UNWIND_H */