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; |
| 17 | |
| 18 | struct map { |
| 19 | union { |
| 20 | struct rb_node rb_node; |
| 21 | struct list_head node; |
| 22 | }; |
| 23 | u64 start; |
| 24 | u64 end; |
| 25 | enum map_type type; |
| 26 | u64 pgoff; |
| 27 | u64 (*map_ip)(struct map *, u64); |
| 28 | u64 (*unmap_ip)(struct map *, u64); |
| 29 | struct dso *dso; |
| 30 | }; |
| 31 | |
| 32 | static inline u64 map__map_ip(struct map *map, u64 ip) |
| 33 | { |
| 34 | return ip - map->start + map->pgoff; |
| 35 | } |
| 36 | |
| 37 | static inline u64 map__unmap_ip(struct map *map, u64 ip) |
| 38 | { |
| 39 | return ip + map->start - map->pgoff; |
| 40 | } |
| 41 | |
| 42 | static inline u64 identity__map_ip(struct map *map __used, u64 ip) |
| 43 | { |
| 44 | return ip; |
| 45 | } |
| 46 | |
| 47 | struct symbol; |
| 48 | struct mmap_event; |
| 49 | |
| 50 | typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); |
| 51 | |
| 52 | void map__init(struct map *self, enum map_type type, |
| 53 | u64 start, u64 end, u64 pgoff, struct dso *dso); |
| 54 | struct map *map__new(struct mmap_event *event, enum map_type, |
| 55 | char *cwd, int cwdlen); |
| 56 | void map__delete(struct map *self); |
| 57 | struct map *map__clone(struct map *self); |
| 58 | int map__overlap(struct map *l, struct map *r); |
| 59 | size_t map__fprintf(struct map *self, FILE *fp); |
| 60 | |
| 61 | struct perf_session; |
| 62 | |
| 63 | int map__load(struct map *self, struct perf_session *session, |
| 64 | symbol_filter_t filter); |
| 65 | struct symbol *map__find_symbol(struct map *self, struct perf_session *session, |
| 66 | u64 addr, symbol_filter_t filter); |
| 67 | struct symbol *map__find_symbol_by_name(struct map *self, const char *name, |
| 68 | struct perf_session *session, |
| 69 | symbol_filter_t filter); |
| 70 | void map__fixup_start(struct map *self); |
| 71 | void map__fixup_end(struct map *self); |
| 72 | |
| 73 | #endif /* __PERF_MAP_H */ |