From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932598AbdJXMve (ORCPT ); Tue, 24 Oct 2017 08:51:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40916 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932533AbdJXMv1 (ORCPT ); Tue, 24 Oct 2017 08:51:27 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 784244901D Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jolsa@redhat.com Date: Tue, 24 Oct 2017 14:51:21 +0200 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , lkml , Ingo Molnar , Namhyung Kim , David Ahern , Peter Zijlstra , Andi Kleen , "Jin, Yao" , "Wangnan (F)" , "Du, Changbin" Subject: [PATCHv2 9/9] perf tools: Unwind properly location after REJECT Message-ID: <20171024125121.GA5191@krava> References: <20171013083736.15037-1-jolsa@kernel.org> <20171013083736.15037-10-jolsa@kernel.org> <20171013195036.GB5311@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20171013195036.GB5311@kernel.org> User-Agent: Mutt/1.9.1 (2017-09-22) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 24 Oct 2017 12:51:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.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 [] [] > or: perf trace [] -- [] > or: perf trace record [] [] > or: perf trace record [] -- [] > > -e, --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 Link: http://lkml.kernel.org/n/tip-vug2hchlny30jfsfrumbym26@git.kernel.org Signed-off-by: Jiri Olsa --- 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