blob: 82029f92c4d297a9f293247ed553a472ef737c5e [file] [log] [blame]
Zheng Yanac20de62012-06-15 14:31:39 +08001%pure-parser
Jiri Olsa46010ab2012-06-15 14:31:38 +08002%parse-param {void *_data}
Zheng Yanac20de62012-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 Yanac20de62012-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:
296PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
297{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300298 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600299 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200300
David Ahernc5cd8ac2013-07-02 13:27:25 -0600301 ALLOC_LIST(list);
302 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, $5));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200303 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100304}
305|
306PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
307{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300308 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600309 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200310
David Ahernc5cd8ac2013-07-02 13:27:25 -0600311 ALLOC_LIST(list);
312 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200313 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100314}
315|
316PE_NAME_CACHE_TYPE
317{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300318 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600319 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200320
David Ahernc5cd8ac2013-07-02 13:27:25 -0600321 ALLOC_LIST(list);
322 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, NULL, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200323 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100324}
325
326event_legacy_mem:
Jacob Shin3741eb92014-05-29 17:26:51 +0200327PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
328{
329 struct parse_events_evlist *data = _data;
330 struct list_head *list;
331
332 ALLOC_LIST(list);
333 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
334 (void *) $2, $6, $4));
335 $$ = list;
336}
337|
338PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
339{
340 struct parse_events_evlist *data = _data;
341 struct list_head *list;
342
343 ALLOC_LIST(list);
344 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
345 (void *) $2, NULL, $4));
346 $$ = list;
347}
348|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100349PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
350{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300351 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600352 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200353
David Ahernc5cd8ac2013-07-02 13:27:25 -0600354 ALLOC_LIST(list);
355 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
Jacob Shin3741eb92014-05-29 17:26:51 +0200356 (void *) $2, $4, 0));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200357 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100358}
359|
360PE_PREFIX_MEM PE_VALUE sep_dc
361{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300362 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600363 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200364
David Ahernc5cd8ac2013-07-02 13:27:25 -0600365 ALLOC_LIST(list);
366 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
Jacob Shin3741eb92014-05-29 17:26:51 +0200367 (void *) $2, NULL, 0));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200368 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100369}
370
371event_legacy_tracepoint:
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300372tracepoint_name opt_event_config
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200373{
374 struct parse_events_evlist *data = _data;
Jiri Olsa19658172015-09-07 10:38:07 +0200375 struct parse_events_error *error = data->error;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200376 struct list_head *list;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200377
378 ALLOC_LIST(list);
He Kuange637d172015-09-28 03:52:16 +0000379 if (error)
380 error->idx = @1.first_column;
381
He Kuang865582c2015-09-28 03:52:15 +0000382 if (parse_events_add_tracepoint(list, &data->idx, $1.sys, $1.event,
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300383 error, $2))
He Kuange637d172015-09-28 03:52:16 +0000384 return -1;
385
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200386 $$ = list;
387}
He Kuang865582c2015-09-28 03:52:15 +0000388
389tracepoint_name:
390PE_NAME '-' PE_NAME ':' PE_NAME
391{
392 char sys_name[128];
393 struct tracepoint_name tracepoint;
394
395 snprintf(&sys_name, 128, "%s-%s", $1, $3);
396 tracepoint.sys = &sys_name;
397 tracepoint.event = $5;
398
399 $$ = tracepoint;
400}
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200401|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100402PE_NAME ':' PE_NAME
403{
He Kuang865582c2015-09-28 03:52:15 +0000404 struct tracepoint_name tracepoint = {$1, $3};
Jiri Olsab847cbd2012-05-21 09:12:51 +0200405
He Kuang865582c2015-09-28 03:52:15 +0000406 $$ = tracepoint;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100407}
408
409event_legacy_numeric:
Wang Nan10bf3582016-02-19 11:44:00 +0000410PE_VALUE ':' PE_VALUE opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100411{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300412 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600413 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200414
David Ahernc5cd8ac2013-07-02 13:27:25 -0600415 ALLOC_LIST(list);
Wang Nan10bf3582016-02-19 11:44:00 +0000416 ABORT_ON(parse_events_add_numeric(data, list, (u32)$1, $3, $4));
417 parse_events_terms__delete($4);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200418 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100419}
420
421event_legacy_raw:
Wang Nan10bf3582016-02-19 11:44:00 +0000422PE_RAW opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100423{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300424 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600425 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200426
David Ahernc5cd8ac2013-07-02 13:27:25 -0600427 ALLOC_LIST(list);
Wang Nan10bf3582016-02-19 11:44:00 +0000428 ABORT_ON(parse_events_add_numeric(data, list, PERF_TYPE_RAW, $1, $2));
429 parse_events_terms__delete($2);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200430 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100431}
432
Wang Nan84c86ca2015-10-14 12:41:14 +0000433event_bpf_file:
434PE_BPF_OBJECT
435{
436 struct parse_events_evlist *data = _data;
437 struct parse_events_error *error = data->error;
438 struct list_head *list;
439
440 ALLOC_LIST(list);
Wang Nand509db02015-10-14 12:41:20 +0000441 ABORT_ON(parse_events_load_bpf(data, list, $1, false));
442 $$ = list;
443}
444|
445PE_BPF_SOURCE
446{
447 struct parse_events_evlist *data = _data;
448 struct list_head *list;
449
450 ALLOC_LIST(list);
451 ABORT_ON(parse_events_load_bpf(data, list, $1, true));
Wang Nan84c86ca2015-10-14 12:41:14 +0000452 $$ = list;
453}
454
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300455opt_event_config:
456'/' event_config '/'
457{
458 $$ = $2;
459}
460|
461'/' '/'
462{
463 $$ = NULL;
464}
465|
466{
467 $$ = NULL;
468}
469
Jiri Olsa89efb022012-08-08 12:14:14 +0200470start_terms: event_config
Jiri Olsa90e2b222012-06-15 14:31:40 +0800471{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300472 struct parse_events_terms *data = _data;
Jiri Olsa90e2b222012-06-15 14:31:40 +0800473 data->terms = $1;
474}
475
Jiri Olsa8f707d82012-03-15 20:09:16 +0100476event_config:
477event_config ',' event_term
478{
479 struct list_head *head = $1;
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300480 struct parse_events_term *term = $3;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100481
482 ABORT_ON(!head);
483 list_add_tail(&term->list, head);
484 $$ = $1;
485}
486|
487event_term
488{
489 struct list_head *head = malloc(sizeof(*head));
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300490 struct parse_events_term *term = $1;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100491
492 ABORT_ON(!head);
493 INIT_LIST_HEAD(head);
494 list_add_tail(&term->list, head);
495 $$ = head;
496}
497
498event_term:
499PE_NAME '=' PE_NAME
500{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300501 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100502
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300503 ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200504 $1, $3, &@1, &@3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100505 $$ = term;
506}
507|
508PE_NAME '=' PE_VALUE
509{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300510 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100511
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300512 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200513 $1, $3, &@1, &@3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100514 $$ = term;
515}
516|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200517PE_NAME '=' PE_VALUE_SYM_HW
518{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300519 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200520 int config = $3 & 255;
521
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300522 ABORT_ON(parse_events_term__sym_hw(&term, $1, config));
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200523 $$ = term;
524}
525|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100526PE_NAME
527{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300528 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100529
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300530 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200531 $1, 1, &@1, NULL));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100532 $$ = term;
533}
534|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200535PE_VALUE_SYM_HW
536{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300537 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200538 int config = $1 & 255;
539
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300540 ABORT_ON(parse_events_term__sym_hw(&term, NULL, config));
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200541 $$ = term;
542}
543|
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200544PE_TERM '=' PE_NAME
545{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300546 struct parse_events_term *term;
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200547
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200548 ABORT_ON(parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3));
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200549 $$ = term;
550}
551|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100552PE_TERM '=' PE_VALUE
553{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300554 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100555
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200556 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, &@1, &@3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100557 $$ = term;
558}
559|
560PE_TERM
561{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300562 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100563
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200564 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, &@1, NULL));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100565 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100566}
567
568sep_dc: ':' |
569
Jiri Olsa8f707d82012-03-15 20:09:16 +0100570sep_slash_dc: '/' | ':' |
571
Jiri Olsa89812fc2012-03-15 20:09:15 +0100572%%
573
Jiri Olsa6297d422015-04-22 21:10:17 +0200574void parse_events_error(YYLTYPE *loc, void *data,
575 void *scanner __maybe_unused,
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300576 char const *msg __maybe_unused)
Jiri Olsa89812fc2012-03-15 20:09:15 +0100577{
Jiri Olsa6297d422015-04-22 21:10:17 +0200578 parse_events_evlist_error(data, loc->last_column, "parser error");
Jiri Olsa89812fc2012-03-15 20:09:15 +0100579}