From: David Sharp <dhsharp@google.com>
To: linux-kernel@vger.kernel.org
Cc: mrubin@google.com, David Sharp <dhsharp@google.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@elte.hu>,
Stephane Eranian <eranian@google.com>
Subject: [PATCH perf 1/2] perf: trace-event-parse: support additional operators: '!', '~', and '!='
Date: Mon, 21 Mar 2011 15:34:05 -0700 [thread overview]
Message-ID: <1300746846-28245-2-git-send-email-dhsharp@google.com> (raw)
In-Reply-To: <1300746846-28245-1-git-send-email-dhsharp@google.com>
Add support for the unary operators '!' and '~', and support '!=' so that
it is differentiated from '!'.
Signed-off-by: David Sharp <dhsharp@google.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Stephane Eranian <eranian@google.com>
---
tools/perf/util/trace-event-parse.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 73a0222..67fe01a 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -1107,6 +1107,9 @@ static int get_op_prio(char *op)
{
if (!op[1]) {
switch (op[0]) {
+ case '~':
+ case '!':
+ return 4;
case '*':
case '/':
case '%':
@@ -1184,6 +1187,7 @@ process_op(struct event *event, struct print_arg *arg, char **tok)
return EVENT_ERROR;
}
switch (token[0]) {
+ case '~':
case '!':
case '+':
case '-':
@@ -2109,6 +2113,21 @@ static unsigned long long eval_num_arg(void *data, int size,
left = eval_num_arg(data, size, event, arg->op.left);
right = eval_num_arg(data, size, event, arg->op.right);
switch (arg->op.op[0]) {
+ case '!':
+ switch (arg->op.op[1]) {
+ case 0:
+ val = !right;
+ break;
+ case '=':
+ val = left != right;
+ break;
+ default:
+ die("unknown op '%s'", arg->op.op);
+ }
+ break;
+ case '~':
+ val = ~right;
+ break;
case '|':
if (arg->op.op[1])
val = left || right;
--
1.7.3.1
next prev parent reply other threads:[~2011-03-21 22:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-21 22:34 [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats David Sharp
2011-03-21 22:34 ` David Sharp [this message]
2011-03-21 22:34 ` [PATCH perf 2/2] perf: trace-event-parse: support printing short fields David Sharp
2011-04-07 2:01 ` [PATCH perf 0/2] perf: trace-event-parse: support more operators and print formats David Sharp
2011-04-07 14:26 ` Frederic Weisbecker
2011-04-07 20:25 ` David Sharp
2011-04-07 21:57 ` Frederic Weisbecker
-- strict thread matches above, loose matches on Subject: below --
2011-03-10 22:55 David Sharp
2011-03-10 22:55 ` [PATCH perf 1/2] perf: trace-event-parse: support additional operators: '!', '~', and '!=' David Sharp
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=1300746846-28245-2-git-send-email-dhsharp@google.com \
--to=dhsharp@google.com \
--cc=acme@redhat.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mrubin@google.com \
--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;
as well as URLs for NNTP newsgroup(s).