aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-08-17 17:07:51 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-17 18:00:19 -0400
commit3f9edc2382d5f7c97c693838abb207a9d6bab1fa (patch)
tree0b51d6d9823d5adca9c8369c3d22966346bb38ac /tools
parent9df37ddd81f54dd41dc4958055c3a3c9b6840aef (diff)
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/trace-event-parse.c31
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)
1462{ 1462{
1463 struct print_arg *item_arg; 1463 struct print_arg *item_arg;
1464 enum event_type type; 1464 enum event_type type;
1465 int ptr_cast = 0;
1465 char *token; 1466 char *token;
1466 1467
1467 type = process_arg(event, arg, &token); 1468 type = process_arg(event, arg, &token);
@@ -1469,11 +1470,26 @@ process_paren(struct event *event, struct print_arg *arg, char **tok)
1469 if (type == EVENT_ERROR) 1470 if (type == EVENT_ERROR)
1470 return EVENT_ERROR; 1471 return EVENT_ERROR;
1471 1472
1472 if (type == EVENT_OP) 1473 if (type == EVENT_OP) {
1473 type = process_op(event, arg, &token); 1474 /* handle the ptr casts */
1475 if (!strcmp(token, "*")) {
1476 /*
1477 * FIXME: should we zapp whitespaces before ')' ?
1478 * (may require a peek_token_item())
1479 */
1480 if (__peek_char() == ')') {
1481 ptr_cast = 1;
1482 free_token(token);
1483 type = read_token_item(&token);
1484 }
1485 }
1486 if (!ptr_cast) {
1487 type = process_op(event, arg, &token);
1474 1488
1475 if (type == EVENT_ERROR) 1489 if (type == EVENT_ERROR)
1476 return EVENT_ERROR; 1490 return EVENT_ERROR;
1491 }
1492 }
1477 1493
1478 if (test_type_token(type, token, EVENT_DELIM, (char *)")")) { 1494 if (test_type_token(type, token, EVENT_DELIM, (char *)")")) {
1479 free_token(token); 1495 free_token(token);
@@ -1499,6 +1515,13 @@ process_paren(struct event *event, struct print_arg *arg, char **tok)
1499 item_arg = malloc_or_die(sizeof(*item_arg)); 1515 item_arg = malloc_or_die(sizeof(*item_arg));
1500 1516
1501 arg->type = PRINT_TYPE; 1517 arg->type = PRINT_TYPE;
1518 if (ptr_cast) {
1519 char *old = arg->atom.atom;
1520
1521 arg->atom.atom = malloc_or_die(strlen(old + 3));
1522 sprintf(arg->atom.atom, "%s *", old);
1523 free(old);
1524 }
1502 arg->typecast.type = arg->atom.atom; 1525 arg->typecast.type = arg->atom.atom;
1503 arg->typecast.item = item_arg; 1526 arg->typecast.item = item_arg;
1504 type = process_arg_token(event, item_arg, &token, type); 1527 type = process_arg_token(event, item_arg, &token, type);