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: Jiri 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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Jiri Olsa 2020-05-25 00:42:08 +02:00 коммит произвёл Arnaldo Carvalho de Melo
Родитель 5f09ca5a14
Коммит 1244a32736
3 изменённых файлов: 14 добавлений и 10 удалений

Просмотреть файл

@ -26,7 +26,7 @@
#include <api/fs/tracing_path.h>
#include <perf/cpumap.h>
#include "parse-events-bison.h"
#define YY_EXTRA_TYPE int
#define YY_EXTRA_TYPE void*
#include "parse-events-flex.h"
#include "pmu.h"
#include "thread_map.h"
@ -2027,13 +2027,14 @@ perf_pmu__parse_check(const char *name)
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;
void *scanner;
int ret;
ret = parse_events_lex_init_extra(start_token, &scanner);
ret = parse_events_lex_init_extra(parse_state, &scanner);
if (ret)
return ret;
@ -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)
{
struct parse_events_state parse_state = {
.terms = NULL,
.terms = NULL,
.stoken = PE_START_TERMS,
};
int ret;
ret = parse_events__scanner(str, &parse_state, PE_START_TERMS);
ret = parse_events__scanner(str, &parse_state);
if (!ret) {
list_splice(parse_state.terms, terms);
zfree(&parse_state.terms);
@ -2080,10 +2082,11 @@ int parse_events(struct evlist *evlist, const char *str,
.idx = evlist->core.nr_entries,
.error = err,
.evlist = evlist,
.stoken = PE_START_EVENTS,
};
int ret;
ret = parse_events__scanner(str, &parse_state, PE_START_EVENTS);
ret = parse_events__scanner(str, &parse_state);
perf_pmu__parse_cleanup();
if (!ret && list_empty(&parse_state.list)) {

Просмотреть файл

@ -128,6 +128,7 @@ struct parse_events_state {
struct parse_events_error *error;
struct evlist *evlist;
struct list_head *terms;
int stoken;
};
void parse_events__handle_error(struct parse_events_error *err, int idx,

Просмотреть файл

@ -209,10 +209,10 @@ modifier_bp [rwx]{1,3}
%%
%{
{
int start_token;
struct parse_events_state *_parse_state = parse_events_get_extra(yyscanner);
start_token = parse_events_get_extra(yyscanner);
{
int start_token = _parse_state->stoken;
if (start_token == PE_START_TERMS)
BEGIN(config);
@ -220,7 +220,7 @@ modifier_bp [rwx]{1,3}
BEGIN(event);
if (start_token) {
parse_events_set_extra(NULL, yyscanner);
_parse_state->stoken = 0;
/*
* The flex parser does not init locations variable
* via the scan_string interface, so we need do the