From: Frederic Weisbecker <fweisbec@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Mike Galbraith <efault@gmx.de>,
Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH 4/4] perf tools: Make trace event format parser aware of cast to pointers
Date: Mon, 17 Aug 2009 23:07:51 +0200 [thread overview]
Message-ID: <1250543271-8383-4-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <20090817144007.GC3602@elte.hu>
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>
---
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 ead6a9a..b53b27f 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);
--
1.6.2.3
next prev parent reply other threads:[~2009-08-17 21:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-17 14:18 [PATCH 1/4] perf tools: Add trace event debugfs IO handler Frederic Weisbecker
2009-08-17 14:18 ` [PATCH 2/4] perf tools: Add trace event debugfs stream reader Frederic Weisbecker
2009-08-17 14:42 ` [tip:perfcounters/tracing] " tip-bot for Steven Rostedt
2009-08-17 14:18 ` [PATCH 3/4] perf tools: Add trace event informations parser Frederic Weisbecker
2009-08-17 14:43 ` [tip:perfcounters/tracing] perf tools: Add trace event information parser tip-bot for Steven Rostedt
2009-08-17 14:18 ` [PATCH 4/4] perf tools: Add perf trace Frederic Weisbecker
2009-08-17 14:40 ` Ingo Molnar
2009-08-17 16:28 ` Frederic Weisbecker
2009-08-17 16:36 ` Ingo Molnar
2009-08-17 21:07 ` [PATCH 1/4] perf tools: Fix spelling mistake in callchain error Frederic Weisbecker
2009-08-17 22:06 ` [tip:perfcounters/tracing] " tip-bot for Frederic Weisbecker
2009-08-17 21:07 ` [PATCH 2/4] perf tools: Warn while running perf trace without sample Frederic Weisbecker
2009-08-17 22:06 ` [tip:perfcounters/tracing] " tip-bot for Frederic Weisbecker
2009-08-17 21:07 ` [PATCH 3/4] perf tools: Record events info also when :record suffix is used Frederic Weisbecker
2009-08-17 22:06 ` [tip:perfcounters/tracing] " tip-bot for Frederic Weisbecker
2009-08-17 21:07 ` Frederic Weisbecker [this message]
2009-08-17 22:06 ` [tip:perfcounters/tracing] perf tools: Make trace event format parser aware of cast to pointers tip-bot for Frederic Weisbecker
2009-08-17 14:43 ` [tip:perfcounters/tracing] perf tools: Add perf trace tip-bot for Frederic Weisbecker
2009-08-17 14:42 ` [tip:perfcounters/tracing] perf tools: Add trace event debugfs IO handler tip-bot for Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1250543271-8383-4-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=acme@redhat.com \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome