All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
To: linux-kernel@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Subject: [PATCH 2/3] perf: allow processing single op args
Date: Wed, 07 Dec 2011 10:37:15 +0900	[thread overview]
Message-ID: <4EDEC34B.302@jp.fujitsu.com> (raw)
In-Reply-To: <4EDEC207.90403@jp.fujitsu.com>

I got following error from record with btrfs tracepoints:

  $ perf script
  Fatal: unknown op '-'

It seems that perf failed to handle '-' in the following format:

  print fmt: "%s", ((REC->id >= -9) || (REC->id <= 7)) ? "x" : "y"
                                ~
process_arg() have code to parse '-9' as a "single op" arg, which is
PRINT_OP as type, '-' as op and have '9' as right arg but no left arg.
However arg_num_eval() have no code to handle this "single op" arg
even it is parsed successfully.

This patch allow perf to process such "single op" args.

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
---
 tools/perf/util/trace-event-parse.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index c2adc76..b709f78 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -1355,6 +1355,24 @@ static long long arg_num_eval(struct print_arg *arg)
 		val = arg_num_eval(arg->typecast.item);
 		break;
 	case PRINT_OP:
+		if (!arg->op.left || arg->op.left->type == PRINT_NULL) {
+			/* handle single op */
+			right = arg_num_eval(arg->op.right);
+			switch (arg->op.op[0]) {
+			case '!':
+				val = !right;
+				break;
+			case '+':
+				val = right;
+				break;
+			case '-':
+				val = -right;
+				break;
+			default:
+				die("unknown single op %s", arg->op.op);
+			}
+			break;
+		}
 		switch (arg->op.op[0]) {
 		case '|':
 			left = arg_num_eval(arg->op.left);
-- 
1.7.7.3

  parent reply	other threads:[~2011-12-07  1:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-07  1:31 [PATCH 0/3] perf: parser fix for btrfs tracepoints Hidetoshi Seto
2011-12-07  1:36 ` [PATCH 1/3] perf: parse greater/less than or equal Hidetoshi Seto
2011-12-07  1:37 ` Hidetoshi Seto [this message]
2011-12-07  1:37 ` [PATCH 3/3] perf: allow typecast for signed value Hidetoshi Seto

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=4EDEC34B.302@jp.fujitsu.com \
    --to=seto.hidetoshi@jp.fujitsu.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.