diff options
Diffstat (limited to 'tools/perf/util/map.h')
-rw-r--r-- | tools/perf/util/map.h | 75 |
1 files changed, 61 insertions, 14 deletions
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index 2031278cc06a..30d38d634e09 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h | |||
@@ -19,6 +19,7 @@ extern const char *map_type__name[MAP__NR_TYPES]; | |||
19 | struct dso; | 19 | struct dso; |
20 | struct ref_reloc_sym; | 20 | struct ref_reloc_sym; |
21 | struct map_groups; | 21 | struct map_groups; |
22 | struct kernel_info; | ||
22 | 23 | ||
23 | struct map { | 24 | struct map { |
24 | union { | 25 | union { |
@@ -36,6 +37,7 @@ struct map { | |||
36 | u64 (*unmap_ip)(struct map *, u64); | 37 | u64 (*unmap_ip)(struct map *, u64); |
37 | 38 | ||
38 | struct dso *dso; | 39 | struct dso *dso; |
40 | struct map_groups *groups; | ||
39 | }; | 41 | }; |
40 | 42 | ||
41 | struct kmap { | 43 | struct kmap { |
@@ -43,6 +45,26 @@ struct kmap { | |||
43 | struct map_groups *kmaps; | 45 | struct map_groups *kmaps; |
44 | }; | 46 | }; |
45 | 47 | ||
48 | struct map_groups { | ||
49 | struct rb_root maps[MAP__NR_TYPES]; | ||
50 | struct list_head removed_maps[MAP__NR_TYPES]; | ||
51 | struct kernel_info *this_kerninfo; | ||
52 | }; | ||
53 | |||
54 | /* Native host kernel uses -1 as pid index in kernel_info */ | ||
55 | #define HOST_KERNEL_ID (-1) | ||
56 | #define DEFAULT_GUEST_KERNEL_ID (0) | ||
57 | |||
58 | struct kernel_info { | ||
59 | struct rb_node rb_node; | ||
60 | pid_t pid; | ||
61 | char *root_dir; | ||
62 | struct list_head dsos__user; | ||
63 | struct list_head dsos__kernel; | ||
64 | struct map_groups kmaps; | ||
65 | struct map *vmlinux_maps[MAP__NR_TYPES]; | ||
66 | }; | ||
67 | |||
46 | static inline struct kmap *map__kmap(struct map *self) | 68 | static inline struct kmap *map__kmap(struct map *self) |
47 | { | 69 | { |
48 | return (struct kmap *)(self + 1); | 70 | return (struct kmap *)(self + 1); |
@@ -74,7 +96,8 @@ typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); | |||
74 | 96 | ||
75 | void map__init(struct map *self, enum map_type type, | 97 | void map__init(struct map *self, enum map_type type, |
76 | u64 start, u64 end, u64 pgoff, struct dso *dso); | 98 | u64 start, u64 end, u64 pgoff, struct dso *dso); |
77 | struct map *map__new(u64 start, u64 len, u64 pgoff, u32 pid, char *filename, | 99 | struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, |
100 | u64 pgoff, u32 pid, char *filename, | ||
78 | enum map_type type, char *cwd, int cwdlen); | 101 | enum map_type type, char *cwd, int cwdlen); |
79 | void map__delete(struct map *self); | 102 | void map__delete(struct map *self); |
80 | struct map *map__clone(struct map *self); | 103 | struct map *map__clone(struct map *self); |
@@ -91,11 +114,6 @@ void map__fixup_end(struct map *self); | |||
91 | 114 | ||
92 | void map__reloc_vmlinux(struct map *self); | 115 | void map__reloc_vmlinux(struct map *self); |
93 | 116 | ||
94 | struct map_groups { | ||
95 | struct rb_root maps[MAP__NR_TYPES]; | ||
96 | struct list_head removed_maps[MAP__NR_TYPES]; | ||
97 | }; | ||
98 | |||
99 | size_t __map_groups__fprintf_maps(struct map_groups *self, | 117 | size_t __map_groups__fprintf_maps(struct map_groups *self, |
100 | enum map_type type, int verbose, FILE *fp); | 118 | enum map_type type, int verbose, FILE *fp); |
101 | void maps__insert(struct rb_root *maps, struct map *map); | 119 | void maps__insert(struct rb_root *maps, struct map *map); |
@@ -106,9 +124,40 @@ int map_groups__clone(struct map_groups *self, | |||
106 | size_t map_groups__fprintf(struct map_groups *self, int verbose, FILE *fp); | 124 | size_t map_groups__fprintf(struct map_groups *self, int verbose, FILE *fp); |
107 | size_t map_groups__fprintf_maps(struct map_groups *self, int verbose, FILE *fp); | 125 | size_t map_groups__fprintf_maps(struct map_groups *self, int verbose, FILE *fp); |
108 | 126 | ||
127 | struct kernel_info *add_new_kernel_info(struct rb_root *kerninfo_root, | ||
128 | pid_t pid, const char *root_dir); | ||
129 | struct kernel_info *kerninfo__find(struct rb_root *kerninfo_root, pid_t pid); | ||
130 | struct kernel_info *kerninfo__findnew(struct rb_root *kerninfo_root, pid_t pid); | ||
131 | struct kernel_info *kerninfo__findhost(struct rb_root *kerninfo_root); | ||
132 | char *kern_mmap_name(struct kernel_info *kerninfo, char *buff); | ||
133 | |||
134 | /* | ||
135 | * Default guest kernel is defined by parameter --guestkallsyms | ||
136 | * and --guestmodules | ||
137 | */ | ||
138 | static inline int is_default_guest(struct kernel_info *kerninfo) | ||
139 | { | ||
140 | if (!kerninfo) | ||
141 | return 0; | ||
142 | return kerninfo->pid == DEFAULT_GUEST_KERNEL_ID; | ||
143 | } | ||
144 | |||
145 | static inline int is_host_kernel(struct kernel_info *kerninfo) | ||
146 | { | ||
147 | if (!kerninfo) | ||
148 | return 0; | ||
149 | return kerninfo->pid == HOST_KERNEL_ID; | ||
150 | } | ||
151 | |||
152 | typedef void (*process_kernel_info)(struct kernel_info *kerninfo, void *data); | ||
153 | void kerninfo__process_allkernels(struct rb_root *kerninfo_root, | ||
154 | process_kernel_info process, | ||
155 | void *data); | ||
156 | |||
109 | static inline void map_groups__insert(struct map_groups *self, struct map *map) | 157 | static inline void map_groups__insert(struct map_groups *self, struct map *map) |
110 | { | 158 | { |
111 | maps__insert(&self->maps[map->type], map); | 159 | maps__insert(&self->maps[map->type], map); |
160 | map->groups = self; | ||
112 | } | 161 | } |
113 | 162 | ||
114 | static inline struct map *map_groups__find(struct map_groups *self, | 163 | static inline struct map *map_groups__find(struct map_groups *self, |
@@ -148,13 +197,11 @@ int map_groups__fixup_overlappings(struct map_groups *self, struct map *map, | |||
148 | 197 | ||
149 | struct map *map_groups__find_by_name(struct map_groups *self, | 198 | struct map *map_groups__find_by_name(struct map_groups *self, |
150 | enum map_type type, const char *name); | 199 | enum map_type type, const char *name); |
151 | int __map_groups__create_kernel_maps(struct map_groups *self, | 200 | struct map *map_groups__new_module(struct map_groups *self, |
152 | struct map *vmlinux_maps[MAP__NR_TYPES], | 201 | u64 start, |
153 | struct dso *kernel); | 202 | const char *filename, |
154 | int map_groups__create_kernel_maps(struct map_groups *self, | 203 | struct kernel_info *kerninfo); |
155 | struct map *vmlinux_maps[MAP__NR_TYPES]); | 204 | |
156 | struct map *map_groups__new_module(struct map_groups *self, u64 start, | ||
157 | const char *filename); | ||
158 | void map_groups__flush(struct map_groups *self); | 205 | void map_groups__flush(struct map_groups *self); |
159 | 206 | ||
160 | #endif /* __PERF_MAP_H */ | 207 | #endif /* __PERF_MAP_H */ |