1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __PERF_MAPS_H 3 #define __PERF_MAPS_H 4 5 #include <linux/refcount.h> 6 #include <stdio.h> 7 #include <stdbool.h> 8 #include <linux/types.h> 9 10 struct ref_reloc_sym; 11 struct machine; 12 struct map; 13 struct maps; 14 15 #define KMAP_NAME_LEN 256 16 17 struct kmap { 18 struct ref_reloc_sym *ref_reloc_sym; 19 struct maps *kmaps; 20 char name[KMAP_NAME_LEN]; 21 }; 22 23 struct maps *maps__new(struct machine *machine); 24 bool maps__empty(struct maps *maps); 25 int maps__copy_from(struct maps *maps, struct maps *parent); 26 27 struct maps *maps__get(struct maps *maps); 28 void maps__put(struct maps *maps); 29 30 static inline void __maps__zput(struct maps **map) 31 { 32 maps__put(*map); 33 *map = NULL; 34 } 35 36 #define maps__zput(map) __maps__zput(&map) 37 38 bool maps__equal(struct maps *a, struct maps *b); 39 40 /* Iterate over map calling cb for each entry. */ 41 int maps__for_each_map(struct maps *maps, int (*cb)(struct map *map, void *data), void *data); 42 /* Iterate over map removing an entry if cb returns true. */ 43 void maps__remove_maps(struct maps *maps, bool (*cb)(struct map *map, void *data), void *data); 44 45 struct machine *maps__machine(const struct maps *maps); 46 unsigned int maps__nr_maps(const struct maps *maps); /* Test only. */ 47 refcount_t *maps__refcnt(struct maps *maps); /* Test only. */ 48 49 #ifdef HAVE_LIBUNWIND_SUPPORT 50 void *maps__addr_space(const struct maps *maps); 51 void maps__set_addr_space(struct maps *maps, void *addr_space); 52 uint16_t maps__e_machine(const struct maps *maps); 53 void maps__set_e_machine(struct maps *maps, uint16_t e_machine); 54 #endif 55 #ifdef HAVE_LIBDW_SUPPORT 56 void *maps__libdw_addr_space_dwfl(const struct maps *maps); 57 void maps__set_libdw_addr_space_dwfl(struct maps *maps, void *dwfl); 58 #endif 59 60 size_t maps__fprintf(struct maps *maps, FILE *fp); 61 62 int maps__load_maps(struct maps *maps); 63 int maps__insert(struct maps *maps, struct map *map); 64 void maps__remove(struct maps *maps, struct map *map); 65 int maps__mutate_mapping(struct maps *maps, struct map *map, 66 int (*mutate_cb)(struct map *map, void *data), void *data); 67 68 struct map *maps__find(struct maps *maps, u64 addr); 69 struct symbol *maps__find_symbol(struct maps *maps, u64 addr, struct map **mapp); 70 struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, struct map **mapp); 71 72 struct addr_map_symbol; 73 74 int maps__find_ams(struct maps *maps, struct addr_map_symbol *ams); 75 76 int maps__fixup_overlap_and_insert(struct maps *maps, struct map *new); 77 78 struct map *maps__find_by_name(struct maps *maps, const char *name); 79 80 struct map *maps__find_next_entry(struct maps *maps, struct map *map); 81 82 int maps__merge_in(struct maps *kmaps, struct map *new_map); 83 84 void maps__fixup_end(struct maps *maps); 85 86 void maps__load_first(struct maps *maps); 87 88 #endif // __PERF_MAPS_H 89