blob: 84c6d44d52f98d9c6c7e4997ab6f812f68b414f8 [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);
He Kuangd64ec102016-06-03 03:33:19 +000045int unwind__prepare_access(struct thread *thread, struct map *map);
Namhyung Kim380b5142014-10-06 09:46:01 +090046void unwind__flush_access(struct thread *thread);
Namhyung Kim66f066d82014-10-06 09:46:00 +090047void unwind__finish_access(struct thread *thread);
48#else
He Kuangd64ec102016-06-03 03:33:19 +000049static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
50 struct map *map __maybe_unused)
Namhyung Kim66f066d82014-10-06 09:46:00 +090051{
52 return 0;
53}
54
Namhyung Kim380b5142014-10-06 09:46:01 +090055static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
Namhyung Kim66f066d82014-10-06 09:46:00 +090056static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
Jiri Olsa9ff125d2014-01-07 13:47:28 +010057#endif
Jiri Olsa71ad0f52012-08-07 15:20:46 +020058#else
59static inline int
Irina Tirdea1d037ca2012-09-11 01:15:03 +030060unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
61 void *arg __maybe_unused,
Irina Tirdea1d037ca2012-09-11 01:15:03 +030062 struct thread *thread __maybe_unused,
Arnaldo Carvalho de Melo37676af2013-11-13 17:40:36 -030063 struct perf_sample *data __maybe_unused,
64 int max_stack __maybe_unused)
Jiri Olsa71ad0f52012-08-07 15:20:46 +020065{
66 return 0;
67}
Namhyung Kim66f066d82014-10-06 09:46:00 +090068
He Kuangd64ec102016-06-03 03:33:19 +000069static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
70 struct map *map __maybe_unused)
Namhyung Kim66f066d82014-10-06 09:46:00 +090071{
72 return 0;
73}
74
Namhyung Kim380b5142014-10-06 09:46:01 +090075static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
Namhyung Kim66f066d82014-10-06 09:46:00 +090076static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
Jiri Olsa9ff125d2014-01-07 13:47:28 +010077#endif /* HAVE_DWARF_UNWIND_SUPPORT */
Jiri Olsa71ad0f52012-08-07 15:20:46 +020078#endif /* __UNWIND_H */