maps.h 2.6 KB

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