blob: 6a2d006ea77f31e95b9f208818acda0bb7d15c59 [file] [log] [blame]
Zheng Yanac20de6f2012-06-15 14:31:39 +08001%pure-parser
Jiri Olsa46010ab2012-06-15 14:31:38 +08002%parse-param {void *_data}
Zheng Yanac20de6f2012-06-15 14:31:39 +08003%parse-param {void *scanner}
4%lex-param {void* scanner}
Jiri Olsa6297d422015-04-22 21:10:17 +02005%locations
Jiri Olsa89812fc2012-03-15 20:09:15 +01006
7%{
8
9#define YYDEBUG 1
10
11#include <linux/compiler.h>
12#include <linux/list.h>
Borislav Petkovd944c4e2014-04-25 21:31:02 +020013#include <linux/types.h>
Jiri Olsa89812fc2012-03-15 20:09:15 +010014#include "util.h"
15#include "parse-events.h"
Zheng Yanac20de6f2012-06-15 14:31:39 +080016#include "parse-events-bison.h"
Jiri Olsa89812fc2012-03-15 20:09:15 +010017
Jiri Olsa89812fc2012-03-15 20:09:15 +010018#define ABORT_ON(val) \
19do { \
20 if (val) \
21 YYABORT; \
22} while (0)
23
David Ahernc5cd8ac2013-07-02 13:27:25 -060024#define ALLOC_LIST(list) \
25do { \
26 list = malloc(sizeof(*list)); \
27 ABORT_ON(!list); \
28 INIT_LIST_HEAD(list); \
29} while (0)
30
Namhyung Kim97f63e42013-01-22 18:09:29 +090031static inc_group_count(struct list_head *list,
32 struct parse_events_evlist *data)
33{
34 /* Count groups only have more than 1 members */
35 if (!list_is_last(list->next, list))
36 data->nr_groups++;
37}
38
Jiri Olsa89812fc2012-03-15 20:09:15 +010039%}
40
Jiri Olsa90e2b222012-06-15 14:31:40 +080041%token PE_START_EVENTS PE_START_TERMS
Jiri Olsacf3506d2012-07-04 00:00:43 +020042%token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM
Robert Richterac2ba9f2012-08-16 21:10:21 +020043%token PE_EVENT_NAME
Jiri Olsa89812fc2012-03-15 20:09:15 +010044%token PE_NAME
Wang Nand509db02015-10-14 12:41:20 +000045%token PE_BPF_OBJECT PE_BPF_SOURCE
Jiri Olsa89812fc2012-03-15 20:09:15 +010046%token PE_MODIFIER_EVENT PE_MODIFIER_BP
47%token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
Jiri Olsa89efb022012-08-08 12:14:14 +020048%token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP
Jiri Olsa89812fc2012-03-15 20:09:15 +010049%token PE_ERROR
Kan Liangba32a452014-10-07 11:08:51 -040050%token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT
Jiri Olsa89812fc2012-03-15 20:09:15 +010051%type <num> PE_VALUE
Jiri Olsacf3506d2012-07-04 00:00:43 +020052%type <num> PE_VALUE_SYM_HW
53%type <num> PE_VALUE_SYM_SW
Jiri Olsa89812fc2012-03-15 20:09:15 +010054%type <num> PE_RAW
Jiri Olsa8f707d82012-03-15 20:09:16 +010055%type <num> PE_TERM
Jiri Olsa89812fc2012-03-15 20:09:15 +010056%type <str> PE_NAME
Wang Nan84c86ca2015-10-14 12:41:14 +000057%type <str> PE_BPF_OBJECT
Wang Nand509db02015-10-14 12:41:20 +000058%type <str> PE_BPF_SOURCE
Jiri Olsa89812fc2012-03-15 20:09:15 +010059%type <str> PE_NAME_CACHE_TYPE
60%type <str> PE_NAME_CACHE_OP_RESULT
61%type <str> PE_MODIFIER_EVENT
62%type <str> PE_MODIFIER_BP
Robert Richterac2ba9f2012-08-16 21:10:21 +020063%type <str> PE_EVENT_NAME
Kan Liangba32a452014-10-07 11:08:51 -040064%type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT
Jiri Olsacf3506d2012-07-04 00:00:43 +020065%type <num> value_sym
Jiri Olsa8f707d82012-03-15 20:09:16 +010066%type <head> event_config
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -030067%type <head> opt_event_config
Jiri Olsa8f707d82012-03-15 20:09:16 +010068%type <term> event_term
Jiri Olsab847cbd2012-05-21 09:12:51 +020069%type <head> event_pmu
70%type <head> event_legacy_symbol
71%type <head> event_legacy_cache
72%type <head> event_legacy_mem
73%type <head> event_legacy_tracepoint
He Kuang865582c2015-09-28 03:52:15 +000074%type <tracepoint_name> tracepoint_name
Jiri Olsab847cbd2012-05-21 09:12:51 +020075%type <head> event_legacy_numeric
76%type <head> event_legacy_raw
Wang Nan84c86ca2015-10-14 12:41:14 +000077%type <head> event_bpf_file
Jiri Olsab847cbd2012-05-21 09:12:51 +020078%type <head> event_def
Robert Richterac2ba9f2012-08-16 21:10:21 +020079%type <head> event_mod
80%type <head> event_name
Jiri Olsa89efb022012-08-08 12:14:14 +020081%type <head> event
82%type <head> events
83%type <head> group_def
84%type <head> group
85%type <head> groups
Jiri Olsa89812fc2012-03-15 20:09:15 +010086
87%union
88{
89 char *str;
Robert Richterb527bab2012-08-07 19:43:13 +020090 u64 num;
Jiri Olsa8f707d82012-03-15 20:09:16 +010091 struct list_head *head;
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -030092 struct parse_events_term *term;
He Kuang865582c2015-09-28 03:52:15 +000093 struct tracepoint_name {
94 char *sys;
95 char *event;
96 } tracepoint_name;
Jiri Olsa89812fc2012-03-15 20:09:15 +010097}
98%%
99
Jiri Olsa90e2b222012-06-15 14:31:40 +0800100start:
Jiri Olsa89efb022012-08-08 12:14:14 +0200101PE_START_EVENTS start_events
Jiri Olsa90e2b222012-06-15 14:31:40 +0800102|
Jiri Olsa89efb022012-08-08 12:14:14 +0200103PE_START_TERMS start_terms
104
105start_events: groups
106{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300107 struct parse_events_evlist *data = _data;
Jiri Olsa89efb022012-08-08 12:14:14 +0200108
109 parse_events_update_lists($1, &data->list);
110}
111
112groups:
113groups ',' group
114{
115 struct list_head *list = $1;
116 struct list_head *group = $3;
117
118 parse_events_update_lists(group, list);
119 $$ = list;
120}
121|
122groups ',' event
123{
124 struct list_head *list = $1;
125 struct list_head *event = $3;
126
127 parse_events_update_lists(event, list);
128 $$ = list;
129}
130|
131group
132|
133event
134
135group:
136group_def ':' PE_MODIFIER_EVENT
137{
138 struct list_head *list = $1;
139
140 ABORT_ON(parse_events__modifier_group(list, $3));
141 $$ = list;
142}
143|
144group_def
145
146group_def:
147PE_NAME '{' events '}'
148{
149 struct list_head *list = $3;
150
Namhyung Kim97f63e42013-01-22 18:09:29 +0900151 inc_group_count(list, _data);
Arnaldo Carvalho de Melo63dab222012-08-14 16:35:48 -0300152 parse_events__set_leader($1, list);
Jiri Olsa89efb022012-08-08 12:14:14 +0200153 $$ = list;
154}
155|
156'{' events '}'
157{
158 struct list_head *list = $2;
159
Namhyung Kim97f63e42013-01-22 18:09:29 +0900160 inc_group_count(list, _data);
Arnaldo Carvalho de Melo63dab222012-08-14 16:35:48 -0300161 parse_events__set_leader(NULL, list);
Jiri Olsa89efb022012-08-08 12:14:14 +0200162 $$ = list;
163}
Jiri Olsa90e2b222012-06-15 14:31:40 +0800164
Jiri Olsa89812fc2012-03-15 20:09:15 +0100165events:
Jiri Olsa89efb022012-08-08 12:14:14 +0200166events ',' event
167{
168 struct list_head *event = $3;
169 struct list_head *list = $1;
170
171 parse_events_update_lists(event, list);
172 $$ = list;
173}
174|
175event
Jiri Olsa89812fc2012-03-15 20:09:15 +0100176
Robert Richterac2ba9f2012-08-16 21:10:21 +0200177event: event_mod
178
179event_mod:
180event_name PE_MODIFIER_EVENT
Jiri Olsa89812fc2012-03-15 20:09:15 +0100181{
Jiri Olsa89efb022012-08-08 12:14:14 +0200182 struct list_head *list = $1;
Jiri Olsa46010ab2012-06-15 14:31:38 +0800183
Jiri Olsa5d7be902012-03-20 19:15:40 +0100184 /*
185 * Apply modifier on all events added by single event definition
186 * (there could be more events added for multiple tracepoint
187 * definitions via '*?'.
188 */
Jiri Olsaf5b11352012-08-08 12:21:54 +0200189 ABORT_ON(parse_events__modifier_event(list, $2, false));
Jiri Olsa89efb022012-08-08 12:14:14 +0200190 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100191}
192|
Robert Richterac2ba9f2012-08-16 21:10:21 +0200193event_name
194
195event_name:
196PE_EVENT_NAME event_def
197{
198 ABORT_ON(parse_events_name($2, $1));
199 free($1);
200 $$ = $2;
201}
202|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100203event_def
204
Jiri Olsa5f537a22012-03-15 20:09:18 +0100205event_def: event_pmu |
206 event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +0100207 event_legacy_cache sep_dc |
208 event_legacy_mem |
209 event_legacy_tracepoint sep_dc |
210 event_legacy_numeric sep_dc |
Wang Nan84c86ca2015-10-14 12:41:14 +0000211 event_legacy_raw sep_dc |
212 event_bpf_file
Jiri Olsa89812fc2012-03-15 20:09:15 +0100213
Jiri Olsa5f537a22012-03-15 20:09:18 +0100214event_pmu:
215PE_NAME '/' event_config '/'
216{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300217 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600218 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200219
David Ahernc5cd8ac2013-07-02 13:27:25 -0600220 ALLOC_LIST(list);
Jiri Olsa36adec82015-04-22 21:10:19 +0200221 ABORT_ON(parse_events_add_pmu(data, list, $1, $3));
Arnaldo Carvalho de Melo2146afc2016-02-12 17:09:17 -0300222 parse_events_terms__delete($3);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200223 $$ = list;
Jiri Olsa5f537a22012-03-15 20:09:18 +0100224}
Adrian Hunterad962272014-08-15 22:08:40 +0300225|
Kan Liangba32a452014-10-07 11:08:51 -0400226PE_KERNEL_PMU_EVENT sep_dc
227{
228 struct parse_events_evlist *data = _data;
229 struct list_head *head;
230 struct parse_events_term *term;
231 struct list_head *list;
232
233 ALLOC_LIST(head);
234 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200235 $1, 1, &@1, NULL));
Kan Liangba32a452014-10-07 11:08:51 -0400236 list_add_tail(&term->list, head);
237
238 ALLOC_LIST(list);
Jiri Olsa36adec82015-04-22 21:10:19 +0200239 ABORT_ON(parse_events_add_pmu(data, list, "cpu", head));
Arnaldo Carvalho de Melo2146afc2016-02-12 17:09:17 -0300240 parse_events_terms__delete(head);
Kan Liangba32a452014-10-07 11:08:51 -0400241 $$ = list;
242}
243|
244PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
245{
246 struct parse_events_evlist *data = _data;
247 struct list_head *head;
248 struct parse_events_term *term;
249 struct list_head *list;
250 char pmu_name[128];
251 snprintf(&pmu_name, 128, "%s-%s", $1, $3);
252
253 ALLOC_LIST(head);
254 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200255 &pmu_name, 1, &@1, NULL));
Kan Liangba32a452014-10-07 11:08:51 -0400256 list_add_tail(&term->list, head);
257
258 ALLOC_LIST(list);
Jiri Olsa5ad4da42015-09-02 09:56:31 +0200259 ABORT_ON(parse_events_add_pmu(data, list, "cpu", head));
Arnaldo Carvalho de Melo2146afc2016-02-12 17:09:17 -0300260 parse_events_terms__delete(head);
Kan Liangba32a452014-10-07 11:08:51 -0400261 $$ = list;
262}
Jiri Olsa5f537a22012-03-15 20:09:18 +0100263
Jiri Olsacf3506d2012-07-04 00:00:43 +0200264value_sym:
265PE_VALUE_SYM_HW
266|
267PE_VALUE_SYM_SW
268
Jiri Olsa89812fc2012-03-15 20:09:15 +0100269event_legacy_symbol:
Jiri Olsacf3506d2012-07-04 00:00:43 +0200270value_sym '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +0100271{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300272 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600273 struct list_head *list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100274 int type = $1 >> 16;
275 int config = $1 & 255;
276
David Ahernc5cd8ac2013-07-02 13:27:25 -0600277 ALLOC_LIST(list);
Jiri Olsa87d650b2015-04-22 21:10:24 +0200278 ABORT_ON(parse_events_add_numeric(data, list, type, config, $3));
Arnaldo Carvalho de Melo2146afc2016-02-12 17:09:17 -0300279 parse_events_terms__delete($3);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200280 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100281}
282|
Jiri Olsacf3506d2012-07-04 00:00:43 +0200283value_sym sep_slash_dc
Jiri Olsa8f707d82012-03-15 20:09:16 +0100284{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300285 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600286 struct list_head *list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100287 int type = $1 >> 16;
288 int config = $1 & 255;
289
David Ahernc5cd8ac2013-07-02 13:27:25 -0600290 ALLOC_LIST(list);
Jiri Olsa87d650b2015-04-22 21:10:24 +0200291 ABORT_ON(parse_events_add_numeric(data, list, type, config, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200292 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100293}
294
295event_legacy_cache:
Wang Nan43d0b972016-02-19 11:44:01 +0000296PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100297{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300298 struct parse_events_evlist *data = _data;
Wang Nan43d0b972016-02-19 11:44:01 +0000299 struct parse_events_error *error = data->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600300 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200301
David Ahernc5cd8ac2013-07-02 13:27:25 -0600302 ALLOC_LIST(list);
Wang Nan43d0b972016-02-19 11:44:01 +0000303 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, $5, error, $6));
304 parse_events_terms__delete($6);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200305 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100306}
307|
Wang Nan43d0b972016-02-19 11:44:01 +0000308PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100309{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300310 struct parse_events_evlist *data = _data;
Wang Nan43d0b972016-02-19 11:44:01 +0000311 struct parse_events_error *error = data->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600312 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200313
David Ahernc5cd8ac2013-07-02 13:27:25 -0600314 ALLOC_LIST(list);
Wang Nan43d0b972016-02-19 11:44:01 +0000315 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, NULL, error, $4));
316 parse_events_terms__delete($4);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200317 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100318}
319|
Wang Nan43d0b972016-02-19 11:44:01 +0000320PE_NAME_CACHE_TYPE opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100321{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300322 struct parse_events_evlist *data = _data;
Wang Nan43d0b972016-02-19 11:44:01 +0000323 struct parse_events_error *error = data->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600324 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200325
David Ahernc5cd8ac2013-07-02 13:27:25 -0600326 ALLOC_LIST(list);
Wang Nan43d0b972016-02-19 11:44:01 +0000327 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, NULL, NULL, error, $2));
328 parse_events_terms__delete($2);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200329 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100330}
331
332event_legacy_mem:
Jacob Shin3741eb92014-05-29 17:26:51 +0200333PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
334{
335 struct parse_events_evlist *data = _data;
336 struct list_head *list;
337
338 ALLOC_LIST(list);
339 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
340 (void *) $2, $6, $4));
341 $$ = list;
342}
343|
344PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
345{
346 struct parse_events_evlist *data = _data;
347 struct list_head *list;
348
349 ALLOC_LIST(list);
350 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
351 (void *) $2, NULL, $4));
352 $$ = list;
353}
354|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100355PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
356{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300357 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600358 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200359
David Ahernc5cd8ac2013-07-02 13:27:25 -0600360 ALLOC_LIST(list);
361 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
Jacob Shin3741eb92014-05-29 17:26:51 +0200362 (void *) $2, $4, 0));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200363 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100364}
365|
366PE_PREFIX_MEM PE_VALUE sep_dc
367{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300368 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600369 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200370
David Ahernc5cd8ac2013-07-02 13:27:25 -0600371 ALLOC_LIST(list);
372 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
Jacob Shin3741eb92014-05-29 17:26:51 +0200373 (void *) $2, NULL, 0));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200374 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100375}
376
377event_legacy_tracepoint:
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300378tracepoint_name opt_event_config
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200379{
380 struct parse_events_evlist *data = _data;
Jiri Olsa19658172015-09-07 10:38:07 +0200381 struct parse_events_error *error = data->error;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200382 struct list_head *list;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200383
384 ALLOC_LIST(list);
He Kuange637d172015-09-28 03:52:16 +0000385 if (error)
386 error->idx = @1.first_column;
387
He Kuang865582c2015-09-28 03:52:15 +0000388 if (parse_events_add_tracepoint(list, &data->idx, $1.sys, $1.event,
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300389 error, $2))
He Kuange637d172015-09-28 03:52:16 +0000390 return -1;
391
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200392 $$ = list;
393}
He Kuang865582c2015-09-28 03:52:15 +0000394
395tracepoint_name:
396PE_NAME '-' PE_NAME ':' PE_NAME
397{
398 char sys_name[128];
399 struct tracepoint_name tracepoint;
400
401 snprintf(&sys_name, 128, "%s-%s", $1, $3);
402 tracepoint.sys = &sys_name;
403 tracepoint.event = $5;
404
405 $$ = tracepoint;
406}
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200407|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100408PE_NAME ':' PE_NAME
409{
He Kuang865582c2015-09-28 03:52:15 +0000410 struct tracepoint_name tracepoint = {$1, $3};
Jiri Olsab847cbd2012-05-21 09:12:51 +0200411
He Kuang865582c2015-09-28 03:52:15 +0000412 $$ = tracepoint;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100413}
414
415event_legacy_numeric:
Wang Nan10bf3582016-02-19 11:44:00 +0000416PE_VALUE ':' PE_VALUE opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100417{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300418 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600419 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200420
David Ahernc5cd8ac2013-07-02 13:27:25 -0600421 ALLOC_LIST(list);
Wang Nan10bf3582016-02-19 11:44:00 +0000422 ABORT_ON(parse_events_add_numeric(data, list, (u32)$1, $3, $4));
423 parse_events_terms__delete($4);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200424 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100425}
426
427event_legacy_raw:
Wang Nan10bf3582016-02-19 11:44:00 +0000428PE_RAW opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100429{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300430 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600431 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200432
David Ahernc5cd8ac2013-07-02 13:27:25 -0600433 ALLOC_LIST(list);
Wang Nan10bf3582016-02-19 11:44:00 +0000434 ABORT_ON(parse_events_add_numeric(data, list, PERF_TYPE_RAW, $1, $2));
435 parse_events_terms__delete($2);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200436 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100437}
438
Wang Nan84c86ca2015-10-14 12:41:14 +0000439event_bpf_file:
440PE_BPF_OBJECT
441{
442 struct parse_events_evlist *data = _data;
443 struct parse_events_error *error = data->error;
444 struct list_head *list;
445
446 ALLOC_LIST(list);
Wang Nand509db02015-10-14 12:41:20 +0000447 ABORT_ON(parse_events_load_bpf(data, list, $1, false));
448 $$ = list;
449}
450|
451PE_BPF_SOURCE
452{
453 struct parse_events_evlist *data = _data;
454 struct list_head *list;
455
456 ALLOC_LIST(list);
457 ABORT_ON(parse_events_load_bpf(data, list, $1, true));
Wang Nan84c86ca2015-10-14 12:41:14 +0000458 $$ = list;
459}
460
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300461opt_event_config:
462'/' event_config '/'
463{
464 $$ = $2;
465}
466|
467'/' '/'
468{
469 $$ = NULL;
470}
471|
472{
473 $$ = NULL;
474}
475
Jiri Olsa89efb022012-08-08 12:14:14 +0200476start_terms: event_config
Jiri Olsa90e2b222012-06-15 14:31:40 +0800477{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300478 struct parse_events_terms *data = _data;
Jiri Olsa90e2b222012-06-15 14:31:40 +0800479 data->terms = $1;
480}
481
Jiri Olsa8f707d82012-03-15 20:09:16 +0100482event_config:
483event_config ',' event_term
484{
485 struct list_head *head = $1;
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300486 struct parse_events_term *term = $3;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100487
488 ABORT_ON(!head);
489 list_add_tail(&term->list, head);
490 $$ = $1;
491}
492|
493event_term
494{
495 struct list_head *head = malloc(sizeof(*head));
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300496 struct parse_events_term *term = $1;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100497
498 ABORT_ON(!head);
499 INIT_LIST_HEAD(head);
500 list_add_tail(&term->list, head);
501 $$ = head;
502}
503
504event_term:
505PE_NAME '=' PE_NAME
506{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300507 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100508
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300509 ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200510 $1, $3, &@1, &@3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100511 $$ = term;
512}
513|
514PE_NAME '=' PE_VALUE
515{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300516 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100517
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300518 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200519 $1, $3, &@1, &@3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100520 $$ = term;
521}
522|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200523PE_NAME '=' PE_VALUE_SYM_HW
524{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300525 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200526 int config = $3 & 255;
527
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300528 ABORT_ON(parse_events_term__sym_hw(&term, $1, config));
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200529 $$ = term;
530}
531|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100532PE_NAME
533{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300534 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100535
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300536 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200537 $1, 1, &@1, NULL));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100538 $$ = term;
539}
540|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200541PE_VALUE_SYM_HW
542{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300543 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200544 int config = $1 & 255;
545
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300546 ABORT_ON(parse_events_term__sym_hw(&term, NULL, config));
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200547 $$ = term;
548}
549|
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200550PE_TERM '=' PE_NAME
551{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300552 struct parse_events_term *term;
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200553
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200554 ABORT_ON(parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3));
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200555 $$ = term;
556}
557|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100558PE_TERM '=' PE_VALUE
559{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300560 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100561
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200562 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, &@1, &@3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100563 $$ = term;
564}
565|
566PE_TERM
567{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300568 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100569
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200570 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, &@1, NULL));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100571 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100572}
573
574sep_dc: ':' |
575
Jiri Olsa8f707d82012-03-15 20:09:16 +0100576sep_slash_dc: '/' | ':' |
577
Jiri Olsa89812fc2012-03-15 20:09:15 +0100578%%
579
Jiri Olsa6297d422015-04-22 21:10:17 +0200580void parse_events_error(YYLTYPE *loc, void *data,
581 void *scanner __maybe_unused,
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300582 char const *msg __maybe_unused)
Jiri Olsa89812fc2012-03-15 20:09:15 +0100583{
Jiri Olsa6297d422015-04-22 21:10:17 +0200584 parse_events_evlist_error(data, loc->last_column, "parser error");
Jiri Olsa89812fc2012-03-15 20:09:15 +0100585}