linux/tools/perf/util/map_groups.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2#ifndef __PERF_MAP_GROUPS_H
   3#define __PERF_MAP_GROUPS_H
   4
   5#include <linux/refcount.h>
   6#include <linux/rbtree.h>
   7#include <stdio.h>
   8#include <stdbool.h>
   9#include <linux/types.h>
  10#include "rwsem.h"
  11
  12struct ref_reloc_sym;
  13struct machine;
  14struct map;
  15struct thread;
  16
  17struct maps {
  18        struct rb_root      entries;
  19        struct rb_root      names;
  20        struct rw_semaphore lock;
  21};
  22
  23void maps__insert(struct maps *maps, struct map *map);
  24void maps__remove(struct maps *maps, struct map *map);
  25struct map *maps__find(struct maps *maps, u64 addr);
  26struct map *maps__first(struct maps *maps);
  27struct map *map__next(struct map *map);
  28struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, struct map **mapp);
  29
  30struct map_groups {
  31        struct maps      maps;
  32        struct machine   *machine;
  33        refcount_t       refcnt;
  34};
  35
  36#define KMAP_NAME_LEN 256
  37
  38struct kmap {
  39        struct ref_reloc_sym *ref_reloc_sym;
  40        struct map_groups    *kmaps;
  41        char                 name[KMAP_NAME_LEN];
  42};
  43
  44struct map_groups *map_groups__new(struct machine *machine);
  45void map_groups__delete(struct map_groups *mg);
  46bool map_groups__empty(struct map_groups *mg);
  47
  48static inline struct map_groups *map_groups__get(struct map_groups *mg)
  49{
  50        if (mg)
  51                refcount_inc(&mg->refcnt);
  52        return mg;
  53}
  54
  55void map_groups__put(struct map_groups *mg);
  56void map_groups__init(struct map_groups *mg, struct machine *machine);
  57void map_groups__exit(struct map_groups *mg);
  58int map_groups__clone(struct thread *thread, struct map_groups *parent);
  59size_t map_groups__fprintf(struct map_groups *mg, FILE *fp);
  60
  61void map_groups__insert(struct map_groups *mg, struct map *map);
  62
  63static inline void map_groups__remove(struct map_groups *mg, struct map *map)
  64{
  65        maps__remove(&mg->maps, map);
  66}
  67
  68static inline struct map *map_groups__find(struct map_groups *mg, u64 addr)
  69{
  70        return maps__find(&mg->maps, addr);
  71}
  72
  73struct map *map_groups__first(struct map_groups *mg);
  74
  75static inline struct map *map_groups__next(struct map *map)
  76{
  77        return map__next(map);
  78}
  79
  80struct symbol *map_groups__find_symbol(struct map_groups *mg, u64 addr, struct map **mapp);
  81struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg, const char *name, struct map **mapp);
  82
  83struct addr_map_symbol;
  84
  85int map_groups__find_ams(struct addr_map_symbol *ams);
  86
  87int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, FILE *fp);
  88
  89struct map *map_groups__find_by_name(struct map_groups *mg, const char *name);
  90
  91int map_groups__merge_in(struct map_groups *kmaps, struct map *new_map);
  92
  93#endif // __PERF_MAP_GROUPS_H
  94