diff options
Diffstat (limited to 'tools/lib/traceevent/event-parse.h')
-rw-r--r-- | tools/lib/traceevent/event-parse.h | 86 |
1 files changed, 72 insertions, 14 deletions
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 8d73d2594f65..791c539374c7 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <stdbool.h> | 23 | #include <stdbool.h> |
24 | #include <stdarg.h> | 24 | #include <stdarg.h> |
25 | #include <regex.h> | 25 | #include <regex.h> |
26 | #include <string.h> | ||
26 | 27 | ||
27 | #ifndef __maybe_unused | 28 | #ifndef __maybe_unused |
28 | #define __maybe_unused __attribute__((unused)) | 29 | #define __maybe_unused __attribute__((unused)) |
@@ -57,6 +58,12 @@ struct pevent_record { | |||
57 | #endif | 58 | #endif |
58 | }; | 59 | }; |
59 | 60 | ||
61 | enum trace_seq_fail { | ||
62 | TRACE_SEQ__GOOD, | ||
63 | TRACE_SEQ__BUFFER_POISONED, | ||
64 | TRACE_SEQ__MEM_ALLOC_FAILED, | ||
65 | }; | ||
66 | |||
60 | /* | 67 | /* |
61 | * Trace sequences are used to allow a function to call several other functions | 68 | * Trace sequences are used to allow a function to call several other functions |
62 | * to create a string of data to use (up to a max of PAGE_SIZE). | 69 | * to create a string of data to use (up to a max of PAGE_SIZE). |
@@ -67,6 +74,7 @@ struct trace_seq { | |||
67 | unsigned int buffer_size; | 74 | unsigned int buffer_size; |
68 | unsigned int len; | 75 | unsigned int len; |
69 | unsigned int readpos; | 76 | unsigned int readpos; |
77 | enum trace_seq_fail state; | ||
70 | }; | 78 | }; |
71 | 79 | ||
72 | void trace_seq_init(struct trace_seq *s); | 80 | void trace_seq_init(struct trace_seq *s); |
@@ -97,7 +105,7 @@ typedef int (*pevent_event_handler_func)(struct trace_seq *s, | |||
97 | void *context); | 105 | void *context); |
98 | 106 | ||
99 | typedef int (*pevent_plugin_load_func)(struct pevent *pevent); | 107 | typedef int (*pevent_plugin_load_func)(struct pevent *pevent); |
100 | typedef int (*pevent_plugin_unload_func)(void); | 108 | typedef int (*pevent_plugin_unload_func)(struct pevent *pevent); |
101 | 109 | ||
102 | struct plugin_option { | 110 | struct plugin_option { |
103 | struct plugin_option *next; | 111 | struct plugin_option *next; |
@@ -122,7 +130,7 @@ struct plugin_option { | |||
122 | * PEVENT_PLUGIN_UNLOADER: (optional) | 130 | * PEVENT_PLUGIN_UNLOADER: (optional) |
123 | * The function called just before unloading | 131 | * The function called just before unloading |
124 | * | 132 | * |
125 | * int PEVENT_PLUGIN_UNLOADER(void) | 133 | * int PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) |
126 | * | 134 | * |
127 | * PEVENT_PLUGIN_OPTIONS: (optional) | 135 | * PEVENT_PLUGIN_OPTIONS: (optional) |
128 | * Plugin options that can be set before loading | 136 | * Plugin options that can be set before loading |
@@ -355,12 +363,35 @@ enum pevent_flag { | |||
355 | _PE(READ_FORMAT_FAILED, "failed to read event format"), \ | 363 | _PE(READ_FORMAT_FAILED, "failed to read event format"), \ |
356 | _PE(READ_PRINT_FAILED, "failed to read event print fmt"), \ | 364 | _PE(READ_PRINT_FAILED, "failed to read event print fmt"), \ |
357 | _PE(OLD_FTRACE_ARG_FAILED,"failed to allocate field name for ftrace"),\ | 365 | _PE(OLD_FTRACE_ARG_FAILED,"failed to allocate field name for ftrace"),\ |
358 | _PE(INVALID_ARG_TYPE, "invalid argument type") | 366 | _PE(INVALID_ARG_TYPE, "invalid argument type"), \ |
367 | _PE(INVALID_EXP_TYPE, "invalid expression type"), \ | ||
368 | _PE(INVALID_OP_TYPE, "invalid operator type"), \ | ||
369 | _PE(INVALID_EVENT_NAME, "invalid event name"), \ | ||
370 | _PE(EVENT_NOT_FOUND, "no event found"), \ | ||
371 | _PE(SYNTAX_ERROR, "syntax error"), \ | ||
372 | _PE(ILLEGAL_RVALUE, "illegal rvalue"), \ | ||
373 | _PE(ILLEGAL_LVALUE, "illegal lvalue for string comparison"), \ | ||
374 | _PE(INVALID_REGEX, "regex did not compute"), \ | ||
375 | _PE(ILLEGAL_STRING_CMP, "illegal comparison for string"), \ | ||
376 | _PE(ILLEGAL_INTEGER_CMP,"illegal comparison for integer"), \ | ||
377 | _PE(REPARENT_NOT_OP, "cannot reparent other than OP"), \ | ||
378 | _PE(REPARENT_FAILED, "failed to reparent filter OP"), \ | ||
379 | _PE(BAD_FILTER_ARG, "bad arg in filter tree"), \ | ||
380 | _PE(UNEXPECTED_TYPE, "unexpected type (not a value)"), \ | ||
381 | _PE(ILLEGAL_TOKEN, "illegal token"), \ | ||
382 | _PE(INVALID_PAREN, "open parenthesis cannot come here"), \ | ||
383 | _PE(UNBALANCED_PAREN, "unbalanced number of parenthesis"), \ | ||
384 | _PE(UNKNOWN_TOKEN, "unknown token"), \ | ||
385 | _PE(FILTER_NOT_FOUND, "no filter found"), \ | ||
386 | _PE(NOT_A_NUMBER, "must have number field"), \ | ||
387 | _PE(NO_FILTER, "no filters exists"), \ | ||
388 | _PE(FILTER_MISS, "record does not match to filter") | ||
359 | 389 | ||
360 | #undef _PE | 390 | #undef _PE |
361 | #define _PE(__code, __str) PEVENT_ERRNO__ ## __code | 391 | #define _PE(__code, __str) PEVENT_ERRNO__ ## __code |
362 | enum pevent_errno { | 392 | enum pevent_errno { |
363 | PEVENT_ERRNO__SUCCESS = 0, | 393 | PEVENT_ERRNO__SUCCESS = 0, |
394 | PEVENT_ERRNO__FILTER_MATCH = PEVENT_ERRNO__SUCCESS, | ||
364 | 395 | ||
365 | /* | 396 | /* |
366 | * Choose an arbitrary negative big number not to clash with standard | 397 | * Choose an arbitrary negative big number not to clash with standard |
@@ -377,6 +408,12 @@ enum pevent_errno { | |||
377 | }; | 408 | }; |
378 | #undef _PE | 409 | #undef _PE |
379 | 410 | ||
411 | struct plugin_list; | ||
412 | |||
413 | struct plugin_list *traceevent_load_plugins(struct pevent *pevent); | ||
414 | void traceevent_unload_plugins(struct plugin_list *plugin_list, | ||
415 | struct pevent *pevent); | ||
416 | |||
380 | struct cmdline; | 417 | struct cmdline; |
381 | struct cmdline_list; | 418 | struct cmdline_list; |
382 | struct func_map; | 419 | struct func_map; |
@@ -522,6 +559,15 @@ __data2host8(struct pevent *pevent, unsigned long long data) | |||
522 | __data2host8(pevent, __val); \ | 559 | __data2host8(pevent, __val); \ |
523 | }) | 560 | }) |
524 | 561 | ||
562 | static inline int traceevent_host_bigendian(void) | ||
563 | { | ||
564 | unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 }; | ||
565 | unsigned int val; | ||
566 | |||
567 | memcpy(&val, str, 4); | ||
568 | return val == 0x01020304; | ||
569 | } | ||
570 | |||
525 | /* taken from kernel/trace/trace.h */ | 571 | /* taken from kernel/trace/trace.h */ |
526 | enum trace_flag_type { | 572 | enum trace_flag_type { |
527 | TRACE_FLAG_IRQS_OFF = 0x01, | 573 | TRACE_FLAG_IRQS_OFF = 0x01, |
@@ -547,7 +593,9 @@ int pevent_parse_header_page(struct pevent *pevent, char *buf, unsigned long siz | |||
547 | 593 | ||
548 | enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf, | 594 | enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf, |
549 | unsigned long size, const char *sys); | 595 | unsigned long size, const char *sys); |
550 | enum pevent_errno pevent_parse_format(struct event_format **eventp, const char *buf, | 596 | enum pevent_errno pevent_parse_format(struct pevent *pevent, |
597 | struct event_format **eventp, | ||
598 | const char *buf, | ||
551 | unsigned long size, const char *sys); | 599 | unsigned long size, const char *sys); |
552 | void pevent_free_format(struct event_format *event); | 600 | void pevent_free_format(struct event_format *event); |
553 | 601 | ||
@@ -576,10 +624,15 @@ int pevent_print_func_field(struct trace_seq *s, const char *fmt, | |||
576 | int pevent_register_event_handler(struct pevent *pevent, int id, | 624 | int pevent_register_event_handler(struct pevent *pevent, int id, |
577 | const char *sys_name, const char *event_name, | 625 | const char *sys_name, const char *event_name, |
578 | pevent_event_handler_func func, void *context); | 626 | pevent_event_handler_func func, void *context); |
627 | int pevent_unregister_event_handler(struct pevent *pevent, int id, | ||
628 | const char *sys_name, const char *event_name, | ||
629 | pevent_event_handler_func func, void *context); | ||
579 | int pevent_register_print_function(struct pevent *pevent, | 630 | int pevent_register_print_function(struct pevent *pevent, |
580 | pevent_func_handler func, | 631 | pevent_func_handler func, |
581 | enum pevent_func_arg_type ret_type, | 632 | enum pevent_func_arg_type ret_type, |
582 | char *name, ...); | 633 | char *name, ...); |
634 | int pevent_unregister_print_function(struct pevent *pevent, | ||
635 | pevent_func_handler func, char *name); | ||
583 | 636 | ||
584 | struct format_field *pevent_find_common_field(struct event_format *event, const char *name); | 637 | struct format_field *pevent_find_common_field(struct event_format *event, const char *name); |
585 | struct format_field *pevent_find_field(struct event_format *event, const char *name); | 638 | struct format_field *pevent_find_field(struct event_format *event, const char *name); |
@@ -811,18 +864,22 @@ struct filter_type { | |||
811 | struct filter_arg *filter; | 864 | struct filter_arg *filter; |
812 | }; | 865 | }; |
813 | 866 | ||
867 | #define PEVENT_FILTER_ERROR_BUFSZ 1024 | ||
868 | |||
814 | struct event_filter { | 869 | struct event_filter { |
815 | struct pevent *pevent; | 870 | struct pevent *pevent; |
816 | int filters; | 871 | int filters; |
817 | struct filter_type *event_filters; | 872 | struct filter_type *event_filters; |
873 | char error_buffer[PEVENT_FILTER_ERROR_BUFSZ]; | ||
818 | }; | 874 | }; |
819 | 875 | ||
820 | struct event_filter *pevent_filter_alloc(struct pevent *pevent); | 876 | struct event_filter *pevent_filter_alloc(struct pevent *pevent); |
821 | 877 | ||
822 | #define FILTER_NONE -2 | 878 | /* for backward compatibility */ |
823 | #define FILTER_NOEXIST -1 | 879 | #define FILTER_NONE PEVENT_ERRNO__FILTER_NOT_FOUND |
824 | #define FILTER_MISS 0 | 880 | #define FILTER_NOEXIST PEVENT_ERRNO__NO_FILTER |
825 | #define FILTER_MATCH 1 | 881 | #define FILTER_MISS PEVENT_ERRNO__FILTER_MISS |
882 | #define FILTER_MATCH PEVENT_ERRNO__FILTER_MATCH | ||
826 | 883 | ||
827 | enum filter_trivial_type { | 884 | enum filter_trivial_type { |
828 | FILTER_TRIVIAL_FALSE, | 885 | FILTER_TRIVIAL_FALSE, |
@@ -830,20 +887,21 @@ enum filter_trivial_type { | |||
830 | FILTER_TRIVIAL_BOTH, | 887 | FILTER_TRIVIAL_BOTH, |
831 | }; | 888 | }; |
832 | 889 | ||
833 | int pevent_filter_add_filter_str(struct event_filter *filter, | 890 | enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter, |
834 | const char *filter_str, | 891 | const char *filter_str); |
835 | char **error_str); | ||
836 | 892 | ||
893 | enum pevent_errno pevent_filter_match(struct event_filter *filter, | ||
894 | struct pevent_record *record); | ||
837 | 895 | ||
838 | int pevent_filter_match(struct event_filter *filter, | 896 | int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err, |
839 | struct pevent_record *record); | 897 | char *buf, size_t buflen); |
840 | 898 | ||
841 | int pevent_event_filtered(struct event_filter *filter, | 899 | int pevent_event_filtered(struct event_filter *filter, |
842 | int event_id); | 900 | int event_id); |
843 | 901 | ||
844 | void pevent_filter_reset(struct event_filter *filter); | 902 | void pevent_filter_reset(struct event_filter *filter); |
845 | 903 | ||
846 | void pevent_filter_clear_trivial(struct event_filter *filter, | 904 | int pevent_filter_clear_trivial(struct event_filter *filter, |
847 | enum filter_trivial_type type); | 905 | enum filter_trivial_type type); |
848 | 906 | ||
849 | void pevent_filter_free(struct event_filter *filter); | 907 | void pevent_filter_free(struct event_filter *filter); |