Loading...
1%pure-parser
2%parse-param {void *_data}
3%parse-param {void *scanner}
4%lex-param {void* scanner}
5%locations
6
7%{
8
9#define YYDEBUG 1
10
11#include <linux/compiler.h>
12#include <linux/list.h>
13#include <linux/types.h>
14#include "util.h"
15#include "parse-events.h"
16#include "parse-events-bison.h"
17
18#define ABORT_ON(val) \
19do { \
20 if (val) \
21 YYABORT; \
22} while (0)
23
24#define ALLOC_LIST(list) \
25do { \
26 list = malloc(sizeof(*list)); \
27 ABORT_ON(!list); \
28 INIT_LIST_HEAD(list); \
29} while (0)
30
31static void 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
39%}
40
41%token PE_START_EVENTS PE_START_TERMS
42%token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM
43%token PE_EVENT_NAME
44%token PE_NAME
45%token PE_BPF_OBJECT PE_BPF_SOURCE
46%token PE_MODIFIER_EVENT PE_MODIFIER_BP
47%token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
48%token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP
49%token PE_ERROR
50%token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT
51%token PE_ARRAY_ALL PE_ARRAY_RANGE
52%type <num> PE_VALUE
53%type <num> PE_VALUE_SYM_HW
54%type <num> PE_VALUE_SYM_SW
55%type <num> PE_RAW
56%type <num> PE_TERM
57%type <str> PE_NAME
58%type <str> PE_BPF_OBJECT
59%type <str> PE_BPF_SOURCE
60%type <str> PE_NAME_CACHE_TYPE
61%type <str> PE_NAME_CACHE_OP_RESULT
62%type <str> PE_MODIFIER_EVENT
63%type <str> PE_MODIFIER_BP
64%type <str> PE_EVENT_NAME
65%type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT
66%type <num> value_sym
67%type <head> event_config
68%type <head> opt_event_config
69%type <term> event_term
70%type <head> event_pmu
71%type <head> event_legacy_symbol
72%type <head> event_legacy_cache
73%type <head> event_legacy_mem
74%type <head> event_legacy_tracepoint
75%type <tracepoint_name> tracepoint_name
76%type <head> event_legacy_numeric
77%type <head> event_legacy_raw
78%type <head> event_bpf_file
79%type <head> event_def
80%type <head> event_mod
81%type <head> event_name
82%type <head> event
83%type <head> events
84%type <head> group_def
85%type <head> group
86%type <head> groups
87%type <array> array
88%type <array> array_term
89%type <array> array_terms
90
91%union
92{
93 char *str;
94 u64 num;
95 struct list_head *head;
96 struct parse_events_term *term;
97 struct tracepoint_name {
98 char *sys;
99 char *event;
100 } tracepoint_name;
101 struct parse_events_array array;
102}
103%%
104
105start:
106PE_START_EVENTS start_events
107|
108PE_START_TERMS start_terms
109
110start_events: groups
111{
112 struct parse_events_evlist *data = _data;
113
114 parse_events_update_lists($1, &data->list);
115}
116
117groups:
118groups ',' group
119{
120 struct list_head *list = $1;
121 struct list_head *group = $3;
122
123 parse_events_update_lists(group, list);
124 $$ = list;
125}
126|
127groups ',' event
128{
129 struct list_head *list = $1;
130 struct list_head *event = $3;
131
132 parse_events_update_lists(event, list);
133 $$ = list;
134}
135|
136group
137|
138event
139
140group:
141group_def ':' PE_MODIFIER_EVENT
142{
143 struct list_head *list = $1;
144
145 ABORT_ON(parse_events__modifier_group(list, $3));
146 $$ = list;
147}
148|
149group_def
150
151group_def:
152PE_NAME '{' events '}'
153{
154 struct list_head *list = $3;
155
156 inc_group_count(list, _data);
157 parse_events__set_leader($1, list);
158 $$ = list;
159}
160|
161'{' events '}'
162{
163 struct list_head *list = $2;
164
165 inc_group_count(list, _data);
166 parse_events__set_leader(NULL, list);
167 $$ = list;
168}
169
170events:
171events ',' event
172{
173 struct list_head *event = $3;
174 struct list_head *list = $1;
175
176 parse_events_update_lists(event, list);
177 $$ = list;
178}
179|
180event
181
182event: event_mod
183
184event_mod:
185event_name PE_MODIFIER_EVENT
186{
187 struct list_head *list = $1;
188
189 /*
190 * Apply modifier on all events added by single event definition
191 * (there could be more events added for multiple tracepoint
192 * definitions via '*?'.
193 */
194 ABORT_ON(parse_events__modifier_event(list, $2, false));
195 $$ = list;
196}
197|
198event_name
199
200event_name:
201PE_EVENT_NAME event_def
202{
203 ABORT_ON(parse_events_name($2, $1));
204 free($1);
205 $$ = $2;
206}
207|
208event_def
209
210event_def: event_pmu |
211 event_legacy_symbol |
212 event_legacy_cache sep_dc |
213 event_legacy_mem |
214 event_legacy_tracepoint sep_dc |
215 event_legacy_numeric sep_dc |
216 event_legacy_raw sep_dc |
217 event_bpf_file
218
219event_pmu:
220PE_NAME opt_event_config
221{
222 struct parse_events_evlist *data = _data;
223 struct list_head *list;
224
225 ALLOC_LIST(list);
226 ABORT_ON(parse_events_add_pmu(data, list, $1, $2));
227 parse_events_terms__delete($2);
228 $$ = list;
229}
230|
231PE_KERNEL_PMU_EVENT sep_dc
232{
233 struct parse_events_evlist *data = _data;
234 struct list_head *head;
235 struct parse_events_term *term;
236 struct list_head *list;
237
238 ALLOC_LIST(head);
239 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
240 $1, 1, &@1, NULL));
241 list_add_tail(&term->list, head);
242
243 ALLOC_LIST(list);
244 ABORT_ON(parse_events_add_pmu(data, list, "cpu", head));
245 parse_events_terms__delete(head);
246 $$ = list;
247}
248|
249PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
250{
251 struct parse_events_evlist *data = _data;
252 struct list_head *head;
253 struct parse_events_term *term;
254 struct list_head *list;
255 char pmu_name[128];
256 snprintf(&pmu_name, 128, "%s-%s", $1, $3);
257
258 ALLOC_LIST(head);
259 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
260 &pmu_name, 1, &@1, NULL));
261 list_add_tail(&term->list, head);
262
263 ALLOC_LIST(list);
264 ABORT_ON(parse_events_add_pmu(data, list, "cpu", head));
265 parse_events_terms__delete(head);
266 $$ = list;
267}
268
269value_sym:
270PE_VALUE_SYM_HW
271|
272PE_VALUE_SYM_SW
273
274event_legacy_symbol:
275value_sym '/' event_config '/'
276{
277 struct parse_events_evlist *data = _data;
278 struct list_head *list;
279 int type = $1 >> 16;
280 int config = $1 & 255;
281
282 ALLOC_LIST(list);
283 ABORT_ON(parse_events_add_numeric(data, list, type, config, $3));
284 parse_events_terms__delete($3);
285 $$ = list;
286}
287|
288value_sym sep_slash_dc
289{
290 struct parse_events_evlist *data = _data;
291 struct list_head *list;
292 int type = $1 >> 16;
293 int config = $1 & 255;
294
295 ALLOC_LIST(list);
296 ABORT_ON(parse_events_add_numeric(data, list, type, config, NULL));
297 $$ = list;
298}
299
300event_legacy_cache:
301PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config
302{
303 struct parse_events_evlist *data = _data;
304 struct parse_events_error *error = data->error;
305 struct list_head *list;
306
307 ALLOC_LIST(list);
308 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, $5, error, $6));
309 parse_events_terms__delete($6);
310 $$ = list;
311}
312|
313PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config
314{
315 struct parse_events_evlist *data = _data;
316 struct parse_events_error *error = data->error;
317 struct list_head *list;
318
319 ALLOC_LIST(list);
320 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, NULL, error, $4));
321 parse_events_terms__delete($4);
322 $$ = list;
323}
324|
325PE_NAME_CACHE_TYPE opt_event_config
326{
327 struct parse_events_evlist *data = _data;
328 struct parse_events_error *error = data->error;
329 struct list_head *list;
330
331 ALLOC_LIST(list);
332 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, NULL, NULL, error, $2));
333 parse_events_terms__delete($2);
334 $$ = list;
335}
336
337event_legacy_mem:
338PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP 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, $6, $4));
346 $$ = list;
347}
348|
349PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
350{
351 struct parse_events_evlist *data = _data;
352 struct list_head *list;
353
354 ALLOC_LIST(list);
355 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
356 (void *) $2, NULL, $4));
357 $$ = list;
358}
359|
360PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
361{
362 struct parse_events_evlist *data = _data;
363 struct list_head *list;
364
365 ALLOC_LIST(list);
366 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
367 (void *) $2, $4, 0));
368 $$ = list;
369}
370|
371PE_PREFIX_MEM PE_VALUE sep_dc
372{
373 struct parse_events_evlist *data = _data;
374 struct list_head *list;
375
376 ALLOC_LIST(list);
377 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
378 (void *) $2, NULL, 0));
379 $$ = list;
380}
381
382event_legacy_tracepoint:
383tracepoint_name opt_event_config
384{
385 struct parse_events_evlist *data = _data;
386 struct parse_events_error *error = data->error;
387 struct list_head *list;
388
389 ALLOC_LIST(list);
390 if (error)
391 error->idx = @1.first_column;
392
393 if (parse_events_add_tracepoint(list, &data->idx, $1.sys, $1.event,
394 error, $2))
395 return -1;
396
397 $$ = list;
398}
399
400tracepoint_name:
401PE_NAME '-' PE_NAME ':' PE_NAME
402{
403 char sys_name[128];
404 struct tracepoint_name tracepoint;
405
406 snprintf(&sys_name, 128, "%s-%s", $1, $3);
407 tracepoint.sys = &sys_name;
408 tracepoint.event = $5;
409
410 $$ = tracepoint;
411}
412|
413PE_NAME ':' PE_NAME
414{
415 struct tracepoint_name tracepoint = {$1, $3};
416
417 $$ = tracepoint;
418}
419
420event_legacy_numeric:
421PE_VALUE ':' PE_VALUE opt_event_config
422{
423 struct parse_events_evlist *data = _data;
424 struct list_head *list;
425
426 ALLOC_LIST(list);
427 ABORT_ON(parse_events_add_numeric(data, list, (u32)$1, $3, $4));
428 parse_events_terms__delete($4);
429 $$ = list;
430}
431
432event_legacy_raw:
433PE_RAW opt_event_config
434{
435 struct parse_events_evlist *data = _data;
436 struct list_head *list;
437
438 ALLOC_LIST(list);
439 ABORT_ON(parse_events_add_numeric(data, list, PERF_TYPE_RAW, $1, $2));
440 parse_events_terms__delete($2);
441 $$ = list;
442}
443
444event_bpf_file:
445PE_BPF_OBJECT opt_event_config
446{
447 struct parse_events_evlist *data = _data;
448 struct parse_events_error *error = data->error;
449 struct list_head *list;
450
451 ALLOC_LIST(list);
452 ABORT_ON(parse_events_load_bpf(data, list, $1, false, $2));
453 parse_events_terms__delete($2);
454 $$ = list;
455}
456|
457PE_BPF_SOURCE opt_event_config
458{
459 struct parse_events_evlist *data = _data;
460 struct list_head *list;
461
462 ALLOC_LIST(list);
463 ABORT_ON(parse_events_load_bpf(data, list, $1, true, $2));
464 parse_events_terms__delete($2);
465 $$ = list;
466}
467
468opt_event_config:
469'/' event_config '/'
470{
471 $$ = $2;
472}
473|
474'/' '/'
475{
476 $$ = NULL;
477}
478|
479{
480 $$ = NULL;
481}
482
483start_terms: event_config
484{
485 struct parse_events_terms *data = _data;
486 data->terms = $1;
487}
488
489event_config:
490event_config ',' event_term
491{
492 struct list_head *head = $1;
493 struct parse_events_term *term = $3;
494
495 ABORT_ON(!head);
496 list_add_tail(&term->list, head);
497 $$ = $1;
498}
499|
500event_term
501{
502 struct list_head *head = malloc(sizeof(*head));
503 struct parse_events_term *term = $1;
504
505 ABORT_ON(!head);
506 INIT_LIST_HEAD(head);
507 list_add_tail(&term->list, head);
508 $$ = head;
509}
510
511event_term:
512PE_NAME '=' PE_NAME
513{
514 struct parse_events_term *term;
515
516 ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
517 $1, $3, &@1, &@3));
518 $$ = term;
519}
520|
521PE_NAME '=' PE_VALUE
522{
523 struct parse_events_term *term;
524
525 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
526 $1, $3, &@1, &@3));
527 $$ = term;
528}
529|
530PE_NAME '=' PE_VALUE_SYM_HW
531{
532 struct parse_events_term *term;
533 int config = $3 & 255;
534
535 ABORT_ON(parse_events_term__sym_hw(&term, $1, config));
536 $$ = term;
537}
538|
539PE_NAME
540{
541 struct parse_events_term *term;
542
543 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
544 $1, 1, &@1, NULL));
545 $$ = term;
546}
547|
548PE_VALUE_SYM_HW
549{
550 struct parse_events_term *term;
551 int config = $1 & 255;
552
553 ABORT_ON(parse_events_term__sym_hw(&term, NULL, config));
554 $$ = term;
555}
556|
557PE_TERM '=' PE_NAME
558{
559 struct parse_events_term *term;
560
561 ABORT_ON(parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3));
562 $$ = term;
563}
564|
565PE_TERM '=' PE_VALUE
566{
567 struct parse_events_term *term;
568
569 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, &@1, &@3));
570 $$ = term;
571}
572|
573PE_TERM
574{
575 struct parse_events_term *term;
576
577 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, &@1, NULL));
578 $$ = term;
579}
580|
581PE_NAME array '=' PE_NAME
582{
583 struct parse_events_term *term;
584 int i;
585
586 ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
587 $1, $4, &@1, &@4));
588
589 term->array = $2;
590 $$ = term;
591}
592|
593PE_NAME array '=' PE_VALUE
594{
595 struct parse_events_term *term;
596
597 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
598 $1, $4, &@1, &@4));
599 term->array = $2;
600 $$ = term;
601}
602
603array:
604'[' array_terms ']'
605{
606 $$ = $2;
607}
608|
609PE_ARRAY_ALL
610{
611 $$.nr_ranges = 0;
612 $$.ranges = NULL;
613}
614
615array_terms:
616array_terms ',' array_term
617{
618 struct parse_events_array new_array;
619
620 new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges;
621 new_array.ranges = malloc(sizeof(new_array.ranges[0]) *
622 new_array.nr_ranges);
623 ABORT_ON(!new_array.ranges);
624 memcpy(&new_array.ranges[0], $1.ranges,
625 $1.nr_ranges * sizeof(new_array.ranges[0]));
626 memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges,
627 $3.nr_ranges * sizeof(new_array.ranges[0]));
628 free($1.ranges);
629 free($3.ranges);
630 $$ = new_array;
631}
632|
633array_term
634
635array_term:
636PE_VALUE
637{
638 struct parse_events_array array;
639
640 array.nr_ranges = 1;
641 array.ranges = malloc(sizeof(array.ranges[0]));
642 ABORT_ON(!array.ranges);
643 array.ranges[0].start = $1;
644 array.ranges[0].length = 1;
645 $$ = array;
646}
647|
648PE_VALUE PE_ARRAY_RANGE PE_VALUE
649{
650 struct parse_events_array array;
651
652 ABORT_ON($3 < $1);
653 array.nr_ranges = 1;
654 array.ranges = malloc(sizeof(array.ranges[0]));
655 ABORT_ON(!array.ranges);
656 array.ranges[0].start = $1;
657 array.ranges[0].length = $3 - $1 + 1;
658 $$ = array;
659}
660
661sep_dc: ':' |
662
663sep_slash_dc: '/' | ':' |
664
665%%
666
667void parse_events_error(YYLTYPE *loc, void *data,
668 void *scanner __maybe_unused,
669 char const *msg __maybe_unused)
670{
671 parse_events_evlist_error(data, loc->last_column, "parser error");
672}
1%pure-parser
2%parse-param {void *_data}
3%parse-param {void *scanner}
4%lex-param {void* scanner}
5
6%{
7
8#define YYDEBUG 1
9
10#include <linux/compiler.h>
11#include <linux/list.h>
12#include "types.h"
13#include "util.h"
14#include "parse-events.h"
15#include "parse-events-bison.h"
16
17extern int parse_events_lex (YYSTYPE* lvalp, void* scanner);
18
19#define ABORT_ON(val) \
20do { \
21 if (val) \
22 YYABORT; \
23} while (0)
24
25#define ALLOC_LIST(list) \
26do { \
27 list = malloc(sizeof(*list)); \
28 ABORT_ON(!list); \
29 INIT_LIST_HEAD(list); \
30} while (0)
31
32static inc_group_count(struct list_head *list,
33 struct parse_events_evlist *data)
34{
35 /* Count groups only have more than 1 members */
36 if (!list_is_last(list->next, list))
37 data->nr_groups++;
38}
39
40%}
41
42%token PE_START_EVENTS PE_START_TERMS
43%token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM
44%token PE_EVENT_NAME
45%token PE_NAME
46%token PE_MODIFIER_EVENT PE_MODIFIER_BP
47%token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
48%token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP
49%token PE_ERROR
50%type <num> PE_VALUE
51%type <num> PE_VALUE_SYM_HW
52%type <num> PE_VALUE_SYM_SW
53%type <num> PE_RAW
54%type <num> PE_TERM
55%type <str> PE_NAME
56%type <str> PE_NAME_CACHE_TYPE
57%type <str> PE_NAME_CACHE_OP_RESULT
58%type <str> PE_MODIFIER_EVENT
59%type <str> PE_MODIFIER_BP
60%type <str> PE_EVENT_NAME
61%type <num> value_sym
62%type <head> event_config
63%type <term> event_term
64%type <head> event_pmu
65%type <head> event_legacy_symbol
66%type <head> event_legacy_cache
67%type <head> event_legacy_mem
68%type <head> event_legacy_tracepoint
69%type <head> event_legacy_numeric
70%type <head> event_legacy_raw
71%type <head> event_def
72%type <head> event_mod
73%type <head> event_name
74%type <head> event
75%type <head> events
76%type <head> group_def
77%type <head> group
78%type <head> groups
79
80%union
81{
82 char *str;
83 u64 num;
84 struct list_head *head;
85 struct parse_events_term *term;
86}
87%%
88
89start:
90PE_START_EVENTS start_events
91|
92PE_START_TERMS start_terms
93
94start_events: groups
95{
96 struct parse_events_evlist *data = _data;
97
98 parse_events_update_lists($1, &data->list);
99}
100
101groups:
102groups ',' group
103{
104 struct list_head *list = $1;
105 struct list_head *group = $3;
106
107 parse_events_update_lists(group, list);
108 $$ = list;
109}
110|
111groups ',' event
112{
113 struct list_head *list = $1;
114 struct list_head *event = $3;
115
116 parse_events_update_lists(event, list);
117 $$ = list;
118}
119|
120group
121|
122event
123
124group:
125group_def ':' PE_MODIFIER_EVENT
126{
127 struct list_head *list = $1;
128
129 ABORT_ON(parse_events__modifier_group(list, $3));
130 $$ = list;
131}
132|
133group_def
134
135group_def:
136PE_NAME '{' events '}'
137{
138 struct list_head *list = $3;
139
140 inc_group_count(list, _data);
141 parse_events__set_leader($1, list);
142 $$ = list;
143}
144|
145'{' events '}'
146{
147 struct list_head *list = $2;
148
149 inc_group_count(list, _data);
150 parse_events__set_leader(NULL, list);
151 $$ = list;
152}
153
154events:
155events ',' event
156{
157 struct list_head *event = $3;
158 struct list_head *list = $1;
159
160 parse_events_update_lists(event, list);
161 $$ = list;
162}
163|
164event
165
166event: event_mod
167
168event_mod:
169event_name PE_MODIFIER_EVENT
170{
171 struct list_head *list = $1;
172
173 /*
174 * Apply modifier on all events added by single event definition
175 * (there could be more events added for multiple tracepoint
176 * definitions via '*?'.
177 */
178 ABORT_ON(parse_events__modifier_event(list, $2, false));
179 $$ = list;
180}
181|
182event_name
183
184event_name:
185PE_EVENT_NAME event_def
186{
187 ABORT_ON(parse_events_name($2, $1));
188 free($1);
189 $$ = $2;
190}
191|
192event_def
193
194event_def: event_pmu |
195 event_legacy_symbol |
196 event_legacy_cache sep_dc |
197 event_legacy_mem |
198 event_legacy_tracepoint sep_dc |
199 event_legacy_numeric sep_dc |
200 event_legacy_raw sep_dc
201
202event_pmu:
203PE_NAME '/' event_config '/'
204{
205 struct parse_events_evlist *data = _data;
206 struct list_head *list;
207
208 ALLOC_LIST(list);
209 ABORT_ON(parse_events_add_pmu(list, &data->idx, $1, $3));
210 parse_events__free_terms($3);
211 $$ = list;
212}
213
214value_sym:
215PE_VALUE_SYM_HW
216|
217PE_VALUE_SYM_SW
218
219event_legacy_symbol:
220value_sym '/' event_config '/'
221{
222 struct parse_events_evlist *data = _data;
223 struct list_head *list;
224 int type = $1 >> 16;
225 int config = $1 & 255;
226
227 ALLOC_LIST(list);
228 ABORT_ON(parse_events_add_numeric(list, &data->idx,
229 type, config, $3));
230 parse_events__free_terms($3);
231 $$ = list;
232}
233|
234value_sym sep_slash_dc
235{
236 struct parse_events_evlist *data = _data;
237 struct list_head *list;
238 int type = $1 >> 16;
239 int config = $1 & 255;
240
241 ALLOC_LIST(list);
242 ABORT_ON(parse_events_add_numeric(list, &data->idx,
243 type, config, NULL));
244 $$ = list;
245}
246
247event_legacy_cache:
248PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
249{
250 struct parse_events_evlist *data = _data;
251 struct list_head *list;
252
253 ALLOC_LIST(list);
254 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, $5));
255 $$ = list;
256}
257|
258PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
259{
260 struct parse_events_evlist *data = _data;
261 struct list_head *list;
262
263 ALLOC_LIST(list);
264 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, NULL));
265 $$ = list;
266}
267|
268PE_NAME_CACHE_TYPE
269{
270 struct parse_events_evlist *data = _data;
271 struct list_head *list;
272
273 ALLOC_LIST(list);
274 ABORT_ON(parse_events_add_cache(list, &data->idx, $1, NULL, NULL));
275 $$ = list;
276}
277
278event_legacy_mem:
279PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
280{
281 struct parse_events_evlist *data = _data;
282 struct list_head *list;
283
284 ALLOC_LIST(list);
285 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
286 (void *) $2, $4));
287 $$ = list;
288}
289|
290PE_PREFIX_MEM PE_VALUE sep_dc
291{
292 struct parse_events_evlist *data = _data;
293 struct list_head *list;
294
295 ALLOC_LIST(list);
296 ABORT_ON(parse_events_add_breakpoint(list, &data->idx,
297 (void *) $2, NULL));
298 $$ = list;
299}
300
301event_legacy_tracepoint:
302PE_NAME ':' PE_NAME
303{
304 struct parse_events_evlist *data = _data;
305 struct list_head *list;
306
307 ALLOC_LIST(list);
308 ABORT_ON(parse_events_add_tracepoint(list, &data->idx, $1, $3));
309 $$ = list;
310}
311
312event_legacy_numeric:
313PE_VALUE ':' PE_VALUE
314{
315 struct parse_events_evlist *data = _data;
316 struct list_head *list;
317
318 ALLOC_LIST(list);
319 ABORT_ON(parse_events_add_numeric(list, &data->idx, (u32)$1, $3, NULL));
320 $$ = list;
321}
322
323event_legacy_raw:
324PE_RAW
325{
326 struct parse_events_evlist *data = _data;
327 struct list_head *list;
328
329 ALLOC_LIST(list);
330 ABORT_ON(parse_events_add_numeric(list, &data->idx,
331 PERF_TYPE_RAW, $1, NULL));
332 $$ = list;
333}
334
335start_terms: event_config
336{
337 struct parse_events_terms *data = _data;
338 data->terms = $1;
339}
340
341event_config:
342event_config ',' event_term
343{
344 struct list_head *head = $1;
345 struct parse_events_term *term = $3;
346
347 ABORT_ON(!head);
348 list_add_tail(&term->list, head);
349 $$ = $1;
350}
351|
352event_term
353{
354 struct list_head *head = malloc(sizeof(*head));
355 struct parse_events_term *term = $1;
356
357 ABORT_ON(!head);
358 INIT_LIST_HEAD(head);
359 list_add_tail(&term->list, head);
360 $$ = head;
361}
362
363event_term:
364PE_NAME '=' PE_NAME
365{
366 struct parse_events_term *term;
367
368 ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
369 $1, $3));
370 $$ = term;
371}
372|
373PE_NAME '=' PE_VALUE
374{
375 struct parse_events_term *term;
376
377 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
378 $1, $3));
379 $$ = term;
380}
381|
382PE_NAME '=' PE_VALUE_SYM_HW
383{
384 struct parse_events_term *term;
385 int config = $3 & 255;
386
387 ABORT_ON(parse_events_term__sym_hw(&term, $1, config));
388 $$ = term;
389}
390|
391PE_NAME
392{
393 struct parse_events_term *term;
394
395 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
396 $1, 1));
397 $$ = term;
398}
399|
400PE_VALUE_SYM_HW
401{
402 struct parse_events_term *term;
403 int config = $1 & 255;
404
405 ABORT_ON(parse_events_term__sym_hw(&term, NULL, config));
406 $$ = term;
407}
408|
409PE_TERM '=' PE_NAME
410{
411 struct parse_events_term *term;
412
413 ABORT_ON(parse_events_term__str(&term, (int)$1, NULL, $3));
414 $$ = term;
415}
416|
417PE_TERM '=' PE_VALUE
418{
419 struct parse_events_term *term;
420
421 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3));
422 $$ = term;
423}
424|
425PE_TERM
426{
427 struct parse_events_term *term;
428
429 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1));
430 $$ = term;
431}
432
433sep_dc: ':' |
434
435sep_slash_dc: '/' | ':' |
436
437%%
438
439void parse_events_error(void *data __maybe_unused, void *scanner __maybe_unused,
440 char const *msg __maybe_unused)
441{
442}