perf tools: Add flex support for parse_events_error
Allowing flex parser to report back event parsing error, like: $ perf record -e cycles,cache-mises ls event syntax error: '..es,cache-mises' \___ parser error ... Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1429729824-13932-3-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
b39b839309
commit
6297d42372
@@ -3,6 +3,8 @@
|
||||
%option bison-bridge
|
||||
%option prefix="parse_events_"
|
||||
%option stack
|
||||
%option bison-locations
|
||||
%option yylineno
|
||||
|
||||
%{
|
||||
#include <errno.h>
|
||||
@@ -51,6 +53,18 @@ static int str(yyscan_t scanner, int token)
|
||||
return token;
|
||||
}
|
||||
|
||||
#define REWIND(__alloc) \
|
||||
do { \
|
||||
YYSTYPE *__yylval = parse_events_get_lval(yyscanner); \
|
||||
char *text = parse_events_get_text(yyscanner); \
|
||||
\
|
||||
if (__alloc) \
|
||||
__yylval->str = strdup(text); \
|
||||
\
|
||||
yycolumn -= strlen(text); \
|
||||
yyless(0); \
|
||||
} while (0)
|
||||
|
||||
static int pmu_str_check(yyscan_t scanner)
|
||||
{
|
||||
YYSTYPE *yylval = parse_events_get_lval(scanner);
|
||||
@@ -85,6 +99,13 @@ static int term(yyscan_t scanner, int type)
|
||||
return PE_TERM;
|
||||
}
|
||||
|
||||
#define YY_USER_ACTION \
|
||||
do { \
|
||||
yylloc->last_column = yylloc->first_column; \
|
||||
yylloc->first_column = yycolumn; \
|
||||
yycolumn += yyleng; \
|
||||
} while (0);
|
||||
|
||||
%}
|
||||
|
||||
%x mem
|
||||
@@ -119,6 +140,12 @@ modifier_bp [rwx]{1,3}
|
||||
|
||||
if (start_token) {
|
||||
parse_events_set_extra(NULL, yyscanner);
|
||||
/*
|
||||
* The flex parser does not init locations variable
|
||||
* via the scan_string interface, so we need do the
|
||||
* init in here.
|
||||
*/
|
||||
yycolumn = 0;
|
||||
return start_token;
|
||||
}
|
||||
}
|
||||
@@ -127,19 +154,21 @@ modifier_bp [rwx]{1,3}
|
||||
<event>{
|
||||
|
||||
{group} {
|
||||
BEGIN(INITIAL); yyless(0);
|
||||
BEGIN(INITIAL);
|
||||
REWIND(0);
|
||||
}
|
||||
|
||||
{event_pmu} |
|
||||
{event} {
|
||||
str(yyscanner, PE_EVENT_NAME);
|
||||
BEGIN(INITIAL); yyless(0);
|
||||
BEGIN(INITIAL);
|
||||
REWIND(1);
|
||||
return PE_EVENT_NAME;
|
||||
}
|
||||
|
||||
. |
|
||||
<<EOF>> {
|
||||
BEGIN(INITIAL); yyless(0);
|
||||
BEGIN(INITIAL);
|
||||
REWIND(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user