blob: d5b6aff82f21704d06c71def88677a27faa0dff3 [file] [log] [blame]
Jiri Olsafc8c0a92020-01-12 20:22:59 +01001%define api.pure full
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -03002%parse-param {void *_parse_state}
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
Agustin Vega-Friasb2b9d3a2018-03-06 09:04:42 -050011#include <fnmatch.h>
Arnaldo Carvalho de Melobd704622019-09-24 15:45:21 -030012#include <stdio.h>
Jiri Olsa89812fc2012-03-15 20:09:15 +010013#include <linux/compiler.h>
Borislav Petkovd944c4e2014-04-25 21:31:02 +020014#include <linux/types.h>
Ian Rogersf2a8ecd2019-10-30 15:34:44 -070015#include <linux/zalloc.h>
Andi Kleen231bb2a2017-01-27 18:03:39 -080016#include "pmu.h"
Andi Kleenf0fbb112019-03-26 15:18:21 -070017#include "evsel.h"
Jiri Olsa89812fc2012-03-15 20:09:15 +010018#include "parse-events.h"
Zheng Yanac20de6f2012-06-15 14:31:39 +080019#include "parse-events-bison.h"
Jiri Olsa89812fc2012-03-15 20:09:15 +010020
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -030021void parse_events_error(YYLTYPE *loc, void *parse_state, void *scanner, char const *msg);
Arnaldo Carvalho de Melo34a05482017-02-15 10:09:11 -030022
Jiri Olsa89812fc2012-03-15 20:09:15 +010023#define ABORT_ON(val) \
24do { \
25 if (val) \
26 YYABORT; \
27} while (0)
28
Ian Rogersffaecd72020-06-08 22:36:10 -070029static struct list_head* alloc_list(void)
Ian Rogersa26e4712019-10-22 17:53:32 -070030{
31 struct list_head *list;
32
33 list = malloc(sizeof(*list));
34 if (!list)
35 return NULL;
36
37 INIT_LIST_HEAD(list);
38 return list;
39}
David Ahernc5cd8ac2013-07-02 13:27:25 -060040
Ian Rogersf2a8ecd2019-10-30 15:34:44 -070041static void free_list_evsel(struct list_head* list_evsel)
42{
43 struct evsel *evsel, *tmp;
44
45 list_for_each_entry_safe(evsel, tmp, list_evsel, core.node) {
46 list_del_init(&evsel->core.node);
Ian Rogers672f7072020-03-18 19:31:00 -070047 evsel__delete(evsel);
Ian Rogersf2a8ecd2019-10-30 15:34:44 -070048 }
49 free(list_evsel);
50}
51
Colin Ian King07ef7572016-03-07 16:44:37 -030052static void inc_group_count(struct list_head *list,
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -030053 struct parse_events_state *parse_state)
Namhyung Kim97f63e42013-01-22 18:09:29 +090054{
55 /* Count groups only have more than 1 members */
56 if (!list_is_last(list->next, list))
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -030057 parse_state->nr_groups++;
Namhyung Kim97f63e42013-01-22 18:09:29 +090058}
59
Jiri Olsa89812fc2012-03-15 20:09:15 +010060%}
61
Jiri Olsa90e2b222012-06-15 14:31:40 +080062%token PE_START_EVENTS PE_START_TERMS
Jiri Olsacf3506d2012-07-04 00:00:43 +020063%token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM
Andi Kleenf0fbb112019-03-26 15:18:21 -070064%token PE_VALUE_SYM_TOOL
Robert Richterac2ba9f2012-08-16 21:10:21 +020065%token PE_EVENT_NAME
Jiri Olsa89812fc2012-03-15 20:09:15 +010066%token PE_NAME
Wang Nand509db02015-10-14 12:41:20 +000067%token PE_BPF_OBJECT PE_BPF_SOURCE
Jiri Olsa89812fc2012-03-15 20:09:15 +010068%token PE_MODIFIER_EVENT PE_MODIFIER_BP
69%token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
Jiri Olsa89efb022012-08-08 12:14:14 +020070%token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP
Jiri Olsa89812fc2012-03-15 20:09:15 +010071%token PE_ERROR
Jiri Olsa387ad332020-06-02 23:47:29 +020072%token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE
Wang Nane571e022016-02-22 09:10:35 +000073%token PE_ARRAY_ALL PE_ARRAY_RANGE
Mathieu Poirierdd60fba2016-09-06 10:37:15 -060074%token PE_DRV_CFG_TERM
Jiri Olsa89812fc2012-03-15 20:09:15 +010075%type <num> PE_VALUE
Jiri Olsacf3506d2012-07-04 00:00:43 +020076%type <num> PE_VALUE_SYM_HW
77%type <num> PE_VALUE_SYM_SW
Andi Kleenf0fbb112019-03-26 15:18:21 -070078%type <num> PE_VALUE_SYM_TOOL
Jiri Olsa89812fc2012-03-15 20:09:15 +010079%type <num> PE_RAW
Jiri Olsa8f707d82012-03-15 20:09:16 +010080%type <num> PE_TERM
Ian Rogersf2a8ecd2019-10-30 15:34:44 -070081%type <num> value_sym
Jiri Olsa89812fc2012-03-15 20:09:15 +010082%type <str> PE_NAME
Wang Nan84c86ca2015-10-14 12:41:14 +000083%type <str> PE_BPF_OBJECT
Wang Nand509db02015-10-14 12:41:20 +000084%type <str> PE_BPF_SOURCE
Jiri Olsa89812fc2012-03-15 20:09:15 +010085%type <str> PE_NAME_CACHE_TYPE
86%type <str> PE_NAME_CACHE_OP_RESULT
87%type <str> PE_MODIFIER_EVENT
88%type <str> PE_MODIFIER_BP
Robert Richterac2ba9f2012-08-16 21:10:21 +020089%type <str> PE_EVENT_NAME
Jiri Olsa387ad332020-06-02 23:47:29 +020090%type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE
Mathieu Poirierdd60fba2016-09-06 10:37:15 -060091%type <str> PE_DRV_CFG_TERM
Ian Rogersf2a8ecd2019-10-30 15:34:44 -070092%destructor { free ($$); } <str>
Jiri Olsa8f707d82012-03-15 20:09:16 +010093%type <term> event_term
Ian Rogers1dc92552019-10-30 15:34:47 -070094%destructor { parse_events_term__delete ($$); } <term>
Ian Rogersf2a8ecd2019-10-30 15:34:44 -070095%type <list_terms> event_config
96%type <list_terms> opt_event_config
97%type <list_terms> opt_pmu_config
98%destructor { parse_events_terms__delete ($$); } <list_terms>
99%type <list_evsel> event_pmu
100%type <list_evsel> event_legacy_symbol
101%type <list_evsel> event_legacy_cache
102%type <list_evsel> event_legacy_mem
103%type <list_evsel> event_legacy_tracepoint
104%type <list_evsel> event_legacy_numeric
105%type <list_evsel> event_legacy_raw
106%type <list_evsel> event_bpf_file
107%type <list_evsel> event_def
108%type <list_evsel> event_mod
109%type <list_evsel> event_name
110%type <list_evsel> event
111%type <list_evsel> events
112%type <list_evsel> group_def
113%type <list_evsel> group
114%type <list_evsel> groups
115%destructor { free_list_evsel ($$); } <list_evsel>
He Kuang865582c2015-09-28 03:52:15 +0000116%type <tracepoint_name> tracepoint_name
Ian Rogersf2a8ecd2019-10-30 15:34:44 -0700117%destructor { free ($$.sys); free ($$.event); } <tracepoint_name>
Wang Nane571e022016-02-22 09:10:35 +0000118%type <array> array
119%type <array> array_term
120%type <array> array_terms
Ian Rogersf2a8ecd2019-10-30 15:34:44 -0700121%destructor { free ($$.ranges); } <array>
Jiri Olsa89812fc2012-03-15 20:09:15 +0100122
123%union
124{
125 char *str;
Robert Richterb527bab2012-08-07 19:43:13 +0200126 u64 num;
Ian Rogersf2a8ecd2019-10-30 15:34:44 -0700127 struct list_head *list_evsel;
128 struct list_head *list_terms;
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300129 struct parse_events_term *term;
He Kuang865582c2015-09-28 03:52:15 +0000130 struct tracepoint_name {
131 char *sys;
132 char *event;
133 } tracepoint_name;
Wang Nane571e022016-02-22 09:10:35 +0000134 struct parse_events_array array;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100135}
136%%
137
Jiri Olsa90e2b222012-06-15 14:31:40 +0800138start:
Jiri Olsa89efb022012-08-08 12:14:14 +0200139PE_START_EVENTS start_events
Jiri Olsa90e2b222012-06-15 14:31:40 +0800140|
Jiri Olsa89efb022012-08-08 12:14:14 +0200141PE_START_TERMS start_terms
142
143start_events: groups
144{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300145 struct parse_events_state *parse_state = _parse_state;
Jiri Olsa89efb022012-08-08 12:14:14 +0200146
Ian Rogerscabbf262019-10-30 15:34:45 -0700147 /* frees $1 */
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300148 parse_events_update_lists($1, &parse_state->list);
Jiri Olsa89efb022012-08-08 12:14:14 +0200149}
150
151groups:
152groups ',' group
153{
154 struct list_head *list = $1;
155 struct list_head *group = $3;
156
Ian Rogerscabbf262019-10-30 15:34:45 -0700157 /* frees $3 */
Jiri Olsa89efb022012-08-08 12:14:14 +0200158 parse_events_update_lists(group, list);
159 $$ = list;
160}
161|
162groups ',' event
163{
164 struct list_head *list = $1;
165 struct list_head *event = $3;
166
Ian Rogerscabbf262019-10-30 15:34:45 -0700167 /* frees $3 */
Jiri Olsa89efb022012-08-08 12:14:14 +0200168 parse_events_update_lists(event, list);
169 $$ = list;
170}
171|
172group
173|
174event
175
176group:
177group_def ':' PE_MODIFIER_EVENT
178{
179 struct list_head *list = $1;
Ian Rogerscabbf262019-10-30 15:34:45 -0700180 int err;
Jiri Olsa89efb022012-08-08 12:14:14 +0200181
Ian Rogerscabbf262019-10-30 15:34:45 -0700182 err = parse_events__modifier_group(list, $3);
183 free($3);
184 if (err) {
185 free_list_evsel(list);
186 YYABORT;
187 }
Jiri Olsa89efb022012-08-08 12:14:14 +0200188 $$ = list;
189}
190|
191group_def
192
193group_def:
194PE_NAME '{' events '}'
195{
196 struct list_head *list = $3;
197
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300198 inc_group_count(list, _parse_state);
Kan Liang3cdc5c22018-05-07 14:13:43 -0700199 parse_events__set_leader($1, list, _parse_state);
Ian Rogerscabbf262019-10-30 15:34:45 -0700200 free($1);
Jiri Olsa89efb022012-08-08 12:14:14 +0200201 $$ = list;
202}
203|
204'{' events '}'
205{
206 struct list_head *list = $2;
207
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300208 inc_group_count(list, _parse_state);
Kan Liang3cdc5c22018-05-07 14:13:43 -0700209 parse_events__set_leader(NULL, list, _parse_state);
Jiri Olsa89efb022012-08-08 12:14:14 +0200210 $$ = list;
211}
Jiri Olsa90e2b222012-06-15 14:31:40 +0800212
Jiri Olsa89812fc2012-03-15 20:09:15 +0100213events:
Jiri Olsa89efb022012-08-08 12:14:14 +0200214events ',' event
215{
216 struct list_head *event = $3;
217 struct list_head *list = $1;
218
Ian Rogerscabbf262019-10-30 15:34:45 -0700219 /* frees $3 */
Jiri Olsa89efb022012-08-08 12:14:14 +0200220 parse_events_update_lists(event, list);
221 $$ = list;
222}
223|
224event
Jiri Olsa89812fc2012-03-15 20:09:15 +0100225
Robert Richterac2ba9f2012-08-16 21:10:21 +0200226event: event_mod
227
228event_mod:
229event_name PE_MODIFIER_EVENT
Jiri Olsa89812fc2012-03-15 20:09:15 +0100230{
Jiri Olsa89efb022012-08-08 12:14:14 +0200231 struct list_head *list = $1;
Ian Rogerscabbf262019-10-30 15:34:45 -0700232 int err;
Jiri Olsa46010ab2012-06-15 14:31:38 +0800233
Jiri Olsa5d7be902012-03-20 19:15:40 +0100234 /*
235 * Apply modifier on all events added by single event definition
236 * (there could be more events added for multiple tracepoint
237 * definitions via '*?'.
238 */
Ian Rogerscabbf262019-10-30 15:34:45 -0700239 err = parse_events__modifier_event(list, $2, false);
240 free($2);
241 if (err) {
242 free_list_evsel(list);
243 YYABORT;
244 }
Jiri Olsa89efb022012-08-08 12:14:14 +0200245 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100246}
247|
Robert Richterac2ba9f2012-08-16 21:10:21 +0200248event_name
249
250event_name:
251PE_EVENT_NAME event_def
252{
Ian Rogerscabbf262019-10-30 15:34:45 -0700253 int err;
254
255 err = parse_events_name($2, $1);
Robert Richterac2ba9f2012-08-16 21:10:21 +0200256 free($1);
Ian Rogerscabbf262019-10-30 15:34:45 -0700257 if (err) {
258 free_list_evsel($2);
259 YYABORT;
260 }
Robert Richterac2ba9f2012-08-16 21:10:21 +0200261 $$ = $2;
262}
263|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100264event_def
265
Jiri Olsa5f537a22012-03-15 20:09:18 +0100266event_def: event_pmu |
267 event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +0100268 event_legacy_cache sep_dc |
269 event_legacy_mem |
270 event_legacy_tracepoint sep_dc |
271 event_legacy_numeric sep_dc |
Wang Nan84c86ca2015-10-14 12:41:14 +0000272 event_legacy_raw sep_dc |
273 event_bpf_file
Jiri Olsa89812fc2012-03-15 20:09:15 +0100274
Jiri Olsa5f537a22012-03-15 20:09:18 +0100275event_pmu:
Jiri Olsaceac7b72018-06-05 14:14:16 +0200276PE_NAME opt_pmu_config
Jiri Olsa5f537a22012-03-15 20:09:18 +0100277{
Jiri Olsaf7fa8272018-06-07 00:15:05 +0200278 struct parse_events_state *parse_state = _parse_state;
279 struct parse_events_error *error = parse_state->error;
Ian Rogerscabbf262019-10-30 15:34:45 -0700280 struct list_head *list = NULL, *orig_terms = NULL, *terms= NULL;
281 char *pattern = NULL;
282
283#define CLEANUP_YYABORT \
284 do { \
285 parse_events_terms__delete($2); \
286 parse_events_terms__delete(orig_terms); \
Ian Rogerse1e9b782019-11-08 23:58:40 -0800287 free(list); \
Ian Rogerscabbf262019-10-30 15:34:45 -0700288 free($1); \
289 free(pattern); \
290 YYABORT; \
291 } while(0)
Andi Kleen82557182017-03-20 13:17:03 -0700292
Arnaldo Carvalho de Melo4a35a902018-05-07 15:27:01 -0300293 if (parse_events_copy_term_list($2, &orig_terms))
Ian Rogerscabbf262019-10-30 15:34:45 -0700294 CLEANUP_YYABORT;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200295
Jiri Olsaf7fa8272018-06-07 00:15:05 +0200296 if (error)
297 error->idx = @1.first_column;
298
Ian Rogersa26e4712019-10-22 17:53:32 -0700299 list = alloc_list();
Ian Rogerscabbf262019-10-30 15:34:45 -0700300 if (!list)
301 CLEANUP_YYABORT;
Kan Liang3cdc5c22018-05-07 14:13:43 -0700302 if (parse_events_add_pmu(_parse_state, list, $1, $2, false, false)) {
Andi Kleen82557182017-03-20 13:17:03 -0700303 struct perf_pmu *pmu = NULL;
304 int ok = 0;
Agustin Vega-Friasb2b9d3a2018-03-06 09:04:42 -0500305
306 if (asprintf(&pattern, "%s*", $1) < 0)
Ian Rogerscabbf262019-10-30 15:34:45 -0700307 CLEANUP_YYABORT;
Andi Kleen82557182017-03-20 13:17:03 -0700308
309 while ((pmu = perf_pmu__scan(pmu)) != NULL) {
310 char *name = pmu->name;
311
Andi Kleena820e332017-03-20 13:17:04 -0700312 if (!strncmp(name, "uncore_", 7) &&
313 strncmp($1, "uncore_", 7))
314 name += 7;
Agustin Vega-Friasb2b9d3a2018-03-06 09:04:42 -0500315 if (!fnmatch(pattern, name, 0)) {
Ian Rogerscabbf262019-10-30 15:34:45 -0700316 if (parse_events_copy_term_list(orig_terms, &terms))
317 CLEANUP_YYABORT;
Kan Liang3cdc5c22018-05-07 14:13:43 -0700318 if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, true, false))
Andi Kleen82557182017-03-20 13:17:03 -0700319 ok++;
320 parse_events_terms__delete(terms);
321 }
322 }
Agustin Vega-Friasb2b9d3a2018-03-06 09:04:42 -0500323
Andi Kleen82557182017-03-20 13:17:03 -0700324 if (!ok)
Ian Rogerscabbf262019-10-30 15:34:45 -0700325 CLEANUP_YYABORT;
Andi Kleen82557182017-03-20 13:17:03 -0700326 }
Arnaldo Carvalho de Melo4a35a902018-05-07 15:27:01 -0300327 parse_events_terms__delete($2);
Andi Kleen82557182017-03-20 13:17:03 -0700328 parse_events_terms__delete(orig_terms);
Ian Rogersba088292020-03-18 19:31:00 -0700329 free(pattern);
Ian Rogerscabbf262019-10-30 15:34:45 -0700330 free($1);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200331 $$ = list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700332#undef CLEANUP_YYABORT
Jiri Olsa5f537a22012-03-15 20:09:18 +0100333}
Adrian Hunterad962272014-08-15 22:08:40 +0300334|
Kan Liangba32a452014-10-07 11:08:51 -0400335PE_KERNEL_PMU_EVENT sep_dc
336{
Kan Liangba32a452014-10-07 11:08:51 -0400337 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700338 int err;
Kan Liangba32a452014-10-07 11:08:51 -0400339
Ian Rogerscabbf262019-10-30 15:34:45 -0700340 err = parse_events_multi_pmu_add(_parse_state, $1, &list);
341 free($1);
342 if (err < 0)
Andi Kleen231bb2a2017-01-27 18:03:39 -0800343 YYABORT;
Kan Liangba32a452014-10-07 11:08:51 -0400344 $$ = list;
345}
346|
347PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
348{
Kan Liangba32a452014-10-07 11:08:51 -0400349 struct list_head *list;
350 char pmu_name[128];
Andi Kleen82557182017-03-20 13:17:03 -0700351
Ian Rogersc2412fa2020-06-08 22:36:09 -0700352 snprintf(pmu_name, sizeof(pmu_name), "%s-%s", $1, $3);
Ian Rogerscabbf262019-10-30 15:34:45 -0700353 free($1);
354 free($3);
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300355 if (parse_events_multi_pmu_add(_parse_state, pmu_name, &list) < 0)
Andi Kleen82557182017-03-20 13:17:03 -0700356 YYABORT;
Kan Liangba32a452014-10-07 11:08:51 -0400357 $$ = list;
358}
Jiri Olsa387ad332020-06-02 23:47:29 +0200359|
360PE_PMU_EVENT_FAKE sep_dc
361{
362 struct list_head *list;
363 int err;
364
365 list = alloc_list();
366 if (!list)
367 YYABORT;
368
369 err = parse_events_add_pmu(_parse_state, list, $1, NULL, false, false);
370 free($1);
371 if (err < 0) {
372 free(list);
373 YYABORT;
374 }
375 $$ = list;
376}
377|
378PE_PMU_EVENT_FAKE opt_pmu_config
379{
380 struct list_head *list;
381 int err;
382
383 list = alloc_list();
384 if (!list)
385 YYABORT;
386
387 err = parse_events_add_pmu(_parse_state, list, $1, $2, false, false);
388 free($1);
389 parse_events_terms__delete($2);
390 if (err < 0) {
391 free(list);
392 YYABORT;
393 }
394 $$ = list;
395}
Jiri Olsa5f537a22012-03-15 20:09:18 +0100396
Jiri Olsacf3506d2012-07-04 00:00:43 +0200397value_sym:
398PE_VALUE_SYM_HW
399|
400PE_VALUE_SYM_SW
401
Jiri Olsa89812fc2012-03-15 20:09:15 +0100402event_legacy_symbol:
Jiri Olsacf3506d2012-07-04 00:00:43 +0200403value_sym '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +0100404{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600405 struct list_head *list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100406 int type = $1 >> 16;
407 int config = $1 & 255;
Ian Rogerscabbf262019-10-30 15:34:45 -0700408 int err;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100409
Ian Rogersa26e4712019-10-22 17:53:32 -0700410 list = alloc_list();
411 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700412 err = parse_events_add_numeric(_parse_state, list, type, config, $3);
Arnaldo Carvalho de Melo2146afc2016-02-12 17:09:17 -0300413 parse_events_terms__delete($3);
Ian Rogerscabbf262019-10-30 15:34:45 -0700414 if (err) {
415 free_list_evsel(list);
416 YYABORT;
417 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200418 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100419}
420|
Jiri Olsa714a92d2019-02-13 13:32:40 +0100421value_sym sep_slash_slash_dc
Jiri Olsa8f707d82012-03-15 20:09:16 +0100422{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600423 struct list_head *list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100424 int type = $1 >> 16;
425 int config = $1 & 255;
426
Ian Rogersa26e4712019-10-22 17:53:32 -0700427 list = alloc_list();
428 ABORT_ON(!list);
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300429 ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200430 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100431}
Andi Kleenf0fbb112019-03-26 15:18:21 -0700432|
433PE_VALUE_SYM_TOOL sep_slash_slash_dc
434{
435 struct list_head *list;
436
Ian Rogersa26e4712019-10-22 17:53:32 -0700437 list = alloc_list();
438 ABORT_ON(!list);
Andi Kleenf0fbb112019-03-26 15:18:21 -0700439 ABORT_ON(parse_events_add_tool(_parse_state, list, $1));
440 $$ = list;
441}
Jiri Olsa89812fc2012-03-15 20:09:15 +0100442
443event_legacy_cache:
Wang Nan43d0b972016-02-19 11:44:01 +0000444PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100445{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300446 struct parse_events_state *parse_state = _parse_state;
447 struct parse_events_error *error = parse_state->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600448 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700449 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200450
Ian Rogersa26e4712019-10-22 17:53:32 -0700451 list = alloc_list();
452 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700453 err = parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6);
Wang Nan43d0b972016-02-19 11:44:01 +0000454 parse_events_terms__delete($6);
Ian Rogerscabbf262019-10-30 15:34:45 -0700455 free($1);
456 free($3);
457 free($5);
458 if (err) {
459 free_list_evsel(list);
460 YYABORT;
461 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200462 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100463}
464|
Wang Nan43d0b972016-02-19 11:44:01 +0000465PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100466{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300467 struct parse_events_state *parse_state = _parse_state;
468 struct parse_events_error *error = parse_state->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600469 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700470 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200471
Ian Rogersa26e4712019-10-22 17:53:32 -0700472 list = alloc_list();
473 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700474 err = parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4);
Wang Nan43d0b972016-02-19 11:44:01 +0000475 parse_events_terms__delete($4);
Ian Rogerscabbf262019-10-30 15:34:45 -0700476 free($1);
477 free($3);
478 if (err) {
479 free_list_evsel(list);
480 YYABORT;
481 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200482 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100483}
484|
Wang Nan43d0b972016-02-19 11:44:01 +0000485PE_NAME_CACHE_TYPE opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100486{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300487 struct parse_events_state *parse_state = _parse_state;
488 struct parse_events_error *error = parse_state->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600489 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700490 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200491
Ian Rogersa26e4712019-10-22 17:53:32 -0700492 list = alloc_list();
493 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700494 err = parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2);
Wang Nan43d0b972016-02-19 11:44:01 +0000495 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700496 free($1);
497 if (err) {
498 free_list_evsel(list);
499 YYABORT;
500 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200501 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100502}
503
504event_legacy_mem:
Jacob Shin3741eb92014-05-29 17:26:51 +0200505PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
506{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300507 struct parse_events_state *parse_state = _parse_state;
Jacob Shin3741eb92014-05-29 17:26:51 +0200508 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700509 int err;
Jacob Shin3741eb92014-05-29 17:26:51 +0200510
Ian Rogersa26e4712019-10-22 17:53:32 -0700511 list = alloc_list();
512 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700513 err = parse_events_add_breakpoint(list, &parse_state->idx,
Ian Rogersaa98d842020-09-24 17:39:03 -0700514 $2, $6, $4);
Ian Rogerscabbf262019-10-30 15:34:45 -0700515 free($6);
516 if (err) {
517 free(list);
518 YYABORT;
519 }
Jacob Shin3741eb92014-05-29 17:26:51 +0200520 $$ = list;
521}
522|
523PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
524{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300525 struct parse_events_state *parse_state = _parse_state;
Jacob Shin3741eb92014-05-29 17:26:51 +0200526 struct list_head *list;
527
Ian Rogersa26e4712019-10-22 17:53:32 -0700528 list = alloc_list();
529 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700530 if (parse_events_add_breakpoint(list, &parse_state->idx,
Ian Rogersaa98d842020-09-24 17:39:03 -0700531 $2, NULL, $4)) {
Ian Rogerscabbf262019-10-30 15:34:45 -0700532 free(list);
533 YYABORT;
534 }
Jacob Shin3741eb92014-05-29 17:26:51 +0200535 $$ = list;
536}
537|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100538PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
539{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300540 struct parse_events_state *parse_state = _parse_state;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600541 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700542 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200543
Ian Rogersa26e4712019-10-22 17:53:32 -0700544 list = alloc_list();
545 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700546 err = parse_events_add_breakpoint(list, &parse_state->idx,
Ian Rogersaa98d842020-09-24 17:39:03 -0700547 $2, $4, 0);
Ian Rogerscabbf262019-10-30 15:34:45 -0700548 free($4);
549 if (err) {
550 free(list);
551 YYABORT;
552 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200553 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100554}
555|
556PE_PREFIX_MEM PE_VALUE sep_dc
557{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300558 struct parse_events_state *parse_state = _parse_state;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600559 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200560
Ian Rogersa26e4712019-10-22 17:53:32 -0700561 list = alloc_list();
562 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700563 if (parse_events_add_breakpoint(list, &parse_state->idx,
Ian Rogersaa98d842020-09-24 17:39:03 -0700564 $2, NULL, 0)) {
Ian Rogerscabbf262019-10-30 15:34:45 -0700565 free(list);
566 YYABORT;
567 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200568 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100569}
570
571event_legacy_tracepoint:
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300572tracepoint_name opt_event_config
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200573{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300574 struct parse_events_state *parse_state = _parse_state;
575 struct parse_events_error *error = parse_state->error;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200576 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700577 int err;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200578
Ian Rogersa26e4712019-10-22 17:53:32 -0700579 list = alloc_list();
580 ABORT_ON(!list);
He Kuange637d172015-09-28 03:52:16 +0000581 if (error)
582 error->idx = @1.first_column;
583
Ian Rogerscabbf262019-10-30 15:34:45 -0700584 err = parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event,
585 error, $2);
He Kuange637d172015-09-28 03:52:16 +0000586
Ian Rogerscabbf262019-10-30 15:34:45 -0700587 parse_events_terms__delete($2);
588 free($1.sys);
589 free($1.event);
590 if (err) {
591 free(list);
Ian Rogerse1e9b782019-11-08 23:58:40 -0800592 YYABORT;
Ian Rogerscabbf262019-10-30 15:34:45 -0700593 }
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200594 $$ = list;
595}
He Kuang865582c2015-09-28 03:52:15 +0000596
597tracepoint_name:
598PE_NAME '-' PE_NAME ':' PE_NAME
599{
He Kuang865582c2015-09-28 03:52:15 +0000600 struct tracepoint_name tracepoint;
601
Ian Rogerscabbf262019-10-30 15:34:45 -0700602 ABORT_ON(asprintf(&tracepoint.sys, "%s-%s", $1, $3) < 0);
He Kuang865582c2015-09-28 03:52:15 +0000603 tracepoint.event = $5;
Ian Rogerscabbf262019-10-30 15:34:45 -0700604 free($1);
605 free($3);
He Kuang865582c2015-09-28 03:52:15 +0000606 $$ = tracepoint;
607}
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200608|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100609PE_NAME ':' PE_NAME
610{
He Kuang865582c2015-09-28 03:52:15 +0000611 struct tracepoint_name tracepoint = {$1, $3};
Jiri Olsab847cbd2012-05-21 09:12:51 +0200612
He Kuang865582c2015-09-28 03:52:15 +0000613 $$ = tracepoint;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100614}
615
616event_legacy_numeric:
Wang Nan10bf3582016-02-19 11:44:00 +0000617PE_VALUE ':' PE_VALUE opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100618{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600619 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700620 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200621
Ian Rogersa26e4712019-10-22 17:53:32 -0700622 list = alloc_list();
623 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700624 err = parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4);
Wang Nan10bf3582016-02-19 11:44:00 +0000625 parse_events_terms__delete($4);
Ian Rogerscabbf262019-10-30 15:34:45 -0700626 if (err) {
627 free(list);
628 YYABORT;
629 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200630 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100631}
632
633event_legacy_raw:
Wang Nan10bf3582016-02-19 11:44:00 +0000634PE_RAW opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100635{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600636 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700637 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200638
Ian Rogersa26e4712019-10-22 17:53:32 -0700639 list = alloc_list();
640 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700641 err = parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, $1, $2);
Wang Nan10bf3582016-02-19 11:44:00 +0000642 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700643 if (err) {
644 free(list);
645 YYABORT;
646 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200647 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100648}
649
Wang Nan84c86ca2015-10-14 12:41:14 +0000650event_bpf_file:
Wang Nana34f3be2016-02-22 09:10:31 +0000651PE_BPF_OBJECT opt_event_config
Wang Nan84c86ca2015-10-14 12:41:14 +0000652{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300653 struct parse_events_state *parse_state = _parse_state;
Wang Nan84c86ca2015-10-14 12:41:14 +0000654 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700655 int err;
Wang Nan84c86ca2015-10-14 12:41:14 +0000656
Ian Rogersa26e4712019-10-22 17:53:32 -0700657 list = alloc_list();
658 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700659 err = parse_events_load_bpf(parse_state, list, $1, false, $2);
Wang Nana34f3be2016-02-22 09:10:31 +0000660 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700661 free($1);
662 if (err) {
663 free(list);
664 YYABORT;
665 }
Wang Nand509db02015-10-14 12:41:20 +0000666 $$ = list;
667}
668|
Wang Nana34f3be2016-02-22 09:10:31 +0000669PE_BPF_SOURCE opt_event_config
Wang Nand509db02015-10-14 12:41:20 +0000670{
Wang Nand509db02015-10-14 12:41:20 +0000671 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700672 int err;
Wang Nand509db02015-10-14 12:41:20 +0000673
Ian Rogersa26e4712019-10-22 17:53:32 -0700674 list = alloc_list();
675 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700676 err = parse_events_load_bpf(_parse_state, list, $1, true, $2);
Wang Nana34f3be2016-02-22 09:10:31 +0000677 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700678 if (err) {
679 free(list);
680 YYABORT;
681 }
Wang Nan84c86ca2015-10-14 12:41:14 +0000682 $$ = list;
683}
684
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300685opt_event_config:
686'/' event_config '/'
687{
688 $$ = $2;
689}
690|
691'/' '/'
692{
693 $$ = NULL;
694}
695|
696{
697 $$ = NULL;
698}
699
Jiri Olsaceac7b72018-06-05 14:14:16 +0200700opt_pmu_config:
701'/' event_config '/'
702{
703 $$ = $2;
704}
705|
706'/' '/'
707{
708 $$ = NULL;
709}
710
Jiri Olsa89efb022012-08-08 12:14:14 +0200711start_terms: event_config
Jiri Olsa90e2b222012-06-15 14:31:40 +0800712{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300713 struct parse_events_state *parse_state = _parse_state;
Ian Rogerscabbf262019-10-30 15:34:45 -0700714 if (parse_state->terms) {
715 parse_events_terms__delete ($1);
716 YYABORT;
717 }
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300718 parse_state->terms = $1;
Jiri Olsa90e2b222012-06-15 14:31:40 +0800719}
720
Jiri Olsa8f707d82012-03-15 20:09:16 +0100721event_config:
722event_config ',' event_term
723{
724 struct list_head *head = $1;
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300725 struct parse_events_term *term = $3;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100726
Ian Rogerscabbf262019-10-30 15:34:45 -0700727 if (!head) {
Ian Rogers1dc92552019-10-30 15:34:47 -0700728 parse_events_term__delete(term);
Ian Rogerscabbf262019-10-30 15:34:45 -0700729 YYABORT;
730 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100731 list_add_tail(&term->list, head);
732 $$ = $1;
733}
734|
735event_term
736{
737 struct list_head *head = malloc(sizeof(*head));
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300738 struct parse_events_term *term = $1;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100739
740 ABORT_ON(!head);
741 INIT_LIST_HEAD(head);
742 list_add_tail(&term->list, head);
743 $$ = head;
744}
745
746event_term:
Jiri Olsa3a6c51e2020-04-17 00:14:05 +0200747PE_RAW
748{
749 struct parse_events_term *term;
750
751 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_CONFIG,
752 NULL, $1, false, &@1, NULL));
753 $$ = term;
754}
755|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100756PE_NAME '=' PE_NAME
757{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300758 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100759
Ian Rogerscabbf262019-10-30 15:34:45 -0700760 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
761 $1, $3, &@1, &@3)) {
762 free($1);
763 free($3);
764 YYABORT;
765 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100766 $$ = term;
767}
768|
769PE_NAME '=' PE_VALUE
770{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300771 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100772
Ian Rogerscabbf262019-10-30 15:34:45 -0700773 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
774 $1, $3, false, &@1, &@3)) {
775 free($1);
776 YYABORT;
777 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100778 $$ = term;
779}
780|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200781PE_NAME '=' PE_VALUE_SYM_HW
782{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300783 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200784 int config = $3 & 255;
785
Ian Rogerscabbf262019-10-30 15:34:45 -0700786 if (parse_events_term__sym_hw(&term, $1, config)) {
787 free($1);
788 YYABORT;
789 }
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200790 $$ = term;
791}
792|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100793PE_NAME
794{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300795 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100796
Ian Rogerscabbf262019-10-30 15:34:45 -0700797 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
798 $1, 1, true, &@1, NULL)) {
799 free($1);
800 YYABORT;
801 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100802 $$ = term;
803}
804|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200805PE_VALUE_SYM_HW
806{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300807 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200808 int config = $1 & 255;
809
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300810 ABORT_ON(parse_events_term__sym_hw(&term, NULL, config));
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200811 $$ = term;
812}
813|
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200814PE_TERM '=' PE_NAME
815{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300816 struct parse_events_term *term;
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200817
Ian Rogerscabbf262019-10-30 15:34:45 -0700818 if (parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3)) {
819 free($3);
820 YYABORT;
821 }
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200822 $$ = term;
823}
824|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100825PE_TERM '=' PE_VALUE
826{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300827 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100828
Jiri Olsa99e71382017-02-17 15:00:56 +0100829 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, false, &@1, &@3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100830 $$ = term;
831}
832|
833PE_TERM
834{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300835 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100836
Jiri Olsa99e71382017-02-17 15:00:56 +0100837 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, true, &@1, NULL));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100838 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100839}
Wang Nane571e022016-02-22 09:10:35 +0000840|
841PE_NAME array '=' PE_NAME
842{
843 struct parse_events_term *term;
Wang Nane571e022016-02-22 09:10:35 +0000844
Ian Rogerscabbf262019-10-30 15:34:45 -0700845 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
846 $1, $4, &@1, &@4)) {
847 free($1);
848 free($4);
849 free($2.ranges);
850 YYABORT;
851 }
Wang Nane571e022016-02-22 09:10:35 +0000852 term->array = $2;
853 $$ = term;
854}
855|
856PE_NAME array '=' PE_VALUE
857{
858 struct parse_events_term *term;
859
Ian Rogerscabbf262019-10-30 15:34:45 -0700860 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
861 $1, $4, false, &@1, &@4)) {
862 free($1);
863 free($2.ranges);
864 YYABORT;
865 }
Wang Nane571e022016-02-22 09:10:35 +0000866 term->array = $2;
867 $$ = term;
868}
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600869|
870PE_DRV_CFG_TERM
871{
872 struct parse_events_term *term;
Ian Rogersb6645a72019-10-30 15:34:43 -0700873 char *config = strdup($1);
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600874
Ian Rogersb6645a72019-10-30 15:34:43 -0700875 ABORT_ON(!config);
Ian Rogerscabbf262019-10-30 15:34:45 -0700876 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG,
877 config, $1, &@1, NULL)) {
878 free($1);
879 free(config);
880 YYABORT;
881 }
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600882 $$ = term;
883}
Wang Nane571e022016-02-22 09:10:35 +0000884
885array:
886'[' array_terms ']'
887{
888 $$ = $2;
889}
890|
891PE_ARRAY_ALL
892{
893 $$.nr_ranges = 0;
894 $$.ranges = NULL;
895}
896
897array_terms:
898array_terms ',' array_term
899{
900 struct parse_events_array new_array;
901
902 new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges;
Ian Rogers826100a2019-10-22 17:53:33 -0700903 new_array.ranges = realloc($1.ranges,
904 sizeof(new_array.ranges[0]) *
905 new_array.nr_ranges);
Wang Nane571e022016-02-22 09:10:35 +0000906 ABORT_ON(!new_array.ranges);
Wang Nane571e022016-02-22 09:10:35 +0000907 memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges,
908 $3.nr_ranges * sizeof(new_array.ranges[0]));
Wang Nane571e022016-02-22 09:10:35 +0000909 free($3.ranges);
910 $$ = new_array;
911}
912|
913array_term
914
915array_term:
916PE_VALUE
917{
918 struct parse_events_array array;
919
920 array.nr_ranges = 1;
921 array.ranges = malloc(sizeof(array.ranges[0]));
922 ABORT_ON(!array.ranges);
923 array.ranges[0].start = $1;
924 array.ranges[0].length = 1;
925 $$ = array;
926}
927|
928PE_VALUE PE_ARRAY_RANGE PE_VALUE
929{
930 struct parse_events_array array;
931
932 ABORT_ON($3 < $1);
933 array.nr_ranges = 1;
934 array.ranges = malloc(sizeof(array.ranges[0]));
935 ABORT_ON(!array.ranges);
936 array.ranges[0].start = $1;
937 array.ranges[0].length = $3 - $1 + 1;
938 $$ = array;
939}
Jiri Olsa89812fc2012-03-15 20:09:15 +0100940
941sep_dc: ':' |
942
Jiri Olsa714a92d2019-02-13 13:32:40 +0100943sep_slash_slash_dc: '/' '/' | ':' |
Jiri Olsa8f707d82012-03-15 20:09:16 +0100944
Jiri Olsa89812fc2012-03-15 20:09:15 +0100945%%
946
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300947void parse_events_error(YYLTYPE *loc, void *parse_state,
Jiri Olsa6297d422015-04-22 21:10:17 +0200948 void *scanner __maybe_unused,
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300949 char const *msg __maybe_unused)
Jiri Olsa89812fc2012-03-15 20:09:15 +0100950{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300951 parse_events_evlist_error(parse_state, loc->last_column, "parser error");
Jiri Olsa89812fc2012-03-15 20:09:15 +0100952}