diff options
Diffstat (limited to 'parse-events.h')
-rw-r--r-- | parse-events.h | 196 |
1 files changed, 152 insertions, 44 deletions
diff --git a/parse-events.h b/parse-events.h index 4459b52..db7e259 100644 --- a/parse-events.h +++ b/parse-events.h | |||
@@ -49,6 +49,7 @@ extern int trace_seq_do_printf(struct trace_seq *s); | |||
49 | 49 | ||
50 | /* ----------------------- pevent ----------------------- */ | 50 | /* ----------------------- pevent ----------------------- */ |
51 | 51 | ||
52 | struct pevent; | ||
52 | struct event; | 53 | struct event; |
53 | 54 | ||
54 | typedef int (*pevent_event_handler_func)(struct trace_seq *s, | 55 | typedef int (*pevent_event_handler_func)(struct trace_seq *s, |
@@ -56,7 +57,7 @@ typedef int (*pevent_event_handler_func)(struct trace_seq *s, | |||
56 | struct event *event, int cpu, | 57 | struct event *event, int cpu, |
57 | unsigned long long nsecs); | 58 | unsigned long long nsecs); |
58 | 59 | ||
59 | typedef int (*pevent_plugin_load_func)(void); | 60 | typedef int (*pevent_plugin_load_func)(struct pevent *pevent); |
60 | 61 | ||
61 | #define PEVENT_PLUGIN_LOADER pevent_plugin_loader | 62 | #define PEVENT_PLUGIN_LOADER pevent_plugin_loader |
62 | #define MAKE_STR(x) #x | 63 | #define MAKE_STR(x) #x |
@@ -75,6 +76,7 @@ enum format_flags { | |||
75 | 76 | ||
76 | struct format_field { | 77 | struct format_field { |
77 | struct format_field *next; | 78 | struct format_field *next; |
79 | struct event *event; | ||
78 | char *type; | 80 | char *type; |
79 | char *name; | 81 | char *name; |
80 | int offset; | 82 | int offset; |
@@ -179,6 +181,7 @@ struct print_fmt { | |||
179 | 181 | ||
180 | struct event { | 182 | struct event { |
181 | struct event *next; | 183 | struct event *next; |
184 | struct pevent *pevent; | ||
182 | char *name; | 185 | char *name; |
183 | int id; | 186 | int id; |
184 | int flags; | 187 | int flags; |
@@ -204,24 +207,80 @@ enum event_sort_type { | |||
204 | EVENT_SORT_SYSTEM, | 207 | EVENT_SORT_SYSTEM, |
205 | }; | 208 | }; |
206 | 209 | ||
207 | extern int old_format; | 210 | struct cmdline; |
211 | struct cmdline_list; | ||
212 | struct func_map; | ||
213 | struct func_list; | ||
208 | 214 | ||
209 | void parse_set_info(int nr_cpus, int long_sz); | 215 | struct pevent { |
216 | int header_page_ts_offset; | ||
217 | int header_page_ts_size; | ||
218 | int header_page_size_offset; | ||
219 | int header_page_size_size; | ||
220 | int header_page_data_offset; | ||
221 | int header_page_data_size; | ||
222 | |||
223 | int file_bigendian; | ||
224 | int host_bigendian; | ||
225 | |||
226 | int latency_format; | ||
227 | |||
228 | int old_format; | ||
229 | |||
230 | int cpus; | ||
231 | int long_size; | ||
232 | |||
233 | struct cmdline *cmdlines; | ||
234 | struct cmdline_list *cmdlist; | ||
235 | int cmdline_count; | ||
236 | |||
237 | struct func_map *func_map; | ||
238 | struct func_list *funclist; | ||
239 | unsigned int func_count; | ||
240 | |||
241 | struct printk_map *printk_map; | ||
242 | struct printk_list *printklist; | ||
243 | unsigned int printk_count; | ||
244 | |||
245 | struct event *event_list; | ||
246 | int nr_events; | ||
247 | struct event **events; | ||
248 | enum event_sort_type last_type; | ||
249 | |||
250 | int type_offset; | ||
251 | int type_size; | ||
252 | |||
253 | int pid_offset; | ||
254 | int pid_size; | ||
255 | |||
256 | int pc_offset; | ||
257 | int pc_size; | ||
258 | |||
259 | int flags_offset; | ||
260 | int flags_size; | ||
261 | |||
262 | int ld_offset; | ||
263 | int ld_size; | ||
264 | |||
265 | struct format_field *bprint_ip_field; | ||
266 | struct format_field *bprint_fmt_field; | ||
267 | struct format_field *bprint_buf_field; | ||
268 | }; | ||
269 | |||
270 | void parse_set_info(struct pevent *pevent, int nr_cpus, int long_sz); | ||
210 | 271 | ||
211 | void die(char *fmt, ...); | 272 | void die(char *fmt, ...); |
212 | void *malloc_or_die(unsigned int size); | 273 | void *malloc_or_die(unsigned int size); |
213 | void warning(char *fmt, ...); | 274 | void warning(char *fmt, ...); |
214 | 275 | ||
215 | extern int file_bigendian; | ||
216 | extern int host_bigendian; | ||
217 | |||
218 | int bigendian(void); | 276 | int bigendian(void); |
219 | 277 | ||
220 | static inline unsigned short __data2host2(unsigned short data) | 278 | static inline unsigned short |
279 | __data2host2(struct pevent *pevent, unsigned short data) | ||
221 | { | 280 | { |
222 | unsigned short swap; | 281 | unsigned short swap; |
223 | 282 | ||
224 | if (host_bigendian == file_bigendian) | 283 | if (pevent->host_bigendian == pevent->file_bigendian) |
225 | return data; | 284 | return data; |
226 | 285 | ||
227 | swap = ((data & 0xffULL) << 8) | | 286 | swap = ((data & 0xffULL) << 8) | |
@@ -230,11 +289,12 @@ static inline unsigned short __data2host2(unsigned short data) | |||
230 | return swap; | 289 | return swap; |
231 | } | 290 | } |
232 | 291 | ||
233 | static inline unsigned int __data2host4(unsigned int data) | 292 | static inline unsigned int |
293 | __data2host4(struct pevent *pevent, unsigned int data) | ||
234 | { | 294 | { |
235 | unsigned int swap; | 295 | unsigned int swap; |
236 | 296 | ||
237 | if (host_bigendian == file_bigendian) | 297 | if (pevent->host_bigendian == pevent->file_bigendian) |
238 | return data; | 298 | return data; |
239 | 299 | ||
240 | swap = ((data & 0xffULL) << 24) | | 300 | swap = ((data & 0xffULL) << 24) | |
@@ -245,11 +305,12 @@ static inline unsigned int __data2host4(unsigned int data) | |||
245 | return swap; | 305 | return swap; |
246 | } | 306 | } |
247 | 307 | ||
248 | static inline unsigned long long __data2host8(unsigned long long data) | 308 | static inline unsigned long long |
309 | __data2host8(struct pevent *pevent, unsigned long long data) | ||
249 | { | 310 | { |
250 | unsigned long long swap; | 311 | unsigned long long swap; |
251 | 312 | ||
252 | if (host_bigendian == file_bigendian) | 313 | if (pevent->host_bigendian == pevent->file_bigendian) |
253 | return data; | 314 | return data; |
254 | 315 | ||
255 | swap = ((data & 0xffULL) << 56) | | 316 | swap = ((data & 0xffULL) << 56) | |
@@ -264,18 +325,9 @@ static inline unsigned long long __data2host8(unsigned long long data) | |||
264 | return swap; | 325 | return swap; |
265 | } | 326 | } |
266 | 327 | ||
267 | #define data2host2(ptr) __data2host2(*(unsigned short *)ptr) | 328 | #define data2host2(pevent, ptr) __data2host2(pevent, *(unsigned short *)ptr) |
268 | #define data2host4(ptr) __data2host4(*(unsigned int *)ptr) | 329 | #define data2host4(pevent, ptr) __data2host4(pevent, *(unsigned int *)ptr) |
269 | #define data2host8(ptr) __data2host8(*(unsigned long long *)ptr) | 330 | #define data2host8(pevent, ptr) __data2host8(pevent, *(unsigned long long *)ptr) |
270 | |||
271 | extern int header_page_ts_offset; | ||
272 | extern int header_page_ts_size; | ||
273 | extern int header_page_size_offset; | ||
274 | extern int header_page_size_size; | ||
275 | extern int header_page_data_offset; | ||
276 | extern int header_page_data_size; | ||
277 | |||
278 | extern int latency_format; | ||
279 | 331 | ||
280 | /* taken from kernel/trace/trace.h */ | 332 | /* taken from kernel/trace/trace.h */ |
281 | enum trace_flag_type { | 333 | enum trace_flag_type { |
@@ -286,47 +338,103 @@ enum trace_flag_type { | |||
286 | TRACE_FLAG_SOFTIRQ = 0x10, | 338 | TRACE_FLAG_SOFTIRQ = 0x10, |
287 | }; | 339 | }; |
288 | 340 | ||
289 | int pevent_register_comm(char *comm, int pid); | 341 | int pevent_register_comm(struct pevent *pevent, char *comm, int pid); |
290 | int pevent_register_function(char *name, unsigned long long addr, char *mod); | 342 | int pevent_register_function(struct pevent *pevetn, char *name, |
291 | int pevent_register_print_string(char *fmt, unsigned long long addr); | 343 | unsigned long long addr, char *mod); |
344 | int pevent_register_print_string(struct pevent *pevent, char *fmt, | ||
345 | unsigned long long addr); | ||
292 | 346 | ||
293 | void pevent_print_event(struct trace_seq *s, | 347 | void pevent_print_event(struct pevent *pevent, struct trace_seq *s, |
294 | int cpu, void *data, int size, unsigned long long nsecs); | 348 | int cpu, void *data, int size, unsigned long long nsecs); |
295 | 349 | ||
296 | int pevent_parse_header_page(char *buf, unsigned long size); | 350 | int pevent_parse_header_page(struct pevent *pevent, char *buf, unsigned long size); |
297 | 351 | ||
298 | int pevent_parse_event(char *buf, unsigned long size, char *sys); | 352 | int pevent_parse_event(struct pevent *pevent, char *buf, unsigned long size, char *sys); |
299 | 353 | ||
300 | int pevent_register_event_handler(int id, char *sys_name, char *event_name, | 354 | int pevent_register_event_handler(struct pevent *pevent, int id, char *sys_name, char *event_name, |
301 | pevent_event_handler_func func); | 355 | pevent_event_handler_func func); |
302 | 356 | ||
303 | struct format_field *pevent_find_common_field(struct event *event, const char *name); | 357 | struct format_field *pevent_find_common_field(struct event *event, const char *name); |
304 | struct format_field *pevent_find_field(struct event *event, const char *name); | 358 | struct format_field *pevent_find_field(struct event *event, const char *name); |
305 | struct format_field *pevent_find_any_field(struct event *event, const char *name); | 359 | struct format_field *pevent_find_any_field(struct event *event, const char *name); |
306 | 360 | ||
307 | const char *pevent_find_function(unsigned long long addr); | 361 | const char *pevent_find_function(struct pevent *pevent, unsigned long long addr); |
308 | unsigned long long pevent_read_number(const void *ptr, int size); | 362 | unsigned long long pevent_read_number(struct pevent *pevent, const void *ptr, int size); |
309 | int pevent_read_number_field(struct format_field *field, const void *data, | 363 | int pevent_read_number_field(struct format_field *field, const void *data, |
310 | unsigned long long *value); | 364 | unsigned long long *value); |
311 | 365 | ||
312 | struct event *pevent_find_event(int id); | 366 | struct event *pevent_find_event(struct pevent *pevent, int id); |
313 | 367 | ||
314 | struct event * | 368 | struct event * |
315 | pevent_find_event_by_name(const char *sys, const char *name); | 369 | pevent_find_event_by_name(struct pevent *pevent, const char *sys, const char *name); |
316 | 370 | ||
317 | void pevent_data_lat_fmt(struct trace_seq *s, void *data, int size __unused); | 371 | void pevent_data_lat_fmt(struct pevent *pevent, |
318 | int pevent_data_type(void *data); | 372 | struct trace_seq *s, void *data, int size __unused); |
319 | struct event *pevent_data_event_from_type(int type); | 373 | int pevent_data_type(struct pevent *pevent, void *data); |
320 | int pevent_data_pid(void *data); | 374 | struct event *pevent_data_event_from_type(struct pevent *pevent, int type); |
321 | const char *pevent_data_comm_from_pid(int pid); | 375 | int pevent_data_pid(struct pevent *pevent, void *data); |
376 | const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid); | ||
322 | void pevent_event_info(struct trace_seq *s, struct event *event, | 377 | void pevent_event_info(struct trace_seq *s, struct event *event, |
323 | int cpu, void *data, int size, unsigned long long nsecs); | 378 | int cpu, void *data, int size, unsigned long long nsecs); |
324 | 379 | ||
325 | struct event **pevent_list_events(enum event_sort_type); | 380 | struct event **pevent_list_events(struct pevent *pevent, enum event_sort_type); |
381 | |||
382 | static inline int pevent_get_cpus(struct pevent *pevent) | ||
383 | { | ||
384 | return pevent->cpus; | ||
385 | } | ||
386 | |||
387 | static inline void pevent_set_cpus(struct pevent *pevent, int cpus) | ||
388 | { | ||
389 | pevent->cpus = cpus; | ||
390 | } | ||
391 | |||
392 | static inline int pevent_get_long_size(struct pevent *pevent) | ||
393 | { | ||
394 | return pevent->long_size; | ||
395 | } | ||
396 | |||
397 | static inline void pevent_set_long_size(struct pevent *pevent, int long_size) | ||
398 | { | ||
399 | pevent->long_size = long_size; | ||
400 | } | ||
401 | |||
402 | static inline int pevent_is_file_bigendian(struct pevent *pevent) | ||
403 | { | ||
404 | return pevent->file_bigendian; | ||
405 | } | ||
406 | |||
407 | static inline void pevent_set_file_bigendian(struct pevent *pevent, int endian) | ||
408 | { | ||
409 | pevent->file_bigendian = endian; | ||
410 | } | ||
411 | |||
412 | static inline int pevent_is_host_bigendian(struct pevent *pevent) | ||
413 | { | ||
414 | return pevent->host_bigendian; | ||
415 | } | ||
416 | |||
417 | static inline void pevent_set_host_bigendian(struct pevent *pevent, int endian) | ||
418 | { | ||
419 | pevent->host_bigendian = endian; | ||
420 | } | ||
421 | |||
422 | static inline int pevent_is_latency_format(struct pevent *pevent) | ||
423 | { | ||
424 | return pevent->latency_format; | ||
425 | } | ||
426 | |||
427 | static inline void pevent_set_latency_format(struct pevent *pevent, int lat) | ||
428 | { | ||
429 | pevent->latency_format = lat; | ||
430 | } | ||
431 | |||
432 | struct pevent *pevent_alloc(void); | ||
433 | void pevent_free(struct pevent *pevent); | ||
326 | 434 | ||
327 | /* for debugging */ | 435 | /* for debugging */ |
328 | void pevent_print_funcs(void); | 436 | void pevent_print_funcs(struct pevent *pevent); |
329 | void pevent_print_printk(void); | 437 | void pevent_print_printk(struct pevent *pevent); |
330 | 438 | ||
331 | 439 | ||
332 | #endif /* _PARSE_EVENTS_H */ | 440 | #endif /* _PARSE_EVENTS_H */ |