Skip to content

Commit 9445464

Browse files
olsajiriacmel
authored andcommitted
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 <[email protected]> Reported-by: Arnaldo Carvalho de Melo <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Tested-by: Andi Kleen <[email protected]> Cc: Changbin Du <[email protected]> Cc: David Ahern <[email protected]> Cc: Jin Yao <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 331c7cb commit 9445464

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tools/perf/util/parse-events.l

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ do { \
154154
yycolumn += yyleng; \
155155
} while (0);
156156

157+
#define USER_REJECT \
158+
yycolumn -= yyleng; \
159+
REJECT
160+
157161
%}
158162

159163
%x mem
@@ -335,8 +339,8 @@ r{num_raw_hex} { return raw(yyscanner); }
335339
{num_hex} { return value(yyscanner, 16); }
336340

337341
{modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); }
338-
{bpf_object} { if (!isbpf(yyscanner)) REJECT; return str(yyscanner, PE_BPF_OBJECT); }
339-
{bpf_source} { if (!isbpf(yyscanner)) REJECT; return str(yyscanner, PE_BPF_SOURCE); }
342+
{bpf_object} { if (!isbpf(yyscanner)) USER_REJECT; return str(yyscanner, PE_BPF_OBJECT); }
343+
{bpf_source} { if (!isbpf(yyscanner)) USER_REJECT; return str(yyscanner, PE_BPF_SOURCE); }
340344
{name} { return pmu_str_check(yyscanner); }
341345
"/" { BEGIN(config); return '/'; }
342346
- { return '-'; }

0 commit comments

Comments
 (0)