Commit | Line | Data |
---|---|---|
4a58e611 ACM |
1 | #ifndef __PERF_MAP_H |
2 | #define __PERF_MAP_H | |
3 | ||
4 | #include <linux/compiler.h> | |
5 | #include <linux/list.h> | |
6 | #include <linux/rbtree.h> | |
7 | #include <linux/types.h> | |
8 | ||
9 | enum map_type { | |
10 | MAP__FUNCTION = 0, | |
11 | MAP__VARIABLE, | |
12 | }; | |
13 | ||
14 | #define MAP__NR_TYPES (MAP__VARIABLE + 1) | |
15 | ||
16 | struct dso; | |
9de89fe7 ACM |
17 | struct ref_reloc_sym; |
18 | struct map_groups; | |
4a58e611 ACM |
19 | |
20 | struct map { | |
21 | union { | |
22 | struct rb_node rb_node; | |
23 | struct list_head node; | |
24 | }; | |
25 | u64 start; | |
26 | u64 end; | |
27 | enum map_type type; | |
28 | u64 pgoff; | |
29 | u64 (*map_ip)(struct map *, u64); | |
30 | u64 (*unmap_ip)(struct map *, u64); | |
31 | struct dso *dso; | |
32 | }; | |
33 | ||
9de89fe7 ACM |
34 | struct kmap { |
35 | struct ref_reloc_sym *ref_reloc_sym; | |
36 | struct map_groups *kmaps; | |
37 | }; | |
38 | ||
39 | static inline struct kmap *map__kmap(struct map *self) | |
40 | { | |
41 | return (struct kmap *)(self + 1); | |
42 | } | |
43 | ||
4a58e611 ACM |
44 | static inline u64 map__map_ip(struct map *map, u64 ip) |
45 | { | |
46 | return ip - map->start + map->pgoff; | |
47 | } | |
48 | ||
49 | static inline u64 map__unmap_ip(struct map *map, u64 ip) | |
50 | { | |
51 | return ip + map->start - map->pgoff; | |
52 | } | |
53 | ||
54 | static inline u64 identity__map_ip(struct map *map __used, u64 ip) | |
55 | { | |
56 | return ip; | |
57 | } | |
58 | ||
59 | struct symbol; | |
60 | struct mmap_event; | |
61 | ||
62 | typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); | |
63 | ||
64 | void map__init(struct map *self, enum map_type type, | |
65 | u64 start, u64 end, u64 pgoff, struct dso *dso); | |
66 | struct map *map__new(struct mmap_event *event, enum map_type, | |
67 | char *cwd, int cwdlen); | |
68 | void map__delete(struct map *self); | |
69 | struct map *map__clone(struct map *self); | |
70 | int map__overlap(struct map *l, struct map *r); | |
71 | size_t map__fprintf(struct map *self, FILE *fp); | |
72 | ||
9de89fe7 ACM |
73 | int map__load(struct map *self, symbol_filter_t filter); |
74 | struct symbol *map__find_symbol(struct map *self, | |
4a58e611 ACM |
75 | u64 addr, symbol_filter_t filter); |
76 | struct symbol *map__find_symbol_by_name(struct map *self, const char *name, | |
4a58e611 ACM |
77 | symbol_filter_t filter); |
78 | void map__fixup_start(struct map *self); | |
79 | void map__fixup_end(struct map *self); | |
80 | ||
9de89fe7 ACM |
81 | void map__reloc_vmlinux(struct map *self); |
82 | ||
4a58e611 | 83 | #endif /* __PERF_MAP_H */ |