diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-08-06 22:33:02 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-08-26 00:32:06 -0400 |
commit | aa38e9fc3ea804290efd3a39316d7f7e6c945800 (patch) | |
tree | 8f9766b20c9006c1373f11c927fb46441e01df0f /kernel | |
parent | 6591b493871cf9b17de2ba272edb8ab529a8058b (diff) |
tracing/filters: Add filter_type to struct ftrace_event_field
The type of a field is stored as a string in @type, and here
we add @filter_type which is an enum value.
This prepares for later patches, so we can specifically assign
different @filter_type for the same @type.
For example normally a "char *" field is treated as a ptr,
but we may want it to be treated as a string when doing filting.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4A7B925E.9030605@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.h | 2 | ||||
-rw-r--r-- | kernel/trace/trace_events.c | 2 | ||||
-rw-r--r-- | kernel/trace/trace_events_filter.c | 23 |
3 files changed, 18 insertions, 9 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 300ef788c976..64dda5709cb9 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -755,6 +755,7 @@ struct ftrace_event_field { | |||
755 | struct list_head link; | 755 | struct list_head link; |
756 | char *name; | 756 | char *name; |
757 | char *type; | 757 | char *type; |
758 | int filter_type; | ||
758 | int offset; | 759 | int offset; |
759 | int size; | 760 | int size; |
760 | int is_signed; | 761 | int is_signed; |
@@ -800,6 +801,7 @@ extern int apply_subsystem_event_filter(struct event_subsystem *system, | |||
800 | char *filter_string); | 801 | char *filter_string); |
801 | extern void print_subsystem_event_filter(struct event_subsystem *system, | 802 | extern void print_subsystem_event_filter(struct event_subsystem *system, |
802 | struct trace_seq *s); | 803 | struct trace_seq *s); |
804 | extern int filter_assign_type(const char *type); | ||
803 | 805 | ||
804 | static inline int | 806 | static inline int |
805 | filter_check_discard(struct ftrace_event_call *call, void *rec, | 807 | filter_check_discard(struct ftrace_event_call *call, void *rec, |
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 79d352027a61..5740e90f4ca1 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
@@ -44,9 +44,11 @@ int trace_define_field(struct ftrace_event_call *call, const char *type, | |||
44 | if (!field->type) | 44 | if (!field->type) |
45 | goto err; | 45 | goto err; |
46 | 46 | ||
47 | field->filter_type = filter_assign_type(type); | ||
47 | field->offset = offset; | 48 | field->offset = offset; |
48 | field->size = size; | 49 | field->size = size; |
49 | field->is_signed = is_signed; | 50 | field->is_signed = is_signed; |
51 | |||
50 | list_add(&field->link, &call->fields); | 52 | list_add(&field->link, &call->fields); |
51 | 53 | ||
52 | return 0; | 54 | return 0; |
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 490337abed75..22e6d822bbaa 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c | |||
@@ -476,11 +476,12 @@ static int filter_add_pred_fn(struct filter_parse_state *ps, | |||
476 | } | 476 | } |
477 | 477 | ||
478 | enum { | 478 | enum { |
479 | FILTER_STATIC_STRING = 1, | 479 | FILTER_OTHER = 0, |
480 | FILTER_DYN_STRING | 480 | FILTER_STATIC_STRING, |
481 | FILTER_DYN_STRING, | ||
481 | }; | 482 | }; |
482 | 483 | ||
483 | static int is_string_field(const char *type) | 484 | int filter_assign_type(const char *type) |
484 | { | 485 | { |
485 | if (strstr(type, "__data_loc") && strstr(type, "char")) | 486 | if (strstr(type, "__data_loc") && strstr(type, "char")) |
486 | return FILTER_DYN_STRING; | 487 | return FILTER_DYN_STRING; |
@@ -488,12 +489,18 @@ static int is_string_field(const char *type) | |||
488 | if (strchr(type, '[') && strstr(type, "char")) | 489 | if (strchr(type, '[') && strstr(type, "char")) |
489 | return FILTER_STATIC_STRING; | 490 | return FILTER_STATIC_STRING; |
490 | 491 | ||
491 | return 0; | 492 | return FILTER_OTHER; |
493 | } | ||
494 | |||
495 | static bool is_string_field(struct ftrace_event_field *field) | ||
496 | { | ||
497 | return field->filter_type == FILTER_DYN_STRING || | ||
498 | field->filter_type == FILTER_STATIC_STRING; | ||
492 | } | 499 | } |
493 | 500 | ||
494 | static int is_legal_op(struct ftrace_event_field *field, int op) | 501 | static int is_legal_op(struct ftrace_event_field *field, int op) |
495 | { | 502 | { |
496 | if (is_string_field(field->type) && (op != OP_EQ && op != OP_NE)) | 503 | if (is_string_field(field) && (op != OP_EQ && op != OP_NE)) |
497 | return 0; | 504 | return 0; |
498 | 505 | ||
499 | return 1; | 506 | return 1; |
@@ -550,7 +557,6 @@ static int filter_add_pred(struct filter_parse_state *ps, | |||
550 | struct ftrace_event_field *field; | 557 | struct ftrace_event_field *field; |
551 | filter_pred_fn_t fn; | 558 | filter_pred_fn_t fn; |
552 | unsigned long long val; | 559 | unsigned long long val; |
553 | int string_type; | ||
554 | int ret; | 560 | int ret; |
555 | 561 | ||
556 | pred->fn = filter_pred_none; | 562 | pred->fn = filter_pred_none; |
@@ -578,9 +584,8 @@ static int filter_add_pred(struct filter_parse_state *ps, | |||
578 | return -EINVAL; | 584 | return -EINVAL; |
579 | } | 585 | } |
580 | 586 | ||
581 | string_type = is_string_field(field->type); | 587 | if (is_string_field(field)) { |
582 | if (string_type) { | 588 | if (field->filter_type == FILTER_STATIC_STRING) |
583 | if (string_type == FILTER_STATIC_STRING) | ||
584 | fn = filter_pred_string; | 589 | fn = filter_pred_string; |
585 | else | 590 | else |
586 | fn = filter_pred_strloc; | 591 | fn = filter_pred_strloc; |