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

perf parse: Add 'struct parse_events_state' pointer to scanner

We need to pass more data to the scanner so let's start with having it
to take pointer to 'struct parse_events_state' object instead of just
start token.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20200524224219.234847-4-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 5f09ca5a
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <api/fs/tracing_path.h> #include <api/fs/tracing_path.h>
#include <perf/cpumap.h> #include <perf/cpumap.h>
#include "parse-events-bison.h" #include "parse-events-bison.h"
#define YY_EXTRA_TYPE int #define YY_EXTRA_TYPE void*
#include "parse-events-flex.h" #include "parse-events-flex.h"
#include "pmu.h" #include "pmu.h"
#include "thread_map.h" #include "thread_map.h"
...@@ -2027,13 +2027,14 @@ perf_pmu__parse_check(const char *name) ...@@ -2027,13 +2027,14 @@ perf_pmu__parse_check(const char *name)
return r ? r->type : PMU_EVENT_SYMBOL_ERR; return r ? r->type : PMU_EVENT_SYMBOL_ERR;
} }
static int parse_events__scanner(const char *str, void *parse_state, int start_token) static int parse_events__scanner(const char *str,
struct parse_events_state *parse_state)
{ {
YY_BUFFER_STATE buffer; YY_BUFFER_STATE buffer;
void *scanner; void *scanner;
int ret; int ret;
ret = parse_events_lex_init_extra(start_token, &scanner); ret = parse_events_lex_init_extra(parse_state, &scanner);
if (ret) if (ret)
return ret; return ret;
...@@ -2057,11 +2058,12 @@ static int parse_events__scanner(const char *str, void *parse_state, int start_t ...@@ -2057,11 +2058,12 @@ static int parse_events__scanner(const char *str, void *parse_state, int start_t
int parse_events_terms(struct list_head *terms, const char *str) int parse_events_terms(struct list_head *terms, const char *str)
{ {
struct parse_events_state parse_state = { struct parse_events_state parse_state = {
.terms = NULL, .terms = NULL,
.stoken = PE_START_TERMS,
}; };
int ret; int ret;
ret = parse_events__scanner(str, &parse_state, PE_START_TERMS); ret = parse_events__scanner(str, &parse_state);
if (!ret) { if (!ret) {
list_splice(parse_state.terms, terms); list_splice(parse_state.terms, terms);
zfree(&parse_state.terms); zfree(&parse_state.terms);
...@@ -2080,10 +2082,11 @@ int parse_events(struct evlist *evlist, const char *str, ...@@ -2080,10 +2082,11 @@ int parse_events(struct evlist *evlist, const char *str,
.idx = evlist->core.nr_entries, .idx = evlist->core.nr_entries,
.error = err, .error = err,
.evlist = evlist, .evlist = evlist,
.stoken = PE_START_EVENTS,
}; };
int ret; int ret;
ret = parse_events__scanner(str, &parse_state, PE_START_EVENTS); ret = parse_events__scanner(str, &parse_state);
perf_pmu__parse_cleanup(); perf_pmu__parse_cleanup();
if (!ret && list_empty(&parse_state.list)) { if (!ret && list_empty(&parse_state.list)) {
......
...@@ -128,6 +128,7 @@ struct parse_events_state { ...@@ -128,6 +128,7 @@ struct parse_events_state {
struct parse_events_error *error; struct parse_events_error *error;
struct evlist *evlist; struct evlist *evlist;
struct list_head *terms; struct list_head *terms;
int stoken;
}; };
void parse_events__handle_error(struct parse_events_error *err, int idx, void parse_events__handle_error(struct parse_events_error *err, int idx,
......
...@@ -209,10 +209,10 @@ modifier_bp [rwx]{1,3} ...@@ -209,10 +209,10 @@ modifier_bp [rwx]{1,3}
%% %%
%{ %{
{ struct parse_events_state *_parse_state = parse_events_get_extra(yyscanner);
int start_token;
start_token = parse_events_get_extra(yyscanner); {
int start_token = _parse_state->stoken;
if (start_token == PE_START_TERMS) if (start_token == PE_START_TERMS)
BEGIN(config); BEGIN(config);
...@@ -220,7 +220,7 @@ modifier_bp [rwx]{1,3} ...@@ -220,7 +220,7 @@ modifier_bp [rwx]{1,3}
BEGIN(event); BEGIN(event);
if (start_token) { if (start_token) {
parse_events_set_extra(NULL, yyscanner); _parse_state->stoken = 0;
/* /*
* The flex parser does not init locations variable * The flex parser does not init locations variable
* via the scan_string interface, so we need do the * via the scan_string interface, so we need do the
......
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