Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 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; |
Arnaldo Carvalho de Melo | 9de89fe | 2010-02-03 16:52:00 -0200 | [diff] [blame] | 17 | struct ref_reloc_sym; |
| 18 | struct map_groups; |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 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; |
Kirill Smelkov | 7a2b620 | 2010-02-03 16:52:07 -0200 | [diff] [blame] | 29 | |
| 30 | /* ip -> dso rip */ |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 31 | u64 (*map_ip)(struct map *, u64); |
Kirill Smelkov | 7a2b620 | 2010-02-03 16:52:07 -0200 | [diff] [blame] | 32 | /* dso rip -> ip */ |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 33 | u64 (*unmap_ip)(struct map *, u64); |
Kirill Smelkov | 7a2b620 | 2010-02-03 16:52:07 -0200 | [diff] [blame] | 34 | |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 35 | struct dso *dso; |
| 36 | }; |
| 37 | |
Arnaldo Carvalho de Melo | 9de89fe | 2010-02-03 16:52:00 -0200 | [diff] [blame] | 38 | struct kmap { |
| 39 | struct ref_reloc_sym *ref_reloc_sym; |
| 40 | struct map_groups *kmaps; |
| 41 | }; |
| 42 | |
| 43 | static inline struct kmap *map__kmap(struct map *self) |
| 44 | { |
| 45 | return (struct kmap *)(self + 1); |
| 46 | } |
| 47 | |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 48 | static inline u64 map__map_ip(struct map *map, u64 ip) |
| 49 | { |
| 50 | return ip - map->start + map->pgoff; |
| 51 | } |
| 52 | |
| 53 | static inline u64 map__unmap_ip(struct map *map, u64 ip) |
| 54 | { |
| 55 | return ip + map->start - map->pgoff; |
| 56 | } |
| 57 | |
| 58 | static inline u64 identity__map_ip(struct map *map __used, u64 ip) |
| 59 | { |
| 60 | return ip; |
| 61 | } |
| 62 | |
Kirill Smelkov | 7a2b620 | 2010-02-03 16:52:07 -0200 | [diff] [blame] | 63 | |
Kirill Smelkov | ee11b90 | 2010-02-07 11:46:15 -0200 | [diff] [blame^] | 64 | /* rip/ip <-> addr suitable for passing to `objdump --start-address=` */ |
Kirill Smelkov | 7a2b620 | 2010-02-03 16:52:07 -0200 | [diff] [blame] | 65 | u64 map__rip_2objdump(struct map *map, u64 rip); |
Kirill Smelkov | ee11b90 | 2010-02-07 11:46:15 -0200 | [diff] [blame^] | 66 | u64 map__objdump_2ip(struct map *map, u64 addr); |
Kirill Smelkov | 7a2b620 | 2010-02-03 16:52:07 -0200 | [diff] [blame] | 67 | |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 68 | struct symbol; |
| 69 | struct mmap_event; |
| 70 | |
| 71 | typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); |
| 72 | |
| 73 | void map__init(struct map *self, enum map_type type, |
| 74 | u64 start, u64 end, u64 pgoff, struct dso *dso); |
| 75 | struct map *map__new(struct mmap_event *event, enum map_type, |
| 76 | char *cwd, int cwdlen); |
| 77 | void map__delete(struct map *self); |
| 78 | struct map *map__clone(struct map *self); |
| 79 | int map__overlap(struct map *l, struct map *r); |
| 80 | size_t map__fprintf(struct map *self, FILE *fp); |
| 81 | |
Arnaldo Carvalho de Melo | 9de89fe | 2010-02-03 16:52:00 -0200 | [diff] [blame] | 82 | int map__load(struct map *self, symbol_filter_t filter); |
| 83 | struct symbol *map__find_symbol(struct map *self, |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 84 | u64 addr, symbol_filter_t filter); |
| 85 | struct symbol *map__find_symbol_by_name(struct map *self, const char *name, |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 86 | symbol_filter_t filter); |
| 87 | void map__fixup_start(struct map *self); |
| 88 | void map__fixup_end(struct map *self); |
| 89 | |
Arnaldo Carvalho de Melo | 9de89fe | 2010-02-03 16:52:00 -0200 | [diff] [blame] | 90 | void map__reloc_vmlinux(struct map *self); |
| 91 | |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 92 | #endif /* __PERF_MAP_H */ |