Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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 <linux/rbtree.h>
7#include <stdio.h>
8#include <stdbool.h>
9#include <linux/types.h>
10#include "rwsem.h"
11#include <internal/rc_check.h>
12
13struct ref_reloc_sym;
14struct machine;
15struct map;
16struct maps;
17struct thread;
18
19struct map_rb_node {
20 struct rb_node rb_node;
21 struct map *map;
22};
23
24struct map_rb_node *maps__first(struct maps *maps);
25struct map_rb_node *map_rb_node__next(struct map_rb_node *node);
26struct map_rb_node *maps__find_node(struct maps *maps, struct map *map);
27struct map *maps__find(struct maps *maps, u64 addr);
28
29#define maps__for_each_entry(maps, map) \
30 for (map = maps__first(maps); map; map = map_rb_node__next(map))
31
32#define maps__for_each_entry_safe(maps, map, next) \
33 for (map = maps__first(maps), next = map_rb_node__next(map); map; \
34 map = next, next = map_rb_node__next(map))
35
36DECLARE_RC_STRUCT(maps) {
37 struct rb_root entries;
38 struct rw_semaphore lock;
39 struct machine *machine;
40 struct map *last_search_by_name;
41 struct map **maps_by_name;
42 refcount_t refcnt;
43 unsigned int nr_maps;
44 unsigned int nr_maps_allocated;
45#ifdef HAVE_LIBUNWIND_SUPPORT
46 void *addr_space;
47 const struct unwind_libunwind_ops *unwind_libunwind_ops;
48#endif
49};
50
51#define KMAP_NAME_LEN 256
52
53struct kmap {
54 struct ref_reloc_sym *ref_reloc_sym;
55 struct maps *kmaps;
56 char name[KMAP_NAME_LEN];
57};
58
59struct maps *maps__new(struct machine *machine);
60void maps__delete(struct maps *maps);
61bool maps__empty(struct maps *maps);
62int maps__clone(struct thread *thread, struct maps *parent);
63
64struct maps *maps__get(struct maps *maps);
65void maps__put(struct maps *maps);
66
67static inline struct rb_root *maps__entries(struct maps *maps)
68{
69 return &RC_CHK_ACCESS(maps)->entries;
70}
71
72static inline struct machine *maps__machine(struct maps *maps)
73{
74 return RC_CHK_ACCESS(maps)->machine;
75}
76
77static inline struct rw_semaphore *maps__lock(struct maps *maps)
78{
79 return &RC_CHK_ACCESS(maps)->lock;
80}
81
82static inline struct map **maps__maps_by_name(struct maps *maps)
83{
84 return RC_CHK_ACCESS(maps)->maps_by_name;
85}
86
87static inline unsigned int maps__nr_maps(const struct maps *maps)
88{
89 return RC_CHK_ACCESS(maps)->nr_maps;
90}
91
92static inline refcount_t *maps__refcnt(struct maps *maps)
93{
94 return &RC_CHK_ACCESS(maps)->refcnt;
95}
96
97#ifdef HAVE_LIBUNWIND_SUPPORT
98static inline void *maps__addr_space(struct maps *maps)
99{
100 return RC_CHK_ACCESS(maps)->addr_space;
101}
102
103static inline const struct unwind_libunwind_ops *maps__unwind_libunwind_ops(const struct maps *maps)
104{
105 return RC_CHK_ACCESS(maps)->unwind_libunwind_ops;
106}
107#endif
108
109size_t maps__fprintf(struct maps *maps, FILE *fp);
110
111int maps__insert(struct maps *maps, struct map *map);
112void maps__remove(struct maps *maps, struct map *map);
113
114struct symbol *maps__find_symbol(struct maps *maps, u64 addr, struct map **mapp);
115struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, struct map **mapp);
116
117struct addr_map_symbol;
118
119int maps__find_ams(struct maps *maps, struct addr_map_symbol *ams);
120
121int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp);
122
123struct map *maps__find_by_name(struct maps *maps, const char *name);
124
125int maps__merge_in(struct maps *kmaps, struct map *new_map);
126
127void __maps__sort_by_name(struct maps *maps);
128
129#endif // __PERF_MAPS_H