1 #ifndef __PERF_MACHINE_H
2 #define __PERF_MACHINE_H
5 #include <linux/rbtree.h>
17 /* Native host kernel uses -1 as pid index in machine */
18 #define HOST_KERNEL_ID (-1)
19 #define DEFAULT_GUEST_KERNEL_ID (0)
21 extern const char *ref_reloc_sym_names
[];
26 struct rb_node rb_node
;
31 struct rb_root threads
;
32 struct list_head dead_threads
;
33 struct thread
*last_match
;
34 struct vdso_info
*vdso_info
;
35 struct list_head user_dsos
;
36 struct list_head kernel_dsos
;
37 struct map_groups kmaps
;
38 struct map
*vmlinux_maps
[MAP__NR_TYPES
];
39 symbol_filter_t symbol_filter
;
44 struct map
*machine__kernel_map(struct machine
*machine
, enum map_type type
)
46 return machine
->vmlinux_maps
[type
];
49 struct thread
*machine__find_thread(struct machine
*machine
, pid_t pid
,
51 struct comm
*machine__thread_exec_comm(struct machine
*machine
,
52 struct thread
*thread
);
54 int machine__process_comm_event(struct machine
*machine
, union perf_event
*event
,
55 struct perf_sample
*sample
);
56 int machine__process_exit_event(struct machine
*machine
, union perf_event
*event
,
57 struct perf_sample
*sample
);
58 int machine__process_fork_event(struct machine
*machine
, union perf_event
*event
,
59 struct perf_sample
*sample
);
60 int machine__process_lost_event(struct machine
*machine
, union perf_event
*event
,
61 struct perf_sample
*sample
);
62 int machine__process_mmap_event(struct machine
*machine
, union perf_event
*event
,
63 struct perf_sample
*sample
);
64 int machine__process_mmap2_event(struct machine
*machine
, union perf_event
*event
,
65 struct perf_sample
*sample
);
66 int machine__process_event(struct machine
*machine
, union perf_event
*event
,
67 struct perf_sample
*sample
);
69 typedef void (*machine__process_t
)(struct machine
*machine
, void *data
);
73 struct rb_root guests
;
74 symbol_filter_t symbol_filter
;
77 void machines__init(struct machines
*machines
);
78 void machines__exit(struct machines
*machines
);
80 void machines__process_guests(struct machines
*machines
,
81 machine__process_t process
, void *data
);
83 struct machine
*machines__add(struct machines
*machines
, pid_t pid
,
84 const char *root_dir
);
85 struct machine
*machines__find_host(struct machines
*machines
);
86 struct machine
*machines__find(struct machines
*machines
, pid_t pid
);
87 struct machine
*machines__findnew(struct machines
*machines
, pid_t pid
);
89 void machines__set_id_hdr_size(struct machines
*machines
, u16 id_hdr_size
);
90 char *machine__mmap_name(struct machine
*machine
, char *bf
, size_t size
);
92 void machines__set_symbol_filter(struct machines
*machines
,
93 symbol_filter_t symbol_filter
);
94 void machines__set_comm_exec(struct machines
*machines
, bool comm_exec
);
96 struct machine
*machine__new_host(void);
97 int machine__init(struct machine
*machine
, const char *root_dir
, pid_t pid
);
98 void machine__exit(struct machine
*machine
);
99 void machine__delete_dead_threads(struct machine
*machine
);
100 void machine__delete_threads(struct machine
*machine
);
101 void machine__delete(struct machine
*machine
);
103 struct branch_info
*sample__resolve_bstack(struct perf_sample
*sample
,
104 struct addr_location
*al
);
105 struct mem_info
*sample__resolve_mem(struct perf_sample
*sample
,
106 struct addr_location
*al
);
107 int machine__resolve_callchain(struct machine
*machine
,
108 struct perf_evsel
*evsel
,
109 struct thread
*thread
,
110 struct perf_sample
*sample
,
111 struct symbol
**parent
,
112 struct addr_location
*root_al
,
116 * Default guest kernel is defined by parameter --guestkallsyms
119 static inline bool machine__is_default_guest(struct machine
*machine
)
121 return machine
? machine
->pid
== DEFAULT_GUEST_KERNEL_ID
: false;
124 static inline bool machine__is_host(struct machine
*machine
)
126 return machine
? machine
->pid
== HOST_KERNEL_ID
: false;
129 struct thread
*machine__findnew_thread(struct machine
*machine
, pid_t pid
,
132 size_t machine__fprintf(struct machine
*machine
, FILE *fp
);
135 struct symbol
*machine__find_kernel_symbol(struct machine
*machine
,
136 enum map_type type
, u64 addr
,
138 symbol_filter_t filter
)
140 return map_groups__find_symbol(&machine
->kmaps
, type
, addr
,
145 struct symbol
*machine__find_kernel_function(struct machine
*machine
, u64 addr
,
147 symbol_filter_t filter
)
149 return machine__find_kernel_symbol(machine
, MAP__FUNCTION
, addr
,
154 struct symbol
*machine__find_kernel_function_by_name(struct machine
*machine
,
157 symbol_filter_t filter
)
159 return map_groups__find_function_by_name(&machine
->kmaps
, name
, mapp
,
163 struct map
*machine__new_module(struct machine
*machine
, u64 start
,
164 const char *filename
);
166 int machine__load_kallsyms(struct machine
*machine
, const char *filename
,
167 enum map_type type
, symbol_filter_t filter
);
168 int machine__load_vmlinux_path(struct machine
*machine
, enum map_type type
,
169 symbol_filter_t filter
);
171 size_t machine__fprintf_dsos_buildid(struct machine
*machine
, FILE *fp
,
172 bool (skip
)(struct dso
*dso
, int parm
), int parm
);
173 size_t machines__fprintf_dsos(struct machines
*machines
, FILE *fp
);
174 size_t machines__fprintf_dsos_buildid(struct machines
*machines
, FILE *fp
,
175 bool (skip
)(struct dso
*dso
, int parm
), int parm
);
177 void machine__destroy_kernel_maps(struct machine
*machine
);
178 int __machine__create_kernel_maps(struct machine
*machine
, struct dso
*kernel
);
179 int machine__create_kernel_maps(struct machine
*machine
);
181 int machines__create_kernel_maps(struct machines
*machines
, pid_t pid
);
182 int machines__create_guest_kernel_maps(struct machines
*machines
);
183 void machines__destroy_kernel_maps(struct machines
*machines
);
185 size_t machine__fprintf_vmlinux_path(struct machine
*machine
, FILE *fp
);
187 int machine__for_each_thread(struct machine
*machine
,
188 int (*fn
)(struct thread
*thread
, void *p
),
191 int __machine__synthesize_threads(struct machine
*machine
, struct perf_tool
*tool
,
192 struct target
*target
, struct thread_map
*threads
,
193 perf_event__handler_t process
, bool data_mmap
);
195 int machine__synthesize_threads(struct machine
*machine
, struct target
*target
,
196 struct thread_map
*threads
, bool data_mmap
)
198 return __machine__synthesize_threads(machine
, NULL
, target
, threads
,
199 perf_event__process
, data_mmap
);
202 pid_t
machine__get_current_tid(struct machine
*machine
, int cpu
);
203 int machine__set_current_tid(struct machine
*machine
, int cpu
, pid_t pid
,
206 #endif /* __PERF_MACHINE_H */