diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-02-15 22:25:37 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-02-15 22:25:37 -0500 |
commit | fa6f2462ec91a70974df0221a6f005de547ef73e (patch) | |
tree | dcddffbfa586f41b685952c8d4a5c030f4cc09b7 /parse-events.h | |
parent | a419a4e2a34a24b9e7d3f91aa195beac1e8bced2 (diff) |
parse-events: Add event filtering on event fields
Add the ability to filter on event fields. This patch implements
the filter on trace-cmd report.
Using the following:
trace-cmd report -F 'sched.sched_switch:next_prio < 100 ||
(prev_comm != "swapper" && next_comm != "swapper")'
Will return a report where prios are under 100 (Real-time)
and does not include any context switch with the swapper task.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'parse-events.h')
-rw-r--r-- | parse-events.h | 116 |
1 files changed, 115 insertions, 1 deletions
diff --git a/parse-events.h b/parse-events.h index 879da4c..cc5af58 100644 --- a/parse-events.h +++ b/parse-events.h | |||
@@ -110,7 +110,7 @@ enum format_flags { | |||
110 | 110 | ||
111 | struct format_field { | 111 | struct format_field { |
112 | struct format_field *next; | 112 | struct format_field *next; |
113 | struct event_format *event; | 113 | struct event_format *event; |
114 | char *type; | 114 | char *type; |
115 | char *name; | 115 | char *name; |
116 | int offset; | 116 | int offset; |
@@ -240,6 +240,18 @@ enum event_sort_type { | |||
240 | EVENT_SORT_SYSTEM, | 240 | EVENT_SORT_SYSTEM, |
241 | }; | 241 | }; |
242 | 242 | ||
243 | enum event_type { | ||
244 | EVENT_ERROR, | ||
245 | EVENT_NONE, | ||
246 | EVENT_SPACE, | ||
247 | EVENT_NEWLINE, | ||
248 | EVENT_OP, | ||
249 | EVENT_DELIM, | ||
250 | EVENT_ITEM, | ||
251 | EVENT_DQUOTE, | ||
252 | EVENT_SQUOTE, | ||
253 | }; | ||
254 | |||
243 | struct cmdline; | 255 | struct cmdline; |
244 | struct cmdline_list; | 256 | struct cmdline_list; |
245 | struct func_map; | 257 | struct func_map; |
@@ -469,9 +481,111 @@ void pevent_free(struct pevent *pevent); | |||
469 | void pevent_ref(struct pevent *pevent); | 481 | void pevent_ref(struct pevent *pevent); |
470 | void pevent_unref(struct pevent *pevent); | 482 | void pevent_unref(struct pevent *pevent); |
471 | 483 | ||
484 | /* access to the internal parser */ | ||
485 | void pevent_buffer_init(const char *buf, unsigned long long size); | ||
486 | enum event_type pevent_read_token(char **tok); | ||
487 | void pevent_free_token(char *token); | ||
488 | |||
472 | /* for debugging */ | 489 | /* for debugging */ |
473 | void pevent_print_funcs(struct pevent *pevent); | 490 | void pevent_print_funcs(struct pevent *pevent); |
474 | void pevent_print_printk(struct pevent *pevent); | 491 | void pevent_print_printk(struct pevent *pevent); |
475 | 492 | ||
493 | /* ----------------------- filtering ----------------------- */ | ||
494 | |||
495 | enum filter_boolean_type { | ||
496 | FILTER_FALSE, | ||
497 | FILTER_TRUE, | ||
498 | }; | ||
499 | |||
500 | enum filter_op_type { | ||
501 | FILTER_OP_AND = 1, | ||
502 | FILTER_OP_OR, | ||
503 | FILTER_OP_NOT, | ||
504 | }; | ||
505 | |||
506 | enum filter_cmp_type { | ||
507 | FILTER_CMP_NONE, | ||
508 | FILTER_CMP_EQ, | ||
509 | FILTER_CMP_NE, | ||
510 | FILTER_CMP_GT, | ||
511 | FILTER_CMP_LT, | ||
512 | FILTER_CMP_GE, | ||
513 | FILTER_CMP_LE, | ||
514 | FILTER_CMP_MATCH, | ||
515 | FILTER_CMP_NOT_MATCH, | ||
516 | FILTER_CMP_CONTAIN, | ||
517 | FILTER_CMP_NOT_CONTAIN, | ||
518 | }; | ||
519 | |||
520 | enum filter_arg_type { | ||
521 | FILTER_ARG_NONE, | ||
522 | FILTER_ARG_BOOLEAN, | ||
523 | FILTER_ARG_OP, | ||
524 | FILTER_ARG_NUM, | ||
525 | FILTER_ARG_STR, | ||
526 | }; | ||
527 | |||
528 | struct fliter_arg; | ||
529 | |||
530 | struct filter_arg_boolean { | ||
531 | enum filter_boolean_type value; | ||
532 | }; | ||
533 | |||
534 | struct filter_arg_op { | ||
535 | enum filter_op_type type; | ||
536 | struct filter_arg *left; | ||
537 | struct filter_arg *right; | ||
538 | }; | ||
539 | |||
540 | struct filter_arg_num { | ||
541 | enum filter_cmp_type type; | ||
542 | struct format_field *field; | ||
543 | unsigned long long val; | ||
544 | }; | ||
545 | |||
546 | struct filter_arg_str { | ||
547 | enum filter_cmp_type type; | ||
548 | struct format_field *field; | ||
549 | char *val; | ||
550 | }; | ||
551 | |||
552 | struct filter_arg { | ||
553 | enum filter_arg_type type; | ||
554 | union { | ||
555 | struct filter_arg_boolean bool; | ||
556 | struct filter_arg_op op; | ||
557 | struct filter_arg_num num; | ||
558 | struct filter_arg_str str; | ||
559 | }; | ||
560 | }; | ||
561 | |||
562 | struct filter_type { | ||
563 | int event_id; | ||
564 | struct event_format *event; | ||
565 | struct filter_arg *filter; | ||
566 | }; | ||
567 | |||
568 | struct event_filter { | ||
569 | struct pevent *pevent; | ||
570 | int filters; | ||
571 | struct filter_type *event_filters; | ||
572 | }; | ||
573 | |||
574 | struct event_filter *pevent_filter_alloc(struct pevent *pevent); | ||
575 | |||
576 | #define FILTER_NONE -2 | ||
577 | #define FILTER_NOEXIST -1 | ||
578 | #define FILTER_MISS 0 | ||
579 | #define FILTER_MATCH 1 | ||
580 | |||
581 | int pevent_filter_add_filter_str(struct event_filter *filter, | ||
582 | const char *filter_str, | ||
583 | char **error_str); | ||
584 | |||
585 | |||
586 | int pevent_filter_match(struct event_filter *filter, | ||
587 | struct record *record); | ||
588 | |||
589 | void pevent_filter_free(struct event_filter *filter); | ||
476 | 590 | ||
477 | #endif /* _PARSE_EVENTS_H */ | 591 | #endif /* _PARSE_EVENTS_H */ |