diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-10-14 15:43:36 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-15 04:42:36 -0400 |
commit | b99af874829cba2b30d212bc6fd31b56275ee4d2 (patch) | |
tree | 3fe1964f4d538be5a2fac5b9e934631f528d18cb /tools/perf/util/trace-event-parse.c | |
parent | 0959b8d65ce26131c2d5ccfa518a7b76529280fa (diff) |
perf tools: Handle * as typecast in trace parsing
The '*' is currently only treated as a multiplication, and it
needs to be handled as a typecast pointer.
This is the version used by trace-cmd.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <20091014194358.409327875@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/trace-event-parse.c')
-rw-r--r-- | tools/perf/util/trace-event-parse.c | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 7aeedb09ea7d..f73ee55b51e8 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c | |||
@@ -1217,7 +1217,24 @@ process_op(struct event *event, struct print_arg *arg, char **tok) | |||
1217 | 1217 | ||
1218 | right = malloc_or_die(sizeof(*right)); | 1218 | right = malloc_or_die(sizeof(*right)); |
1219 | 1219 | ||
1220 | type = process_arg(event, right, tok); | 1220 | type = read_token_item(&token); |
1221 | *tok = token; | ||
1222 | |||
1223 | /* could just be a type pointer */ | ||
1224 | if ((strcmp(arg->op.op, "*") == 0) && | ||
1225 | type == EVENT_DELIM && (strcmp(token, ")") == 0)) { | ||
1226 | if (left->type != PRINT_ATOM) | ||
1227 | die("bad pointer type"); | ||
1228 | left->atom.atom = realloc(left->atom.atom, | ||
1229 | sizeof(left->atom.atom) + 3); | ||
1230 | strcat(left->atom.atom, " *"); | ||
1231 | *arg = *left; | ||
1232 | free(arg); | ||
1233 | |||
1234 | return type; | ||
1235 | } | ||
1236 | |||
1237 | type = process_arg_token(event, right, tok, type); | ||
1221 | 1238 | ||
1222 | arg->op.right = right; | 1239 | arg->op.right = right; |
1223 | 1240 | ||
@@ -1548,7 +1565,6 @@ process_paren(struct event *event, struct print_arg *arg, char **tok) | |||
1548 | { | 1565 | { |
1549 | struct print_arg *item_arg; | 1566 | struct print_arg *item_arg; |
1550 | enum event_type type; | 1567 | enum event_type type; |
1551 | int ptr_cast = 0; | ||
1552 | char *token; | 1568 | char *token; |
1553 | 1569 | ||
1554 | type = process_arg(event, arg, &token); | 1570 | type = process_arg(event, arg, &token); |
@@ -1556,26 +1572,11 @@ process_paren(struct event *event, struct print_arg *arg, char **tok) | |||
1556 | if (type == EVENT_ERROR) | 1572 | if (type == EVENT_ERROR) |
1557 | return EVENT_ERROR; | 1573 | return EVENT_ERROR; |
1558 | 1574 | ||
1559 | if (type == EVENT_OP) { | 1575 | if (type == EVENT_OP) |
1560 | /* handle the ptr casts */ | 1576 | type = process_op(event, arg, &token); |
1561 | if (!strcmp(token, "*")) { | ||
1562 | /* | ||
1563 | * FIXME: should we zapp whitespaces before ')' ? | ||
1564 | * (may require a peek_token_item()) | ||
1565 | */ | ||
1566 | if (__peek_char() == ')') { | ||
1567 | ptr_cast = 1; | ||
1568 | free_token(token); | ||
1569 | type = read_token_item(&token); | ||
1570 | } | ||
1571 | } | ||
1572 | if (!ptr_cast) { | ||
1573 | type = process_op(event, arg, &token); | ||
1574 | 1577 | ||
1575 | if (type == EVENT_ERROR) | 1578 | if (type == EVENT_ERROR) |
1576 | return EVENT_ERROR; | 1579 | return EVENT_ERROR; |
1577 | } | ||
1578 | } | ||
1579 | 1580 | ||
1580 | if (test_type_token(type, token, EVENT_DELIM, (char *)")")) { | 1581 | if (test_type_token(type, token, EVENT_DELIM, (char *)")")) { |
1581 | free_token(token); | 1582 | free_token(token); |
@@ -1601,13 +1602,6 @@ process_paren(struct event *event, struct print_arg *arg, char **tok) | |||
1601 | item_arg = malloc_or_die(sizeof(*item_arg)); | 1602 | item_arg = malloc_or_die(sizeof(*item_arg)); |
1602 | 1603 | ||
1603 | arg->type = PRINT_TYPE; | 1604 | arg->type = PRINT_TYPE; |
1604 | if (ptr_cast) { | ||
1605 | char *old = arg->atom.atom; | ||
1606 | |||
1607 | arg->atom.atom = malloc_or_die(strlen(old + 3)); | ||
1608 | sprintf(arg->atom.atom, "%s *", old); | ||
1609 | free(old); | ||
1610 | } | ||
1611 | arg->typecast.type = arg->atom.atom; | 1605 | arg->typecast.type = arg->atom.atom; |
1612 | arg->typecast.item = item_arg; | 1606 | arg->typecast.item = item_arg; |
1613 | type = process_arg_token(event, item_arg, &token, type); | 1607 | type = process_arg_token(event, item_arg, &token, type); |