public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>, lkml <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	David Ahern <dsahern@gmail.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Andi Kleen <andi@firstfloor.org>,
	"Jin, Yao" <yao.jin@linux.intel.com>,
	"Wangnan (F)" <wangnan0@huawei.com>,
	"Du, Changbin" <changbin.du@intel.com>
Subject: [PATCHv2 9/9] perf tools: Unwind properly location after REJECT
Date: Tue, 24 Oct 2017 14:51:21 +0200	[thread overview]
Message-ID: <20171024125121.GA5191@krava> (raw)
In-Reply-To: <20171013195036.GB5311@kernel.org>

On Fri, Oct 13, 2017 at 04:50:36PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Fri, Oct 13, 2017 at 10:37:36AM +0200, Jiri Olsa escreveu:
> > 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.
> 
> What is this fixing? Please state that, below I show what it is breaking
> :-/
> 
> Before:
> 
> [root@jouet ~]# perf trace --no-syscalls -e ~acme/bpf/sys_read.c/max-stack=5/ sleep 1
> bpf: builtin compilation failed: -95, try external compiler
>      0.000 perf_bpf_probe:func:(ffffffffbb2634e0))
>                                        sys_read ([kernel.kallsyms])
>                                        entry_SYSCALL_64_fastpath ([kernel.kallsyms])
>                                        __read (/usr/lib64/ld-2.25.so)
>                                        _dl_map_object (/usr/lib64/ld-2.25.so)
> 
> After:
> 
> [root@jouet ~]# perf trace --no-syscalls -e ~acme/bpf/sys_read.c/max-stack=5/ sleep 1
> event syntax error: '/home/acme/bpf/sys_read.c/max-stack=5/'
>                      \___ parser error
> Run 'perf list' for a list of valid events
> 
>  Usage: perf trace [<options>] [<command>]
>     or: perf trace [<options>] -- <command> [<options>]
>     or: perf trace record [<options>] [<command>]
>     or: perf trace record [<options>] -- <command> [<options>]
> 
>     -e, --event <event>   event/syscall selector. use 'perf list' to list available events
> [root@jouet ~]# 
> 

v2 with updated changelog attached,

also I rebased the rest of the fixes and pushed
them into perf/fixes branch


thanks,
jirka


---
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

Tested-by: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/n/tip-vug2hchlny30jfsfrumbym26@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 38a42bdf1492..241396cd059d 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
@@ -336,8 +340,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 '-'; }
-- 
2.13.6

  reply	other threads:[~2017-10-24 12:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-13  8:37 [PATCH 0/9] perf tools: Assorted fixes Jiri Olsa
2017-10-13  8:37 ` [PATCH 1/9] perf tools: Fix crash in perf_hpp__reset_output_field Jiri Olsa
2017-10-20  7:18   ` [tip:perf/urgent] perf hists: Fix crash in perf_hpp__reset_output_field() tip-bot for Jiri Olsa
2017-10-13  8:37 ` [PATCH 2/9] perf tools: Add extra integrity checks to fmt_free Jiri Olsa
2017-10-20  7:19   ` [tip:perf/urgent] perf hists: Add extra integrity checks to fmt_free() tip-bot for Jiri Olsa
2017-10-13  8:37 ` [PATCH 3/9] perf tools: Rename struct perf_data_file to perf_data Jiri Olsa
2017-10-13  8:37 ` [PATCH 4/9] perf tools: Add struct perf_data_file Jiri Olsa
2017-10-13  8:37 ` [PATCH 5/9] perf tools: Add perf_data_file__write function Jiri Olsa
2017-10-13  8:37 ` [PATCH 6/9] perf stat: Move the shadow stats scale computation in perf_stat__update_shadow_stats Jiri Olsa
2017-10-13  8:37 ` [PATCH 7/9] perf stat: Make --per-thread update shadow stats to show metrics Jiri Olsa
2017-10-13  8:37 ` [PATCH 8/9] perf tools: Check wether the eBPF file exists in event parsing Jiri Olsa
2017-10-20  7:19   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2017-10-13  8:37 ` [PATCH 9/9] perf tools: Unwind properly location after REJECT Jiri Olsa
2017-10-13 19:50   ` Arnaldo Carvalho de Melo
2017-10-24 12:51     ` Jiri Olsa [this message]
2017-10-25 14:07       ` [PATCHv2 " Jiri Olsa

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=20171024125121.GA5191@krava \
    --to=jolsa@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=andi@firstfloor.org \
    --cc=changbin.du@intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --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