unwind.h 2.0 KB
Newer Older
1 2 3
#ifndef __UNWIND_H
#define __UNWIND_H

B
Borislav Petkov 已提交
4
#include <linux/types.h>
5 6
#include "event.h"
#include "symbol.h"
7
#include "thread.h"
8 9 10 11 12 13 14 15 16

struct unwind_entry {
	struct map	*map;
	struct symbol	*sym;
	u64		ip;
};

typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg);

17 18 19 20 21 22 23 24 25
struct unwind_libunwind_ops {
	int (*prepare_access)(struct thread *thread);
	void (*flush_access)(struct thread *thread);
	void (*finish_access)(struct thread *thread);
	int (*get_entries)(unwind_entry_cb_t cb, void *arg,
			   struct thread *thread,
			   struct perf_sample *data, int max_stack);
};

26
#ifdef HAVE_DWARF_UNWIND_SUPPORT
27 28
int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
			struct thread *thread,
29
			struct perf_sample *data, int max_stack);
30 31
/* libunwind specific */
#ifdef HAVE_LIBUNWIND_SUPPORT
32 33 34 35
#ifndef LIBUNWIND__ARCH_REG_ID
#define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arch_reg_id(regnum)
#endif
int LIBUNWIND__ARCH_REG_ID(int regnum);
36
int unwind__prepare_access(struct thread *thread, struct map *map);
37
void unwind__flush_access(struct thread *thread);
38 39
void unwind__finish_access(struct thread *thread);
#else
40 41
static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
					 struct map *map __maybe_unused)
42 43 44 45
{
	return 0;
}

46
static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
47
static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
48
#endif
49 50
#else
static inline int
51 52 53
unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
		    void *arg __maybe_unused,
		    struct thread *thread __maybe_unused,
54 55
		    struct perf_sample *data __maybe_unused,
		    int max_stack __maybe_unused)
56 57 58
{
	return 0;
}
59

60 61
static inline int unwind__prepare_access(struct thread *thread __maybe_unused,
					 struct map *map __maybe_unused)
62 63 64 65
{
	return 0;
}

66
static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
67
static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
68
#endif /* HAVE_DWARF_UNWIND_SUPPORT */
69
#endif /* __UNWIND_H */