提交 ae762641 编写于 作者: J Jiri Olsa 提交者: 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: NIan Rogers <irogers@google.com>
Signed-off-by: NJiri Olsa <jolsa@kernel.org>
Acked-by: NIan Rogers <irogers@google.com>
Tested-by: NArnaldo 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: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册