From: tip-bot for Vaibhav Nagarnaik <vnagarnaik@google.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, vnagarnaik@google.com,
hpa@zytor.com, mingo@kernel.org, peterz@infradead.org,
dhsharp@google.com, namhyung.kim@lge.com, bp@alien8.de,
jolsa@redhat.com, fweisbec@gmail.com, acme@infradead.org,
mrubin@google.com, rostedt@goodmis.org, tglx@linutronix.de,
asharma@fb.com
Subject: [tip:perf/core] parse-events: Handle opcode parsing error
Date: Mon, 21 May 2012 02:39:51 -0700 [thread overview]
Message-ID: <tip-14ffde0e966efab6724e2de3ab470b78d4e01109@git.kernel.org> (raw)
In-Reply-To: <1311619257-4970-1-git-send-email-vnagarnaik@google.com>
Commit-ID: 14ffde0e966efab6724e2de3ab470b78d4e01109
Gitweb: http://git.kernel.org/tip/14ffde0e966efab6724e2de3ab470b78d4e01109
Author: Vaibhav Nagarnaik <vnagarnaik@google.com>
AuthorDate: Fri, 6 Apr 2012 00:48:01 +0200
Committer: Frederic Weisbecker <fweisbec@gmail.com>
CommitDate: Wed, 25 Apr 2012 13:35:32 +0200
parse-events: Handle opcode parsing error
If an invalid opcode is encountered in parsing event print format, the
trace-cmd calls exit() without parsing any other events.
This patch adds handling for such an error where the get_op_prio() is
called. If the return value is -1, then the event print format parsing
is skipped and parsing continues.
Cc: Michael Rubin <mrubin@google.com>
Cc: David Sharp <dhsharp@google.com>
Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Link: http://lkml.kernel.org/r/1311619257-4970-1-git-send-email-vnagarnaik@google.com
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Arun Sharma <asharma@fb.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
tools/lib/traceevent/event-parse.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index ef2c65f..cdb32c7 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -1592,7 +1592,7 @@ static int get_op_prio(char *op)
case '?':
return 16;
default:
- die("unknown op '%c'", op[0]);
+ do_warning("unknown op '%c'", op[0]);
return -1;
}
} else {
@@ -1613,22 +1613,22 @@ static int get_op_prio(char *op)
} else if (strcmp(op, "||") == 0) {
return 15;
} else {
- die("unknown op '%s'", op);
+ do_warning("unknown op '%s'", op);
return -1;
}
}
}
-static void set_op_prio(struct print_arg *arg)
+static int set_op_prio(struct print_arg *arg)
{
/* single ops are the greatest */
- if (!arg->op.left || arg->op.left->type == PRINT_NULL) {
+ if (!arg->op.left || arg->op.left->type == PRINT_NULL)
arg->op.prio = 0;
- return;
- }
+ else
+ arg->op.prio = get_op_prio(arg->op.op);
- arg->op.prio = get_op_prio(arg->op.op);
+ return arg->op.prio;
}
/* Note, *tok does not get freed, but will most likely be saved */
@@ -1710,7 +1710,10 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok)
arg->op.op = token;
arg->op.left = left;
- set_op_prio(arg);
+ if (set_op_prio(arg) == -1) {
+ event->flags |= EVENT_FL_FAILED;
+ goto out_free;
+ }
type = read_token_item(&token);
*tok = token;
next prev parent reply other threads:[~2012-05-21 9:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-16 3:00 [PATCH 1/4] trace-cmd: Add parse error checking target Vaibhav Nagarnaik
2011-07-16 3:00 ` [PATCH 2/4] trace-cmd: Handle invalid opcode parsing gracefully Vaibhav Nagarnaik
2011-07-25 14:03 ` Steven Rostedt
2012-05-21 9:39 ` [tip:perf/core] parse-events: " tip-bot for Vaibhav Nagarnaik
2011-07-16 3:00 ` [PATCH 3/4] trace-cmd: Handle opcode parsing error Vaibhav Nagarnaik
2011-07-25 14:01 ` Steven Rostedt
2011-07-25 18:06 ` Vaibhav Nagarnaik
2011-07-25 18:40 ` Vaibhav Nagarnaik
2012-05-21 9:39 ` tip-bot for Vaibhav Nagarnaik [this message]
2011-07-16 3:00 ` [PATCH 4/4] trace-cmd: Support '+' opcode in print format Vaibhav Nagarnaik
2011-07-25 14:02 ` Steven Rostedt
2012-05-21 9:41 ` [tip:perf/core] parse-events: " tip-bot for Vaibhav Nagarnaik
2011-07-25 13:32 ` [PATCH 1/4] trace-cmd: Add parse error checking target Steven Rostedt
2011-07-25 18:06 ` Vaibhav Nagarnaik
2011-07-25 18:39 ` [PATCH v2 " Vaibhav Nagarnaik
2011-07-29 14:19 ` Steven Rostedt
2011-07-29 17:41 ` Vaibhav Nagarnaik
2011-07-29 17:53 ` Steven Rostedt
2011-07-29 19:07 ` Vaibhav Nagarnaik
2011-07-30 1:33 ` 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=tip-14ffde0e966efab6724e2de3ab470b78d4e01109@git.kernel.org \
--to=vnagarnaik@google.com \
--cc=acme@infradead.org \
--cc=asharma@fb.com \
--cc=bp@alien8.de \
--cc=dhsharp@google.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mrubin@google.com \
--cc=namhyung.kim@lge.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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