diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-08-17 23:07:51 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-08-18 00:00:19 +0200 |
commit | 3f9edc2382d5f7c97c693838abb207a9d6bab1fa (patch) | |
tree | 0b51d6d9823d5adca9c8369c3d22966346bb38ac | |
parent | 9df37ddd81f54dd41dc4958055c3a3c9b6840aef (diff) | |
download | blackbird-op-linux-3f9edc2382d5f7c97c693838abb207a9d6bab1fa.tar.gz blackbird-op-linux-3f9edc2382d5f7c97c693838abb207a9d6bab1fa.zip |
perf tools: Make trace event format parser aware of cast to pointers
The ftrace event format parser handles the usual casts but not
the cast to pointers. Such casts have been introduced recently
with the module trace events and raise the following parsing
error:
Fatal: bad op token )
This is because it considers the "*" character as a binary
operator. Make it then aware of casts to pointers.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <1250543271-8383-4-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | tools/perf/util/trace-event-parse.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index ead6a9ad3599..b53b27f34e4e 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -1462,6 +1462,7 @@ process_paren(struct event *event, struct print_arg *arg, char **tok) { struct print_arg *item_arg; enum event_type type; + int ptr_cast = 0; char *token; type = process_arg(event, arg, &token); @@ -1469,11 +1470,26 @@ process_paren(struct event *event, struct print_arg *arg, char **tok) if (type == EVENT_ERROR) return EVENT_ERROR; - if (type == EVENT_OP) - type = process_op(event, arg, &token); + if (type == EVENT_OP) { + /* handle the ptr casts */ + if (!strcmp(token, "*")) { + /* + * FIXME: should we zapp whitespaces before ')' ? + * (may require a peek_token_item()) + */ + if (__peek_char() == ')') { + ptr_cast = 1; + free_token(token); + type = read_token_item(&token); + } + } + if (!ptr_cast) { + type = process_op(event, arg, &token); - if (type == EVENT_ERROR) - return EVENT_ERROR; + if (type == EVENT_ERROR) + return EVENT_ERROR; + } + } if (test_type_token(type, token, EVENT_DELIM, (char *)")")) { free_token(token); @@ -1499,6 +1515,13 @@ process_paren(struct event *event, struct print_arg *arg, char **tok) item_arg = malloc_or_die(sizeof(*item_arg)); arg->type = PRINT_TYPE; + if (ptr_cast) { + char *old = arg->atom.atom; + + arg->atom.atom = malloc_or_die(strlen(old + 3)); + sprintf(arg->atom.atom, "%s *", old); + free(old); + } arg->typecast.type = arg->atom.atom; arg->typecast.item = item_arg; type = process_arg_token(event, item_arg, &token, type); |