Commit ae762641 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

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 error

The reason is that we don't have rule for ',' in 'event' start condition
and it's matched and accepted by default rule.

Add 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: default avatarIan Rogers <irogers@google.com>
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Acked-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20200520074050.156988-1-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 498ef715
...@@ -2041,6 +2041,7 @@ static int parse_events__scanner(const char *str, void *parse_state, int start_t ...@@ -2041,6 +2041,7 @@ static int parse_events__scanner(const char *str, void *parse_state, int start_t
#ifdef PARSER_DEBUG #ifdef PARSER_DEBUG
parse_events_debug = 1; parse_events_debug = 1;
parse_events_set_debug(1, scanner);
#endif #endif
ret = parse_events_parse(parse_state, scanner); ret = parse_events_parse(parse_state, scanner);
......
...@@ -252,7 +252,9 @@ modifier_bp [rwx]{1,3} ...@@ -252,7 +252,9 @@ modifier_bp [rwx]{1,3}
BEGIN(INITIAL); BEGIN(INITIAL);
REWIND(0); REWIND(0);
} }
, {
return ',';
}
} }
<array>{ <array>{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment