linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: dsahern@gmail.com, ak@linux.intel.com, namhyung@kernel.org,
	linux-kernel@vger.kernel.org, changbin.du@intel.com,
	tglx@linutronix.de, yao.jin@linux.intel.com, mingo@kernel.org,
	wangnan0@huawei.com, jolsa@kernel.org, acme@redhat.com,
	hpa@zytor.com
Subject: [tip:perf/urgent] perf tools: Unwind properly location after REJECT
Date: Sat, 28 Oct 2017 16:10:20 -0700	[thread overview]
Message-ID: <tip-vug2hchlny30jfsfrumbym26@git.kernel.org> (raw)
In-Reply-To: <20171009140944.GD28623@kernel.org>

Commit-ID:  9445464bb8318e42e5232b37fc7218ed028517f6
Gitweb:     https://git.kernel.org/tip/9445464bb8318e42e5232b37fc7218ed028517f6
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Thu, 12 Oct 2017 17:03:38 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 27 Oct 2017 11:42:51 -0300

perf tools: Unwind properly location after REJECT

We have defined YY_USER_ACTION to keep trace of the column location
during events parsing, but we need to clean it up when we call REJECT.

When REJECT is called, the lexer shrinks the text and re-runs the
matching, so we need to address it in resuming the previous location
value to keep it correct for error display, like:

Before:
  $ perf stat -e 'cpu/uops_executed.core,krava/'  true
  event syntax error: '..38;5;9:mi=01;05;37;41:su=48;5;196;38;5;15:sg=48;5;1\
1;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;\
21;38;50
�'
                                  \___ unknown term

After:
  $ ./perf stat -e 'cpu/uops_executed.core,krava/'  true
  event syntax error: '..cuted.core,krava/'
                                    \___ unknown term

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Andi Kleen <ak@linux.intel.com>
Cc: Changbin Du <changbin.du@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-vug2hchlny30jfsfrumbym26@git.kernel.org
Link: http://lkml.kernel.org/r/20171009140944.GD28623@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/parse-events.l | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index dcfdafd..6680e4f 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -154,6 +154,10 @@ do {							\
 	yycolumn += yyleng;				\
 } while (0);
 
+#define USER_REJECT		\
+	yycolumn -= yyleng;	\
+	REJECT
+
 %}
 
 %x mem
@@ -335,8 +339,8 @@ r{num_raw_hex}		{ return raw(yyscanner); }
 {num_hex}		{ return value(yyscanner, 16); }
 
 {modifier_event}	{ return str(yyscanner, PE_MODIFIER_EVENT); }
-{bpf_object}		{ if (!isbpf(yyscanner)) REJECT; return str(yyscanner, PE_BPF_OBJECT); }
-{bpf_source}		{ if (!isbpf(yyscanner)) REJECT; return str(yyscanner, PE_BPF_SOURCE); }
+{bpf_object}		{ if (!isbpf(yyscanner)) USER_REJECT; return str(yyscanner, PE_BPF_OBJECT); }
+{bpf_source}		{ if (!isbpf(yyscanner)) USER_REJECT; return str(yyscanner, PE_BPF_SOURCE); }
 {name}			{ return pmu_str_check(yyscanner); }
 "/"			{ BEGIN(config); return '/'; }
 -			{ return '-'; }

      parent reply	other threads:[~2017-10-28 23:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-12 19:56 [PATCH 1/2] perf, tools, json: Fix ILP metrics Andi Kleen
2017-09-12 19:56 ` [PATCH 2/2] perf, tools: Don't force MetricExprs to lower case Andi Kleen
2017-10-03 16:06   ` Arnaldo Carvalho de Melo
2017-10-04 10:30     ` Jiri Olsa
2017-10-04 16:27       ` Andi Kleen
2017-10-09 13:41         ` Jiri Olsa
2017-10-09 14:07           ` Andi Kleen
2017-10-09 14:12             ` Arnaldo Carvalho de Melo
2017-10-09 14:39               ` Jiri Olsa
2017-10-09 14:51                 ` Arnaldo Carvalho de Melo
2017-10-09 15:39                 ` Andi Kleen
2017-10-12 15:31                 ` Wangnan (F)
2017-10-12 15:59                   ` Jiri Olsa
2017-10-12 16:07                     ` Wangnan (F)
2017-10-09 14:43             ` Jiri Olsa
2017-10-09 14:09           ` Arnaldo Carvalho de Melo
2017-10-09 14:41             ` Jiri Olsa
2017-10-12 15:13               ` Jiri Olsa
2017-10-12 21:53                 ` Andi Kleen
2017-10-28 23:10             ` tip-bot for Jiri Olsa [this message]

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-vug2hchlny30jfsfrumbym26@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=changbin.du@intel.com \
    --cc=dsahern@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wangnan0@huawei.com \
    --cc=yao.jin@linux.intel.com \
    /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).