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