]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - tools/perf/util/maps.h
perf machine: Fill map_symbol->maps in append_inlines() to fix segfault
[mirror_ubuntu-jammy-kernel.git] / tools / perf / util / maps.h
CommitLineData
41f30914 1/* SPDX-License-Identifier: GPL-2.0 */
c54d241b
ACM
2#ifndef __PERF_MAPS_H
3#define __PERF_MAPS_H
41f30914
ACM
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;
79b6bb73 15struct maps;
41f30914
ACM
16struct thread;
17
41f30914
ACM
18struct map *maps__find(struct maps *maps, u64 addr);
19struct map *maps__first(struct maps *maps);
20struct map *map__next(struct map *map);
8efc4f05
ACM
21
22#define maps__for_each_entry(maps, map) \
23 for (map = maps__first(maps); map; map = map__next(map))
24
25#define maps__for_each_entry_safe(maps, map, next) \
26 for (map = maps__first(maps), next = map__next(map); map; map = next, next = map__next(map))
27
79b6bb73
ACM
28struct maps {
29 struct rb_root entries;
30 struct rw_semaphore lock;
41f30914 31 struct machine *machine;
1ae14516 32 struct map *last_search_by_name;
a7c2b572 33 struct map **maps_by_name;
41f30914 34 refcount_t refcnt;
a7c2b572
ACM
35 unsigned int nr_maps;
36 unsigned int nr_maps_allocated;
e8ba2906
JK
37#ifdef HAVE_LIBUNWIND_SUPPORT
38 void *addr_space;
39 struct unwind_libunwind_ops *unwind_libunwind_ops;
40#endif
41f30914
ACM
41};
42
43#define KMAP_NAME_LEN 256
44
45struct kmap {
46 struct ref_reloc_sym *ref_reloc_sym;
79b6bb73 47 struct maps *kmaps;
41f30914
ACM
48 char name[KMAP_NAME_LEN];
49};
50
79b6bb73 51struct maps *maps__new(struct machine *machine);
9a29ceee
ACM
52void maps__delete(struct maps *maps);
53bool maps__empty(struct maps *maps);
41f30914 54
9a29ceee 55static inline struct maps *maps__get(struct maps *maps)
41f30914 56{
9a29ceee
ACM
57 if (maps)
58 refcount_inc(&maps->refcnt);
59 return maps;
41f30914
ACM
60}
61
9a29ceee
ACM
62void maps__put(struct maps *maps);
63void maps__init(struct maps *maps, struct machine *machine);
64void maps__exit(struct maps *maps);
79b6bb73 65int maps__clone(struct thread *thread, struct maps *parent);
9a29ceee 66size_t maps__fprintf(struct maps *maps, FILE *fp);
41f30914 67
9a29ceee 68void maps__insert(struct maps *maps, struct map *map);
41f30914 69
9a29ceee 70void maps__remove(struct maps *maps, struct map *map);
41f30914 71
9a29ceee
ACM
72struct symbol *maps__find_symbol(struct maps *maps, u64 addr, struct map **mapp);
73struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, struct map **mapp);
41f30914
ACM
74
75struct addr_map_symbol;
76
9a29ceee 77int maps__find_ams(struct maps *maps, struct addr_map_symbol *ams);
41f30914 78
9a29ceee 79int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp);
41f30914 80
9a29ceee 81struct map *maps__find_by_name(struct maps *maps, const char *name);
41f30914 82
79b6bb73 83int maps__merge_in(struct maps *kmaps, struct map *new_map);
4f600bcf 84
9a29ceee 85void __maps__sort_by_name(struct maps *maps);
a7c2b572 86
c54d241b 87#endif // __PERF_MAPS_H