Blame view
tools/perf/util/machine.h
8.8 KB
9d2f8e22f
|
1 2 3 4 |
#ifndef __PERF_MACHINE_H #define __PERF_MACHINE_H #include <sys/types.h> |
69d2591a8
|
5 6 |
#include <linux/rbtree.h> #include "map.h" |
8fa7d87f9
|
7 |
#include "dso.h" |
58d925dce
|
8 |
#include "event.h" |
9d2f8e22f
|
9 |
|
b21484f1a
|
10 |
struct addr_location; |
69d2591a8
|
11 12 13 14 |
struct branch_stack; struct perf_evsel; struct perf_sample; struct symbol; |
9d2f8e22f
|
15 |
struct thread; |
b0a7d1a0c
|
16 |
union perf_event; |
9d2f8e22f
|
17 |
|
69d2591a8
|
18 19 20 |
/* Native host kernel uses -1 as pid index in machine */ #define HOST_KERNEL_ID (-1) #define DEFAULT_GUEST_KERNEL_ID (0) |
5512cf24b
|
21 |
extern const char *ref_reloc_sym_names[]; |
d027b6400
|
22 |
struct vdso_info; |
69d2591a8
|
23 24 25 26 |
struct machine { struct rb_node rb_node; pid_t pid; u16 id_hdr_size; |
cfe1c4140
|
27 |
bool comm_exec; |
caf8a0d04
|
28 |
bool kptr_restrict_warned; |
69d2591a8
|
29 30 |
char *root_dir; struct rb_root threads; |
b91fc39f4
|
31 |
pthread_rwlock_t threads_lock; |
d2c110344
|
32 |
unsigned int nr_threads; |
69d2591a8
|
33 34 |
struct list_head dead_threads; struct thread *last_match; |
d027b6400
|
35 |
struct vdso_info *vdso_info; |
4cde998d2
|
36 |
struct perf_env *env; |
3d39ac538
|
37 |
struct dsos dsos; |
69d2591a8
|
38 39 |
struct map_groups kmaps; struct map *vmlinux_maps[MAP__NR_TYPES]; |
fbe2af45f
|
40 |
u64 kernel_start; |
b9d266baa
|
41 |
pid_t *current_tid; |
0db15b1e8
|
42 43 44 45 |
union { /* Tool specific area */ void *priv; u64 db_id; }; |
69d2591a8
|
46 47 48 |
}; static inline |
a5e813c68
|
49 |
struct map *__machine__kernel_map(struct machine *machine, enum map_type type) |
69d2591a8
|
50 51 52 |
{ return machine->vmlinux_maps[type]; } |
a5e813c68
|
53 54 55 56 57 |
static inline struct map *machine__kernel_map(struct machine *machine) { return __machine__kernel_map(machine, MAP__FUNCTION); } |
fbe2af45f
|
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
int machine__get_kernel_start(struct machine *machine); static inline u64 machine__kernel_start(struct machine *machine) { if (!machine->kernel_start) machine__get_kernel_start(machine); return machine->kernel_start; } static inline bool machine__kernel_ip(struct machine *machine, u64 ip) { u64 kernel_start = machine__kernel_start(machine); return ip >= kernel_start; } |
d75e6097e
|
73 74 |
struct thread *machine__find_thread(struct machine *machine, pid_t pid, pid_t tid); |
cfe1c4140
|
75 76 |
struct comm *machine__thread_exec_comm(struct machine *machine, struct thread *thread); |
9d2f8e22f
|
77 |
|
162f0befd
|
78 79 80 81 82 83 84 85 |
int machine__process_comm_event(struct machine *machine, union perf_event *event, struct perf_sample *sample); int machine__process_exit_event(struct machine *machine, union perf_event *event, struct perf_sample *sample); int machine__process_fork_event(struct machine *machine, union perf_event *event, struct perf_sample *sample); int machine__process_lost_event(struct machine *machine, union perf_event *event, struct perf_sample *sample); |
c4937a91e
|
86 87 |
int machine__process_lost_samples_event(struct machine *machine, union perf_event *event, struct perf_sample *sample); |
4a96f7a02
|
88 89 |
int machine__process_aux_event(struct machine *machine, union perf_event *event); |
0ad21f686
|
90 91 |
int machine__process_itrace_start_event(struct machine *machine, union perf_event *event); |
b8f8eb84f
|
92 |
int machine__process_switch_event(struct machine *machine, |
0286039f7
|
93 |
union perf_event *event); |
f3b3614a2
|
94 95 96 |
int machine__process_namespaces_event(struct machine *machine, union perf_event *event, struct perf_sample *sample); |
162f0befd
|
97 98 99 100 101 102 |
int machine__process_mmap_event(struct machine *machine, union perf_event *event, struct perf_sample *sample); int machine__process_mmap2_event(struct machine *machine, union perf_event *event, struct perf_sample *sample); int machine__process_event(struct machine *machine, union perf_event *event, struct perf_sample *sample); |
b0a7d1a0c
|
103 |
|
69d2591a8
|
104 |
typedef void (*machine__process_t)(struct machine *machine, void *data); |
876650e6c
|
105 106 107 108 109 110 111 112 113 114 |
struct machines { struct machine host; struct rb_root guests; }; void machines__init(struct machines *machines); void machines__exit(struct machines *machines); void machines__process_guests(struct machines *machines, machine__process_t process, void *data); |
69d2591a8
|
115 |
|
876650e6c
|
116 |
struct machine *machines__add(struct machines *machines, pid_t pid, |
69d2591a8
|
117 |
const char *root_dir); |
876650e6c
|
118 119 120 |
struct machine *machines__find_host(struct machines *machines); struct machine *machines__find(struct machines *machines, pid_t pid); struct machine *machines__findnew(struct machines *machines, pid_t pid); |
69d2591a8
|
121 |
|
876650e6c
|
122 |
void machines__set_id_hdr_size(struct machines *machines, u16 id_hdr_size); |
69d2591a8
|
123 |
char *machine__mmap_name(struct machine *machine, char *bf, size_t size); |
cfe1c4140
|
124 |
void machines__set_comm_exec(struct machines *machines, bool comm_exec); |
611a5ce8a
|
125 |
|
8fb598e5a
|
126 |
struct machine *machine__new_host(void); |
7d132caaf
|
127 |
struct machine *machine__new_kallsyms(void); |
69d2591a8
|
128 129 |
int machine__init(struct machine *machine, const char *root_dir, pid_t pid); void machine__exit(struct machine *machine); |
3f067dcab
|
130 |
void machine__delete_threads(struct machine *machine); |
69d2591a8
|
131 |
void machine__delete(struct machine *machine); |
5e78c69b7
|
132 |
void machine__remove_thread(struct machine *machine, struct thread *th); |
69d2591a8
|
133 |
|
644f2df29
|
134 135 |
struct branch_info *sample__resolve_bstack(struct perf_sample *sample, struct addr_location *al); |
e80faac04
|
136 137 |
struct mem_info *sample__resolve_mem(struct perf_sample *sample, struct addr_location *al); |
91d7b2de3
|
138 139 |
struct callchain_cursor; |
cc8b7c2bf
|
140 |
int thread__resolve_callchain(struct thread *thread, |
91d7b2de3
|
141 |
struct callchain_cursor *cursor, |
cc8b7c2bf
|
142 143 144 145 146 |
struct perf_evsel *evsel, struct perf_sample *sample, struct symbol **parent, struct addr_location *root_al, int max_stack); |
69d2591a8
|
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
/* * Default guest kernel is defined by parameter --guestkallsyms * and --guestmodules */ static inline bool machine__is_default_guest(struct machine *machine) { return machine ? machine->pid == DEFAULT_GUEST_KERNEL_ID : false; } static inline bool machine__is_host(struct machine *machine) { return machine ? machine->pid == HOST_KERNEL_ID : false; } |
b91fc39f4
|
161 162 |
struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid); struct thread *machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid); |
69d2591a8
|
163 |
|
aa7cc2ae5
|
164 |
struct dso *machine__findnew_dso(struct machine *machine, const char *filename); |
69d2591a8
|
165 166 167 168 169 |
size_t machine__fprintf(struct machine *machine, FILE *fp); static inline struct symbol *machine__find_kernel_symbol(struct machine *machine, enum map_type type, u64 addr, |
be39db9f2
|
170 |
struct map **mapp) |
69d2591a8
|
171 |
{ |
be39db9f2
|
172 |
return map_groups__find_symbol(&machine->kmaps, type, addr, mapp); |
69d2591a8
|
173 174 175 |
} static inline |
8acd3da03
|
176 177 |
struct symbol *machine__find_kernel_symbol_by_name(struct machine *machine, enum map_type type, const char *name, |
be39db9f2
|
178 |
struct map **mapp) |
8acd3da03
|
179 |
{ |
be39db9f2
|
180 |
return map_groups__find_symbol_by_name(&machine->kmaps, type, name, mapp); |
8acd3da03
|
181 182 183 |
} static inline |
69d2591a8
|
184 |
struct symbol *machine__find_kernel_function(struct machine *machine, u64 addr, |
be39db9f2
|
185 |
struct map **mapp) |
69d2591a8
|
186 187 |
{ return machine__find_kernel_symbol(machine, MAP__FUNCTION, addr, |
be39db9f2
|
188 |
mapp); |
69d2591a8
|
189 190 191 192 193 |
} static inline struct symbol *machine__find_kernel_function_by_name(struct machine *machine, const char *name, |
be39db9f2
|
194 |
struct map **mapp) |
69d2591a8
|
195 |
{ |
be39db9f2
|
196 |
return map_groups__find_function_by_name(&machine->kmaps, name, mapp); |
69d2591a8
|
197 |
} |
9f2de3154
|
198 199 |
struct map *machine__findnew_module_map(struct machine *machine, u64 start, const char *filename); |
203d8a4aa
|
200 |
int arch__fix_module_text_start(u64 *start, const char *name); |
69d2591a8
|
201 |
|
e02092b9a
|
202 |
int __machine__load_kallsyms(struct machine *machine, const char *filename, |
be39db9f2
|
203 |
enum map_type type, bool no_kcore); |
69d2591a8
|
204 |
int machine__load_kallsyms(struct machine *machine, const char *filename, |
be39db9f2
|
205 206 |
enum map_type type); int machine__load_vmlinux_path(struct machine *machine, enum map_type type); |
69d2591a8
|
207 |
|
417c2ff68
|
208 209 |
size_t machine__fprintf_dsos_buildid(struct machine *machine, FILE *fp, bool (skip)(struct dso *dso, int parm), int parm); |
876650e6c
|
210 211 |
size_t machines__fprintf_dsos(struct machines *machines, FILE *fp); size_t machines__fprintf_dsos_buildid(struct machines *machines, FILE *fp, |
417c2ff68
|
212 |
bool (skip)(struct dso *dso, int parm), int parm); |
69d2591a8
|
213 214 215 216 |
void machine__destroy_kernel_maps(struct machine *machine); int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel); int machine__create_kernel_maps(struct machine *machine); |
876650e6c
|
217 218 219 |
int machines__create_kernel_maps(struct machines *machines, pid_t pid); int machines__create_guest_kernel_maps(struct machines *machines); void machines__destroy_kernel_maps(struct machines *machines); |
69d2591a8
|
220 221 |
size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp); |
35feee19f
|
222 223 224 |
int machine__for_each_thread(struct machine *machine, int (*fn)(struct thread *thread, void *p), void *priv); |
a5499b371
|
225 226 227 |
int machines__for_each_thread(struct machines *machines, int (*fn)(struct thread *thread, void *p), void *priv); |
35feee19f
|
228 |
|
a33fbd56e
|
229 |
int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool, |
602ad878d
|
230 |
struct target *target, struct thread_map *threads, |
9d9cad763
|
231 232 |
perf_event__handler_t process, bool data_mmap, unsigned int proc_map_timeout); |
a33fbd56e
|
233 |
static inline |
602ad878d
|
234 |
int machine__synthesize_threads(struct machine *machine, struct target *target, |
9d9cad763
|
235 236 |
struct thread_map *threads, bool data_mmap, unsigned int proc_map_timeout) |
a33fbd56e
|
237 238 |
{ return __machine__synthesize_threads(machine, NULL, target, threads, |
9d9cad763
|
239 240 |
perf_event__process, data_mmap, proc_map_timeout); |
a33fbd56e
|
241 |
} |
b9d266baa
|
242 243 244 |
pid_t machine__get_current_tid(struct machine *machine, int cpu); int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid, pid_t tid); |
c3168b0db
|
245 246 247 248 |
/* * For use with libtraceevent's pevent_set_function_resolver() */ char *machine__resolve_kernel_addr(void *vmachine, unsigned long long *addrp, char **modp); |
b9d266baa
|
249 |
|
9d2f8e22f
|
250 |
#endif /* __PERF_MACHINE_H */ |