perf stat: Fail on extra comma while parsing events
Jiri Olsa
reviewerPATCH 1/1 perf stat: Fail on extra comma while parsing events
Ian reported that we allow to parse following:
$ perf stat -e ,cycles true
which is wrong and we should fail, like we do with this fix:
$ perf stat -e ,cycles true
event syntax error: ',cycles'
\___ parser errorThe reason is that we don't have rule for ',' in 'event' start condition and it's matched and accepted by default rule.
Adding scanner debug support (that Ian already added for expr code), which was really useful for finding this. It's enabled together with bison debug via 'make PARSER_DEBUG=1'.
--- tools/perf/util/parse-events.c | 1 + tools/perf/util/parse-events.l | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/parse-events.c +1 -0
@@ -2014,6 +2014,7 @@ static int parse_events__scanner(const char *str, void *parse_state, int start_t#ifdef PARSER_DEBUG parse_events_debug =1 ; +parse_events_set_debug (1 , scanner);#endif ret =parse_events_parse (parse_state, scanner);
tools/perf/util/parse-events.l +3 -1
@@ -252,7 +252,9 @@ modifier_bp [rwx]{1,3} BEGIN(INITIAL); REWIND(0); } - +, { + return ','; + } } <array>{
Signature · 1 line
2.25.4
Quoted 15 lines · Jiri Olsa
Ian reported that we allow to parse following:
$ perf stat -e ,cycles truewhich is wrong and we should fail, like we do with this fix:
$ perf stat -e ,cycles true event syntax error: ',cycles' \___ parser errorThe reason is that we don't have rule for ',' in 'event' start condition and it's matched and accepted by default rule.
Quoted 6 lines
Adding scanner debug support (that Ian already added for expr code), which was really useful for finding this. It's enabled together with bison debug via 'make PARSER_DEBUG=1'.
Reported-by Ian Rogers <[email protected]>Signed-off-by Jiri Olsa <[email protected]>
Thanks!
Ian
Ian
Quoted 35 lines
--- tools/perf/util/parse-events.c | 1 + tools/perf/util/parse-events.l | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)tools/perf/util/parse-events.c +1
-0@@ -2014,6 +2014,7 @@ static int parse_events__scanner(const char *str, void *parse_state, int start_t#ifdef PARSER_DEBUG parse_events_debug =1 ; +parse_events_set_debug (1 , scanner);#endif ret =parse_events_parse (parse_state, scanner);tools/perf/util/parse-events.l +3
-2@@ -252,7 +252,9 @@ modifier_bp [rwx]{1,3} BEGIN(INITIAL); REWIND(0); } - +, { + return ','; + } } <array>{ --2.25.4
Em Wed, May 20, 2020 at 12:51:24AM -0700, Ian Rogers escreveu:
Quoted 16 lines · Jiri Olsa
Quoted 15 lines
Ian reported that we allow to parse following:
$ perf stat -e ,cycles truewhich is wrong and we should fail, like we do with this fix:
$ perf stat -e ,cycles true event syntax error: ',cycles' \___ parser errorThe reason is that we don't have rule for ',' in 'event' start condition and it's matched and accepted by default rule.
Quoted 8 lines
Quoted 6 lines
Adding scanner debug support (that Ian already added for expr code), which was really useful for finding this. It's enabled together with bison debug via 'make PARSER_DEBUG=1'.
Reported-by Ian Rogers <[email protected]>Signed-off-by Jiri Olsa <[email protected]>Acked-by Ian Rogers <[email protected]>
Thanks, applied.
- Arnaldo