0001
0002 #ifndef __PERF_MAPS_H
0003 #define __PERF_MAPS_H
0004
0005 #include <linux/refcount.h>
0006 #include <linux/rbtree.h>
0007 #include <stdio.h>
0008 #include <stdbool.h>
0009 #include <linux/types.h>
0010 #include "rwsem.h"
0011
0012 struct ref_reloc_sym;
0013 struct machine;
0014 struct map;
0015 struct maps;
0016 struct thread;
0017
0018 struct map *maps__find(struct maps *maps, u64 addr);
0019 struct map *maps__first(struct maps *maps);
0020 struct map *map__next(struct map *map);
0021
0022 #define maps__for_each_entry(maps, map) \
0023 for (map = maps__first(maps); map; map = map__next(map))
0024
0025 #define maps__for_each_entry_safe(maps, map, next) \
0026 for (map = maps__first(maps), next = map__next(map); map; map = next, next = map__next(map))
0027
0028 struct maps {
0029 struct rb_root entries;
0030 struct rw_semaphore lock;
0031 struct machine *machine;
0032 struct map *last_search_by_name;
0033 struct map **maps_by_name;
0034 refcount_t refcnt;
0035 unsigned int nr_maps;
0036 unsigned int nr_maps_allocated;
0037 #ifdef HAVE_LIBUNWIND_SUPPORT
0038 void *addr_space;
0039 struct unwind_libunwind_ops *unwind_libunwind_ops;
0040 #endif
0041 };
0042
0043 #define KMAP_NAME_LEN 256
0044
0045 struct kmap {
0046 struct ref_reloc_sym *ref_reloc_sym;
0047 struct maps *kmaps;
0048 char name[KMAP_NAME_LEN];
0049 };
0050
0051 struct maps *maps__new(struct machine *machine);
0052 void maps__delete(struct maps *maps);
0053 bool maps__empty(struct maps *maps);
0054
0055 static inline struct maps *maps__get(struct maps *maps)
0056 {
0057 if (maps)
0058 refcount_inc(&maps->refcnt);
0059 return maps;
0060 }
0061
0062 void maps__put(struct maps *maps);
0063 int maps__clone(struct thread *thread, struct maps *parent);
0064 size_t maps__fprintf(struct maps *maps, FILE *fp);
0065
0066 void maps__insert(struct maps *maps, struct map *map);
0067
0068 void maps__remove(struct maps *maps, struct map *map);
0069
0070 struct symbol *maps__find_symbol(struct maps *maps, u64 addr, struct map **mapp);
0071 struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, struct map **mapp);
0072
0073 struct addr_map_symbol;
0074
0075 int maps__find_ams(struct maps *maps, struct addr_map_symbol *ams);
0076
0077 int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp);
0078
0079 struct map *maps__find_by_name(struct maps *maps, const char *name);
0080
0081 int maps__merge_in(struct maps *kmaps, struct map *new_map);
0082
0083 void __maps__sort_by_name(struct maps *maps);
0084
0085 #endif