Commit 46010ab2 authored by Jiri Olsa's avatar Jiri Olsa Committed by Ingo Molnar

perf/tool: Use data struct for arg passing in event parse function

Moving all the bison arguments into the structure. In upcomming
patches we are going to:

  - add more arguments
  - reuse the grammer for term parsing

so it's more clear to pack/separate related arguments.
Signed-off-by: default avatarJiri Olsa <jolsa@redhat.com>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1339741902-8449-10-git-send-email-zheng.z.yan@intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 7c94ee2e
......@@ -26,7 +26,7 @@ struct event_symbol {
#ifdef PARSER_DEBUG
extern int parse_events_debug;
#endif
int parse_events_parse(struct list_head *list, int *idx);
int parse_events_parse(void *data);
#define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x
#define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
......@@ -789,25 +789,27 @@ int parse_events_modifier(struct list_head *list, char *str)
int parse_events(struct perf_evlist *evlist, const char *str, int unset __used)
{
LIST_HEAD(list);
LIST_HEAD(list_tmp);
struct parse_events_data__events data = {
.list = LIST_HEAD_INIT(data.list),
.idx = evlist->nr_entries,
};
YY_BUFFER_STATE buffer;
int ret, idx = evlist->nr_entries;
int ret;
buffer = parse_events__scan_string(str);
#ifdef PARSER_DEBUG
parse_events_debug = 1;
#endif
ret = parse_events_parse(&list, &idx);
ret = parse_events_parse(&data);
parse_events__flush_buffer(buffer);
parse_events__delete_buffer(buffer);
parse_events_lex_destroy();
if (!ret) {
int entries = idx - evlist->nr_entries;
perf_evlist__splice_list_tail(evlist, &list, entries);
int entries = data.idx - evlist->nr_entries;
perf_evlist__splice_list_tail(evlist, &data.list, entries);
return 0;
}
......
......@@ -63,6 +63,11 @@ struct parse_events__term {
struct list_head list;
};
struct parse_events_data__events {
struct list_head list;
int idx;
};
int parse_events__is_hardcoded_term(struct parse_events__term *term);
int parse_events__term_num(struct parse_events__term **_term,
int type_term, char *config, long num);
......@@ -83,8 +88,7 @@ int parse_events_add_pmu(struct list_head **list, int *idx,
char *pmu , struct list_head *head_config);
void parse_events_update_lists(struct list_head *list_event,
struct list_head *list_all);
void parse_events_error(struct list_head *list_all,
int *idx, char const *msg);
void parse_events_error(void *data, char const *msg);
int parse_events__test(void);
void print_events(const char *event_glob);
......
%name-prefix "parse_events_"
%parse-param {struct list_head *list_all}
%parse-param {int *idx}
%parse-param {void *_data}
%{
......@@ -64,18 +63,22 @@ events ',' event | event
event:
event_def PE_MODIFIER_EVENT
{
struct parse_events_data__events *data = _data;
/*
* Apply modifier on all events added by single event definition
* (there could be more events added for multiple tracepoint
* definitions via '*?'.
*/
ABORT_ON(parse_events_modifier($1, $2));
parse_events_update_lists($1, list_all);
parse_events_update_lists($1, &data->list);
}
|
event_def
{
parse_events_update_lists($1, list_all);
struct parse_events_data__events *data = _data;
parse_events_update_lists($1, &data->list);
}
event_def: event_pmu |
......@@ -89,9 +92,10 @@ event_def: event_pmu |
event_pmu:
PE_NAME '/' event_config '/'
{
struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
ABORT_ON(parse_events_add_pmu(&list, idx, $1, $3));
ABORT_ON(parse_events_add_pmu(&list, &data->idx, $1, $3));
parse_events__free_terms($3);
$$ = list;
}
......@@ -99,91 +103,106 @@ PE_NAME '/' event_config '/'
event_legacy_symbol:
PE_VALUE_SYM '/' event_config '/'
{
struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
int type = $1 >> 16;
int config = $1 & 255;
ABORT_ON(parse_events_add_numeric(&list, idx, type, config, $3));
ABORT_ON(parse_events_add_numeric(&list, &data->idx,
type, config, $3));
parse_events__free_terms($3);
$$ = list;
}
|
PE_VALUE_SYM sep_slash_dc
{
struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
int type = $1 >> 16;
int config = $1 & 255;
ABORT_ON(parse_events_add_numeric(&list, idx, type, config, NULL));
ABORT_ON(parse_events_add_numeric(&list, &data->idx,
type, config, NULL));
$$ = list;
}
event_legacy_cache:
PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
{
struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
ABORT_ON(parse_events_add_cache(&list, idx, $1, $3, $5));
ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, $5));
$$ = list;
}
|
PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
{
struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
ABORT_ON(parse_events_add_cache(&list, idx, $1, $3, NULL));
ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, NULL));
$$ = list;
}
|
PE_NAME_CACHE_TYPE
{
struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
ABORT_ON(parse_events_add_cache(&list, idx, $1, NULL, NULL));
ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, NULL, NULL));
$$ = list;
}
event_legacy_mem:
PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
{
struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
ABORT_ON(parse_events_add_breakpoint(&list, idx, (void *) $2, $4));
ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
(void *) $2, $4));
$$ = list;
}
|
PE_PREFIX_MEM PE_VALUE sep_dc
{
struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
ABORT_ON(parse_events_add_breakpoint(&list, idx, (void *) $2, NULL));
ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
(void *) $2, NULL));
$$ = list;
}
event_legacy_tracepoint:
PE_NAME ':' PE_NAME
{
struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
ABORT_ON(parse_events_add_tracepoint(&list, idx, $1, $3));
ABORT_ON(parse_events_add_tracepoint(&list, &data->idx, $1, $3));
$$ = list;
}
event_legacy_numeric:
PE_VALUE ':' PE_VALUE
{
struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
ABORT_ON(parse_events_add_numeric(&list, idx, $1, $3, NULL));
ABORT_ON(parse_events_add_numeric(&list, &data->idx, $1, $3, NULL));
$$ = list;
}
event_legacy_raw:
PE_RAW
{
struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
ABORT_ON(parse_events_add_numeric(&list, idx, PERF_TYPE_RAW, $1, NULL));
ABORT_ON(parse_events_add_numeric(&list, &data->idx,
PERF_TYPE_RAW, $1, NULL));
$$ = list;
}
......@@ -267,8 +286,7 @@ sep_slash_dc: '/' | ':' |
%%
void parse_events_error(struct list_head *list_all __used,
int *idx __used,
void parse_events_error(void *data __used,
char const *msg __used)
{
}
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