blob: c0eac88ef474c3af50a5d8ed1f579519fd29de10 [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
67%type <term> event_term
Jiri Olsab847cbd2012-05-21 09:12:51 +020068%type <head> event_pmu
69%type <head> event_legacy_symbol
70%type <head> event_legacy_cache
71%type <head> event_legacy_mem
72%type <head> event_legacy_tracepoint
He Kuang865582c2015-09-28 03:52:15 +000073%type <tracepoint_name> tracepoint_name
Jiri Olsab847cbd2012-05-21 09:12:51 +020074%type <head> event_legacy_numeric
75%type <head> event_legacy_raw
Wang Nan84c86ca2015-10-14 12:41:14 +000076%type <head> event_bpf_file
Jiri Olsab847cbd2012-05-21 09:12:51 +020077%type <head> event_def
Robert Richterac2ba9f2012-08-16 21:10:21 +020078%type <head> event_mod
79%type <head> event_name
Jiri Olsa89efb022012-08-08 12:14:14 +020080%type <head> event
81%type <head> events
82%type <head> group_def
83%type <head> group
84%type <head> groups
Jiri Olsa89812fc2012-03-15 20:09:15 +010085
86%union
87{
88 char *str;
Robert Richterb527bab2012-08-07 19:43:13 +020089 u64 num;
Jiri Olsa8f707d82012-03-15 20:09:16 +010090 struct list_head *head;
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -030091 struct parse_events_term *term;
He Kuang865582c2015-09-28 03:52:15 +000092 struct tracepoint_name {
93 char *sys;
94 char *event;
95 } tracepoint_name;
Jiri Olsa89812fc2012-03-15 20:09:15 +010096}
97%%
98
Jiri Olsa90e2b222012-06-15 14:31:40 +080099start:
Jiri Olsa89efb022012-08-08 12:14:14 +0200100PE_START_EVENTS start_events
Jiri Olsa90e2b222012-06-15 14:31:40 +0800101|
Jiri Olsa89efb022012-08-08 12:14:14 +0200102PE_START_TERMS start_terms
103
104start_events: groups
105{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300106 struct parse_events_evlist *data = _data;
Jiri Olsa89efb022012-08-08 12:14:14 +0200107
108 parse_events_update_lists($1, &data->list);
109}
110
111groups:
112groups ',' group
113{
114 struct list_head *list = $1;
115 struct list_head *group = $3;
116
117 parse_events_update_lists(group, list);
118 $$ = list;
119}
120|
121groups ',' event
122{
123 struct list_head *list = $1;
124 struct list_head *event = $3;
125
126 parse_events_update_lists(event, list);
127 $$ = list;
128}
129|
130group
131|
132event
133
134group:
135group_def ':' PE_MODIFIER_EVENT
136{
137 struct list_head *list = $1;
138
139 ABORT_ON(parse_events__modifier_group(list, $3));
140 $$ = list;
141}
142|
143group_def
144
145group_def:
146PE_NAME '{' events '}'
147{
148 struct list_head *list = $3;
149
Namhyung Kim97f63e42013-01-22 18:09:29 +0900150 inc_group_count(list, _data);
Arnaldo Carvalho de Melo63dab222012-08-14 16:35:48 -0300151 parse_events__set_leader($1, list);
Jiri Olsa89efb022012-08-08 12:14:14 +0200152 $$ = list;
153}
154|
155'{' events '}'
156{
157 struct list_head *list = $2;
158
Namhyung Kim97f63e42013-01-22 18:09:29 +0900159 inc_group_count(list, _data);
Arnaldo Carvalho de Melo63dab222012-08-14 16:35:48 -0300160 parse_events__set_leader(NULL, list);
Jiri Olsa89efb022012-08-08 12:14:14 +0200161 $$ = list;
162}
Jiri Olsa90e2b222012-06-15 14:31:40 +0800163
Jiri Olsa89812fc2012-03-15 20:09:15 +0100164events:
Jiri Olsa89efb022012-08-08 12:14:14 +0200165events ',' event
166{
167 struct list_head *event = $3;
168 struct list_head *list = $1;
169
170 parse_events_update_lists(event, list);
171 $$ = list;
172}
173|
174event
Jiri Olsa89812fc2012-03-15 20:09:15 +0100175
Robert Richterac2ba9f2012-08-16 21:10:21 +0200176event: event_mod
177
178event_mod:
179event_name PE_MODIFIER_EVENT
Jiri Olsa89812fc2012-03-15 20:09:15 +0100180{
Jiri Olsa89efb022012-08-08 12:14:14 +0200181 struct list_head *list = $1;
Jiri Olsa46010ab2012-06-15 14:31:38 +0800182
Jiri Olsa5d7be902012-03-20 19:15:40 +0100183 /*
184 * Apply modifier on all events added by single event definition
185 * (there could be more events added for multiple tracepoint
186 * definitions via '*?'.
187 */
Jiri Olsaf5b11352012-08-08 12:21:54 +0200188 ABORT_ON(parse_events__modifier_event(list, $2, false));
Jiri Olsa89efb022012-08-08 12:14:14 +0200189 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100190}
191|
Robert Richterac2ba9f2012-08-16 21:10:21 +0200192event_name
193
194event_name:
195PE_EVENT_NAME event_def
196{
197 ABORT_ON(parse_events_name($2, $1));
198 free($1);
199 $$ = $2;
200}
201|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100202event_def
203
Jiri Olsa5f537a22012-03-15 20:09:18 +0100204event_def: event_pmu |
205 event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +0100206 event_legacy_cache sep_dc |
207 event_legacy_mem |
208 event_legacy_tracepoint sep_dc |
209 event_legacy_numeric sep_dc |
Wang Nan84c86ca2015-10-14 12:41:14 +0000210 event_legacy_raw sep_dc |
211 event_bpf_file
Jiri Olsa89812fc2012-03-15 20:09:15 +0100212
Jiri Olsa5f537a22012-03-15 20:09:18 +0100213event_pmu:
214PE_NAME '/' event_config '/'
215{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300216 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600217 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200218
David Ahernc5cd8ac2013-07-02 13:27:25 -0600219 ALLOC_LIST(list);
Jiri Olsa36adec82015-04-22 21:10:19 +0200220 ABORT_ON(parse_events_add_pmu(data, list, $1, $3));
Arnaldo Carvalho de Melo2146afc2016-02-12 17:09:17 -0300221 parse_events_terms__delete($3);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200222 $$ = list;
Jiri Olsa5f537a22012-03-15 20:09:18 +0100223}
Adrian Hunterad962272014-08-15 22:08:40 +0300224|
225PE_NAME '/' '/'
226{
227 struct parse_events_evlist *data = _data;
228 struct list_head *list;
229
230 ALLOC_LIST(list);
Jiri Olsa36adec82015-04-22 21:10:19 +0200231 ABORT_ON(parse_events_add_pmu(data, list, $1, NULL));
Adrian Hunterad962272014-08-15 22:08:40 +0300232 $$ = list;
233}
Kan Liangba32a452014-10-07 11:08:51 -0400234|
235PE_KERNEL_PMU_EVENT sep_dc
236{
237 struct parse_events_evlist *data = _data;
238 struct list_head *head;
239 struct parse_events_term *term;
240 struct list_head *list;
241
242 ALLOC_LIST(head);
243 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200244 $1, 1, &@1, NULL));
Kan Liangba32a452014-10-07 11:08:51 -0400245 list_add_tail(&term->list, head);
246
247 ALLOC_LIST(list);
Jiri Olsa36adec82015-04-22 21:10:19 +0200248 ABORT_ON(parse_events_add_pmu(data, list, "cpu", head));
Arnaldo Carvalho de Melo2146afc2016-02-12 17:09:17 -0300249 parse_events_terms__delete(head);
Kan Liangba32a452014-10-07 11:08:51 -0400250 $$ = list;
251}
252|
253PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
254{
255 struct parse_events_evlist *data = _data;
256 struct list_head *head;
257 struct parse_events_term *term;
258 struct list_head *list;
259 char pmu_name[128];
260 snprintf(&pmu_name, 128, "%s-%s", $1, $3);
261
262 ALLOC_LIST(head);
263 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200264 &pmu_name, 1, &@1, NULL));
Kan Liangba32a452014-10-07 11:08:51 -0400265 list_add_tail(&term->list, head);
266
267 ALLOC_LIST(list);
Jiri Olsa5ad4da42015-09-02 09:56:31 +0200268 ABORT_ON(parse_events_add_pmu(data, list, "cpu", head));
Arnaldo Carvalho de Melo2146afc2016-02-12 17:09:17 -0300269 parse_events_terms__delete(head);
Kan Liangba32a452014-10-07 11:08:51 -0400270 $$ = list;
271}
Jiri Olsa5f537a22012-03-15 20:09:18 +0100272
Jiri Olsacf3506d2012-07-04 00:00:43 +0200273value_sym:
274PE_VALUE_SYM_HW
275|
276PE_VALUE_SYM_SW
277
Jiri Olsa89812fc2012-03-15 20:09:15 +0100278event_legacy_symbol:
Jiri Olsacf3506d2012-07-04 00:00:43 +0200279value_sym '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +0100280{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300281 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600282 struct list_head *list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100283 int type = $1 >> 16;
284 int config = $1 & 255;
285
David Ahernc5cd8ac2013-07-02 13:27:25 -0600286 ALLOC_LIST(list);
Jiri Olsa87d650b2015-04-22 21:10:24 +0200287 ABORT_ON(parse_events_add_numeric(data, list, type, config, $3));
Arnaldo Carvalho de Melo2146afc2016-02-12 17:09:17 -0300288 parse_events_terms__delete($3);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200289 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100290}
291|
Jiri Olsacf3506d2012-07-04 00:00:43 +0200292value_sym sep_slash_dc
Jiri Olsa8f707d82012-03-15 20:09:16 +0100293{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300294 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600295 struct list_head *list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100296 int type = $1 >> 16;
297 int config = $1 & 255;
298
David Ahernc5cd8ac2013-07-02 13:27:25 -0600299 ALLOC_LIST(list);
Jiri Olsa87d650b2015-04-22 21:10:24 +0200300 ABORT_ON(parse_events_add_numeric(data, list, type, config, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200301 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100302}
303
304event_legacy_cache:
305PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
306{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300307 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600308 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200309
David Ahernc5cd8ac2013-07-02 13:27:25 -0600310 ALLOC_LIST(list);
311 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, $5));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200312 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100313}
314|
315PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
316{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300317 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600318 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200319
David Ahernc5cd8ac2013-07-02 13:27:25 -0600320 ALLOC_LIST(list);
321 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200322 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100323}
324|
325PE_NAME_CACHE_TYPE
326{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300327 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600328 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200329
David Ahernc5cd8ac2013-07-02 13:27:25 -0600330 ALLOC_LIST(list);
331 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, NULL, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200332 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100333}
334
335event_legacy_mem:
Jacob Shin3741eb92014-05-29 17:26:51 +0200336PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
337{
338 struct parse_events_evlist *data = _data;
339 struct list_head *list;
340
341 ALLOC_LIST(list);
342 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
343 (void *) $2, $6, $4));
344 $$ = list;
345}
346|
347PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
348{
349 struct parse_events_evlist *data = _data;
350 struct list_head *list;
351
352 ALLOC_LIST(list);
353 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
354 (void *) $2, NULL, $4));
355 $$ = list;
356}
357|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100358PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
359{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300360 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600361 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200362
David Ahernc5cd8ac2013-07-02 13:27:25 -0600363 ALLOC_LIST(list);
364 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
Jacob Shin3741eb92014-05-29 17:26:51 +0200365 (void *) $2, $4, 0));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200366 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100367}
368|
369PE_PREFIX_MEM PE_VALUE sep_dc
370{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300371 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600372 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200373
David Ahernc5cd8ac2013-07-02 13:27:25 -0600374 ALLOC_LIST(list);
375 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
Jacob Shin3741eb92014-05-29 17:26:51 +0200376 (void *) $2, NULL, 0));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200377 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100378}
379
380event_legacy_tracepoint:
He Kuang865582c2015-09-28 03:52:15 +0000381tracepoint_name
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200382{
383 struct parse_events_evlist *data = _data;
Jiri Olsa19658172015-09-07 10:38:07 +0200384 struct parse_events_error *error = data->error;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200385 struct list_head *list;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200386
387 ALLOC_LIST(list);
He Kuange637d172015-09-28 03:52:16 +0000388 if (error)
389 error->idx = @1.first_column;
390
He Kuang865582c2015-09-28 03:52:15 +0000391 if (parse_events_add_tracepoint(list, &data->idx, $1.sys, $1.event,
He Kuange637d172015-09-28 03:52:16 +0000392 error, NULL))
Jiri Olsa19658172015-09-07 10:38:07 +0200393 return -1;
He Kuange637d172015-09-28 03:52:16 +0000394
395 $$ = list;
396}
397|
398tracepoint_name '/' event_config '/'
399{
400 struct parse_events_evlist *data = _data;
401 struct parse_events_error *error = data->error;
402 struct list_head *list;
403
404 ALLOC_LIST(list);
405 if (error)
406 error->idx = @1.first_column;
407
408 if (parse_events_add_tracepoint(list, &data->idx, $1.sys, $1.event,
409 error, $3))
410 return -1;
411
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200412 $$ = list;
413}
He Kuang865582c2015-09-28 03:52:15 +0000414
415tracepoint_name:
416PE_NAME '-' PE_NAME ':' PE_NAME
417{
418 char sys_name[128];
419 struct tracepoint_name tracepoint;
420
421 snprintf(&sys_name, 128, "%s-%s", $1, $3);
422 tracepoint.sys = &sys_name;
423 tracepoint.event = $5;
424
425 $$ = tracepoint;
426}
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200427|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100428PE_NAME ':' PE_NAME
429{
He Kuang865582c2015-09-28 03:52:15 +0000430 struct tracepoint_name tracepoint = {$1, $3};
Jiri Olsab847cbd2012-05-21 09:12:51 +0200431
He Kuang865582c2015-09-28 03:52:15 +0000432 $$ = tracepoint;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100433}
434
435event_legacy_numeric:
436PE_VALUE ':' PE_VALUE
437{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300438 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600439 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200440
David Ahernc5cd8ac2013-07-02 13:27:25 -0600441 ALLOC_LIST(list);
Jiri Olsa87d650b2015-04-22 21:10:24 +0200442 ABORT_ON(parse_events_add_numeric(data, list, (u32)$1, $3, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200443 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100444}
445
446event_legacy_raw:
447PE_RAW
448{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300449 struct parse_events_evlist *data = _data;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600450 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200451
David Ahernc5cd8ac2013-07-02 13:27:25 -0600452 ALLOC_LIST(list);
Jiri Olsa87d650b2015-04-22 21:10:24 +0200453 ABORT_ON(parse_events_add_numeric(data, list, PERF_TYPE_RAW, $1, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200454 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100455}
456
Wang Nan84c86ca2015-10-14 12:41:14 +0000457event_bpf_file:
458PE_BPF_OBJECT
459{
460 struct parse_events_evlist *data = _data;
461 struct parse_events_error *error = data->error;
462 struct list_head *list;
463
464 ALLOC_LIST(list);
Wang Nand509db02015-10-14 12:41:20 +0000465 ABORT_ON(parse_events_load_bpf(data, list, $1, false));
466 $$ = list;
467}
468|
469PE_BPF_SOURCE
470{
471 struct parse_events_evlist *data = _data;
472 struct list_head *list;
473
474 ALLOC_LIST(list);
475 ABORT_ON(parse_events_load_bpf(data, list, $1, true));
Wang Nan84c86ca2015-10-14 12:41:14 +0000476 $$ = list;
477}
478
Jiri Olsa89efb022012-08-08 12:14:14 +0200479start_terms: event_config
Jiri Olsa90e2b222012-06-15 14:31:40 +0800480{
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -0300481 struct parse_events_terms *data = _data;
Jiri Olsa90e2b222012-06-15 14:31:40 +0800482 data->terms = $1;
483}
484
Jiri Olsa8f707d82012-03-15 20:09:16 +0100485event_config:
486event_config ',' event_term
487{
488 struct list_head *head = $1;
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300489 struct parse_events_term *term = $3;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100490
491 ABORT_ON(!head);
492 list_add_tail(&term->list, head);
493 $$ = $1;
494}
495|
496event_term
497{
498 struct list_head *head = malloc(sizeof(*head));
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300499 struct parse_events_term *term = $1;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100500
501 ABORT_ON(!head);
502 INIT_LIST_HEAD(head);
503 list_add_tail(&term->list, head);
504 $$ = head;
505}
506
507event_term:
508PE_NAME '=' PE_NAME
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__str(&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|
517PE_NAME '=' PE_VALUE
518{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300519 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100520
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300521 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200522 $1, $3, &@1, &@3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100523 $$ = term;
524}
525|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200526PE_NAME '=' PE_VALUE_SYM_HW
527{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300528 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200529 int config = $3 & 255;
530
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300531 ABORT_ON(parse_events_term__sym_hw(&term, $1, config));
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200532 $$ = term;
533}
534|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100535PE_NAME
536{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300537 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100538
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300539 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200540 $1, 1, &@1, NULL));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100541 $$ = term;
542}
543|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200544PE_VALUE_SYM_HW
545{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300546 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200547 int config = $1 & 255;
548
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300549 ABORT_ON(parse_events_term__sym_hw(&term, NULL, config));
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200550 $$ = term;
551}
552|
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200553PE_TERM '=' PE_NAME
554{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300555 struct parse_events_term *term;
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200556
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200557 ABORT_ON(parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3));
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200558 $$ = term;
559}
560|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100561PE_TERM '=' PE_VALUE
562{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300563 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100564
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200565 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, &@1, &@3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100566 $$ = term;
567}
568|
569PE_TERM
570{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300571 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100572
Jiri Olsacecf3a2e2015-04-22 21:10:20 +0200573 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, &@1, NULL));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100574 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100575}
576
577sep_dc: ':' |
578
Jiri Olsa8f707d82012-03-15 20:09:16 +0100579sep_slash_dc: '/' | ':' |
580
Jiri Olsa89812fc2012-03-15 20:09:15 +0100581%%
582
Jiri Olsa6297d422015-04-22 21:10:17 +0200583void parse_events_error(YYLTYPE *loc, void *data,
584 void *scanner __maybe_unused,
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300585 char const *msg __maybe_unused)
Jiri Olsa89812fc2012-03-15 20:09:15 +0100586{
Jiri Olsa6297d422015-04-22 21:10:17 +0200587 parse_events_evlist_error(data, loc->last_column, "parser error");
Jiri Olsa89812fc2012-03-15 20:09:15 +0100588}