1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/refcount.h>
6 #include <linux/rbtree.h>
9 #include <linux/types.h>
19 struct rb_node rb_node;
23 struct map_rb_node *maps__first(struct maps *maps);
24 struct map_rb_node *map_rb_node__next(struct map_rb_node *node);
25 struct map_rb_node *maps__find_node(struct maps *maps, struct map *map);
26 struct map *maps__find(struct maps *maps, u64 addr);
28 #define maps__for_each_entry(maps, map) \
29 for (map = maps__first(maps); map; map = map_rb_node__next(map))
31 #define maps__for_each_entry_safe(maps, map, next) \
32 for (map = maps__first(maps), next = map_rb_node__next(map); map; \
33 map = next, next = map_rb_node__next(map))
36 struct rb_root entries;
37 struct rw_semaphore lock;
38 struct machine *machine;
39 struct map *last_search_by_name;
40 struct map **maps_by_name;
43 unsigned int nr_maps_allocated;
44 #ifdef HAVE_LIBUNWIND_SUPPORT
46 const struct unwind_libunwind_ops *unwind_libunwind_ops;
50 #define KMAP_NAME_LEN 256
53 struct ref_reloc_sym *ref_reloc_sym;
55 char name[KMAP_NAME_LEN];
58 struct maps *maps__new(struct machine *machine);
59 void maps__delete(struct maps *maps);
60 bool maps__empty(struct maps *maps);
61 int maps__clone(struct thread *thread, struct maps *parent);
63 struct maps *maps__get(struct maps *maps);
64 void maps__put(struct maps *maps);
66 static inline struct rb_root *maps__entries(struct maps *maps)
68 return &maps->entries;
71 static inline struct machine *maps__machine(struct maps *maps)
76 static inline struct rw_semaphore *maps__lock(struct maps *maps)
81 static inline struct map **maps__maps_by_name(struct maps *maps)
83 return maps->maps_by_name;
86 static inline unsigned int maps__nr_maps(const struct maps *maps)
91 static inline refcount_t *maps__refcnt(struct maps *maps)
96 #ifdef HAVE_LIBUNWIND_SUPPORT
97 static inline void *maps__addr_space(struct maps *maps)
99 return maps->addr_space;
102 static inline const struct unwind_libunwind_ops *maps__unwind_libunwind_ops(const struct maps *maps)
104 return maps->unwind_libunwind_ops;
108 size_t maps__fprintf(struct maps *maps, FILE *fp);
110 int maps__insert(struct maps *maps, struct map *map);
111 void maps__remove(struct maps *maps, struct map *map);
113 struct symbol *maps__find_symbol(struct maps *maps, u64 addr, struct map **mapp);
114 struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, struct map **mapp);
116 struct addr_map_symbol;
118 int maps__find_ams(struct maps *maps, struct addr_map_symbol *ams);
120 int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp);
122 struct map *maps__find_by_name(struct maps *maps, const char *name);
124 int maps__merge_in(struct maps *kmaps, struct map *new_map);
126 void __maps__sort_by_name(struct maps *maps);
128 #endif // __PERF_MAPS_H