blob: 6ece67ed244ae4fe4053c19000d9559750b5a0c9 [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 Rogersa26e4712019-10-22 17:53:32 -070029static struct list_head* alloc_list()
30{
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
Kan Liangba32a452014-10-07 11:08:51 -040072%token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT
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
Kan Liangba32a452014-10-07 11:08:51 -040090%type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT
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 Rogerscabbf262019-10-30 15:34:45 -0700329 free($1);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200330 $$ = list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700331#undef CLEANUP_YYABORT
Jiri Olsa5f537a22012-03-15 20:09:18 +0100332}
Adrian Hunterad962272014-08-15 22:08:40 +0300333|
Kan Liangba32a452014-10-07 11:08:51 -0400334PE_KERNEL_PMU_EVENT sep_dc
335{
Kan Liangba32a452014-10-07 11:08:51 -0400336 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700337 int err;
Kan Liangba32a452014-10-07 11:08:51 -0400338
Ian Rogerscabbf262019-10-30 15:34:45 -0700339 err = parse_events_multi_pmu_add(_parse_state, $1, &list);
340 free($1);
341 if (err < 0)
Andi Kleen231bb2a2017-01-27 18:03:39 -0800342 YYABORT;
Kan Liangba32a452014-10-07 11:08:51 -0400343 $$ = list;
344}
345|
346PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
347{
Kan Liangba32a452014-10-07 11:08:51 -0400348 struct list_head *list;
349 char pmu_name[128];
Andi Kleen82557182017-03-20 13:17:03 -0700350
Kan Liangba32a452014-10-07 11:08:51 -0400351 snprintf(&pmu_name, 128, "%s-%s", $1, $3);
Ian Rogerscabbf262019-10-30 15:34:45 -0700352 free($1);
353 free($3);
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300354 if (parse_events_multi_pmu_add(_parse_state, pmu_name, &list) < 0)
Andi Kleen82557182017-03-20 13:17:03 -0700355 YYABORT;
Kan Liangba32a452014-10-07 11:08:51 -0400356 $$ = list;
357}
Jiri Olsa5f537a22012-03-15 20:09:18 +0100358
Jiri Olsacf3506d2012-07-04 00:00:43 +0200359value_sym:
360PE_VALUE_SYM_HW
361|
362PE_VALUE_SYM_SW
363
Jiri Olsa89812fc2012-03-15 20:09:15 +0100364event_legacy_symbol:
Jiri Olsacf3506d2012-07-04 00:00:43 +0200365value_sym '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +0100366{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600367 struct list_head *list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100368 int type = $1 >> 16;
369 int config = $1 & 255;
Ian Rogerscabbf262019-10-30 15:34:45 -0700370 int err;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100371
Ian Rogersa26e4712019-10-22 17:53:32 -0700372 list = alloc_list();
373 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700374 err = parse_events_add_numeric(_parse_state, list, type, config, $3);
Arnaldo Carvalho de Melo2146afc2016-02-12 17:09:17 -0300375 parse_events_terms__delete($3);
Ian Rogerscabbf262019-10-30 15:34:45 -0700376 if (err) {
377 free_list_evsel(list);
378 YYABORT;
379 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200380 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100381}
382|
Jiri Olsa714a92d2019-02-13 13:32:40 +0100383value_sym sep_slash_slash_dc
Jiri Olsa8f707d82012-03-15 20:09:16 +0100384{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600385 struct list_head *list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100386 int type = $1 >> 16;
387 int config = $1 & 255;
388
Ian Rogersa26e4712019-10-22 17:53:32 -0700389 list = alloc_list();
390 ABORT_ON(!list);
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300391 ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200392 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100393}
Andi Kleenf0fbb112019-03-26 15:18:21 -0700394|
395PE_VALUE_SYM_TOOL sep_slash_slash_dc
396{
397 struct list_head *list;
398
Ian Rogersa26e4712019-10-22 17:53:32 -0700399 list = alloc_list();
400 ABORT_ON(!list);
Andi Kleenf0fbb112019-03-26 15:18:21 -0700401 ABORT_ON(parse_events_add_tool(_parse_state, list, $1));
402 $$ = list;
403}
Jiri Olsa89812fc2012-03-15 20:09:15 +0100404
405event_legacy_cache:
Wang Nan43d0b972016-02-19 11:44:01 +0000406PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100407{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300408 struct parse_events_state *parse_state = _parse_state;
409 struct parse_events_error *error = parse_state->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600410 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700411 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200412
Ian Rogersa26e4712019-10-22 17:53:32 -0700413 list = alloc_list();
414 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700415 err = parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6);
Wang Nan43d0b972016-02-19 11:44:01 +0000416 parse_events_terms__delete($6);
Ian Rogerscabbf262019-10-30 15:34:45 -0700417 free($1);
418 free($3);
419 free($5);
420 if (err) {
421 free_list_evsel(list);
422 YYABORT;
423 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200424 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100425}
426|
Wang Nan43d0b972016-02-19 11:44:01 +0000427PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100428{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300429 struct parse_events_state *parse_state = _parse_state;
430 struct parse_events_error *error = parse_state->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600431 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700432 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200433
Ian Rogersa26e4712019-10-22 17:53:32 -0700434 list = alloc_list();
435 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700436 err = parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4);
Wang Nan43d0b972016-02-19 11:44:01 +0000437 parse_events_terms__delete($4);
Ian Rogerscabbf262019-10-30 15:34:45 -0700438 free($1);
439 free($3);
440 if (err) {
441 free_list_evsel(list);
442 YYABORT;
443 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200444 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100445}
446|
Wang Nan43d0b972016-02-19 11:44:01 +0000447PE_NAME_CACHE_TYPE opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100448{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300449 struct parse_events_state *parse_state = _parse_state;
450 struct parse_events_error *error = parse_state->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600451 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700452 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200453
Ian Rogersa26e4712019-10-22 17:53:32 -0700454 list = alloc_list();
455 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700456 err = parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2);
Wang Nan43d0b972016-02-19 11:44:01 +0000457 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700458 free($1);
459 if (err) {
460 free_list_evsel(list);
461 YYABORT;
462 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200463 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100464}
465
466event_legacy_mem:
Jacob Shin3741eb92014-05-29 17:26:51 +0200467PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
468{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300469 struct parse_events_state *parse_state = _parse_state;
Jacob Shin3741eb92014-05-29 17:26:51 +0200470 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700471 int err;
Jacob Shin3741eb92014-05-29 17:26:51 +0200472
Ian Rogersa26e4712019-10-22 17:53:32 -0700473 list = alloc_list();
474 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700475 err = parse_events_add_breakpoint(list, &parse_state->idx,
476 (void *) $2, $6, $4);
477 free($6);
478 if (err) {
479 free(list);
480 YYABORT;
481 }
Jacob Shin3741eb92014-05-29 17:26:51 +0200482 $$ = list;
483}
484|
485PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
486{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300487 struct parse_events_state *parse_state = _parse_state;
Jacob Shin3741eb92014-05-29 17:26:51 +0200488 struct list_head *list;
489
Ian Rogersa26e4712019-10-22 17:53:32 -0700490 list = alloc_list();
491 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700492 if (parse_events_add_breakpoint(list, &parse_state->idx,
493 (void *) $2, NULL, $4)) {
494 free(list);
495 YYABORT;
496 }
Jacob Shin3741eb92014-05-29 17:26:51 +0200497 $$ = list;
498}
499|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100500PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
501{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300502 struct parse_events_state *parse_state = _parse_state;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600503 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700504 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200505
Ian Rogersa26e4712019-10-22 17:53:32 -0700506 list = alloc_list();
507 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700508 err = parse_events_add_breakpoint(list, &parse_state->idx,
509 (void *) $2, $4, 0);
510 free($4);
511 if (err) {
512 free(list);
513 YYABORT;
514 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200515 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100516}
517|
518PE_PREFIX_MEM PE_VALUE sep_dc
519{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300520 struct parse_events_state *parse_state = _parse_state;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600521 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200522
Ian Rogersa26e4712019-10-22 17:53:32 -0700523 list = alloc_list();
524 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700525 if (parse_events_add_breakpoint(list, &parse_state->idx,
526 (void *) $2, NULL, 0)) {
527 free(list);
528 YYABORT;
529 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200530 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100531}
532
533event_legacy_tracepoint:
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300534tracepoint_name opt_event_config
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200535{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300536 struct parse_events_state *parse_state = _parse_state;
537 struct parse_events_error *error = parse_state->error;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200538 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700539 int err;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200540
Ian Rogersa26e4712019-10-22 17:53:32 -0700541 list = alloc_list();
542 ABORT_ON(!list);
He Kuange637d172015-09-28 03:52:16 +0000543 if (error)
544 error->idx = @1.first_column;
545
Ian Rogerscabbf262019-10-30 15:34:45 -0700546 err = parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event,
547 error, $2);
He Kuange637d172015-09-28 03:52:16 +0000548
Ian Rogerscabbf262019-10-30 15:34:45 -0700549 parse_events_terms__delete($2);
550 free($1.sys);
551 free($1.event);
552 if (err) {
553 free(list);
Ian Rogerse1e9b782019-11-08 23:58:40 -0800554 YYABORT;
Ian Rogerscabbf262019-10-30 15:34:45 -0700555 }
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200556 $$ = list;
557}
He Kuang865582c2015-09-28 03:52:15 +0000558
559tracepoint_name:
560PE_NAME '-' PE_NAME ':' PE_NAME
561{
He Kuang865582c2015-09-28 03:52:15 +0000562 struct tracepoint_name tracepoint;
563
Ian Rogerscabbf262019-10-30 15:34:45 -0700564 ABORT_ON(asprintf(&tracepoint.sys, "%s-%s", $1, $3) < 0);
He Kuang865582c2015-09-28 03:52:15 +0000565 tracepoint.event = $5;
Ian Rogerscabbf262019-10-30 15:34:45 -0700566 free($1);
567 free($3);
He Kuang865582c2015-09-28 03:52:15 +0000568 $$ = tracepoint;
569}
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200570|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100571PE_NAME ':' PE_NAME
572{
He Kuang865582c2015-09-28 03:52:15 +0000573 struct tracepoint_name tracepoint = {$1, $3};
Jiri Olsab847cbd2012-05-21 09:12:51 +0200574
He Kuang865582c2015-09-28 03:52:15 +0000575 $$ = tracepoint;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100576}
577
578event_legacy_numeric:
Wang Nan10bf3582016-02-19 11:44:00 +0000579PE_VALUE ':' PE_VALUE opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100580{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600581 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700582 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200583
Ian Rogersa26e4712019-10-22 17:53:32 -0700584 list = alloc_list();
585 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700586 err = parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4);
Wang Nan10bf3582016-02-19 11:44:00 +0000587 parse_events_terms__delete($4);
Ian Rogerscabbf262019-10-30 15:34:45 -0700588 if (err) {
589 free(list);
590 YYABORT;
591 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200592 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100593}
594
595event_legacy_raw:
Wang Nan10bf3582016-02-19 11:44:00 +0000596PE_RAW opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100597{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600598 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700599 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200600
Ian Rogersa26e4712019-10-22 17:53:32 -0700601 list = alloc_list();
602 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700603 err = parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, $1, $2);
Wang Nan10bf3582016-02-19 11:44:00 +0000604 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700605 if (err) {
606 free(list);
607 YYABORT;
608 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200609 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100610}
611
Wang Nan84c86ca2015-10-14 12:41:14 +0000612event_bpf_file:
Wang Nana34f3be2016-02-22 09:10:31 +0000613PE_BPF_OBJECT opt_event_config
Wang Nan84c86ca2015-10-14 12:41:14 +0000614{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300615 struct parse_events_state *parse_state = _parse_state;
Wang Nan84c86ca2015-10-14 12:41:14 +0000616 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700617 int err;
Wang Nan84c86ca2015-10-14 12:41:14 +0000618
Ian Rogersa26e4712019-10-22 17:53:32 -0700619 list = alloc_list();
620 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700621 err = parse_events_load_bpf(parse_state, list, $1, false, $2);
Wang Nana34f3be2016-02-22 09:10:31 +0000622 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700623 free($1);
624 if (err) {
625 free(list);
626 YYABORT;
627 }
Wang Nand509db02015-10-14 12:41:20 +0000628 $$ = list;
629}
630|
Wang Nana34f3be2016-02-22 09:10:31 +0000631PE_BPF_SOURCE opt_event_config
Wang Nand509db02015-10-14 12:41:20 +0000632{
Wang Nand509db02015-10-14 12:41:20 +0000633 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700634 int err;
Wang Nand509db02015-10-14 12:41:20 +0000635
Ian Rogersa26e4712019-10-22 17:53:32 -0700636 list = alloc_list();
637 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700638 err = parse_events_load_bpf(_parse_state, list, $1, true, $2);
Wang Nana34f3be2016-02-22 09:10:31 +0000639 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700640 if (err) {
641 free(list);
642 YYABORT;
643 }
Wang Nan84c86ca2015-10-14 12:41:14 +0000644 $$ = list;
645}
646
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300647opt_event_config:
648'/' event_config '/'
649{
650 $$ = $2;
651}
652|
653'/' '/'
654{
655 $$ = NULL;
656}
657|
658{
659 $$ = NULL;
660}
661
Jiri Olsaceac7b72018-06-05 14:14:16 +0200662opt_pmu_config:
663'/' event_config '/'
664{
665 $$ = $2;
666}
667|
668'/' '/'
669{
670 $$ = NULL;
671}
672
Jiri Olsa89efb022012-08-08 12:14:14 +0200673start_terms: event_config
Jiri Olsa90e2b222012-06-15 14:31:40 +0800674{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300675 struct parse_events_state *parse_state = _parse_state;
Ian Rogerscabbf262019-10-30 15:34:45 -0700676 if (parse_state->terms) {
677 parse_events_terms__delete ($1);
678 YYABORT;
679 }
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300680 parse_state->terms = $1;
Jiri Olsa90e2b222012-06-15 14:31:40 +0800681}
682
Jiri Olsa8f707d82012-03-15 20:09:16 +0100683event_config:
684event_config ',' event_term
685{
686 struct list_head *head = $1;
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300687 struct parse_events_term *term = $3;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100688
Ian Rogerscabbf262019-10-30 15:34:45 -0700689 if (!head) {
Ian Rogers1dc92552019-10-30 15:34:47 -0700690 parse_events_term__delete(term);
Ian Rogerscabbf262019-10-30 15:34:45 -0700691 YYABORT;
692 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100693 list_add_tail(&term->list, head);
694 $$ = $1;
695}
696|
697event_term
698{
699 struct list_head *head = malloc(sizeof(*head));
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300700 struct parse_events_term *term = $1;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100701
702 ABORT_ON(!head);
703 INIT_LIST_HEAD(head);
704 list_add_tail(&term->list, head);
705 $$ = head;
706}
707
708event_term:
Jiri Olsa3a6c51e2020-04-17 00:14:05 +0200709PE_RAW
710{
711 struct parse_events_term *term;
712
713 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_CONFIG,
714 NULL, $1, false, &@1, NULL));
715 $$ = term;
716}
717|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100718PE_NAME '=' PE_NAME
719{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300720 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100721
Ian Rogerscabbf262019-10-30 15:34:45 -0700722 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
723 $1, $3, &@1, &@3)) {
724 free($1);
725 free($3);
726 YYABORT;
727 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100728 $$ = term;
729}
730|
731PE_NAME '=' PE_VALUE
732{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300733 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100734
Ian Rogerscabbf262019-10-30 15:34:45 -0700735 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
736 $1, $3, false, &@1, &@3)) {
737 free($1);
738 YYABORT;
739 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100740 $$ = term;
741}
742|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200743PE_NAME '=' PE_VALUE_SYM_HW
744{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300745 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200746 int config = $3 & 255;
747
Ian Rogerscabbf262019-10-30 15:34:45 -0700748 if (parse_events_term__sym_hw(&term, $1, config)) {
749 free($1);
750 YYABORT;
751 }
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200752 $$ = term;
753}
754|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100755PE_NAME
756{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300757 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100758
Ian Rogerscabbf262019-10-30 15:34:45 -0700759 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
760 $1, 1, true, &@1, NULL)) {
761 free($1);
762 YYABORT;
763 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100764 $$ = term;
765}
766|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200767PE_VALUE_SYM_HW
768{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300769 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200770 int config = $1 & 255;
771
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300772 ABORT_ON(parse_events_term__sym_hw(&term, NULL, config));
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200773 $$ = term;
774}
775|
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200776PE_TERM '=' PE_NAME
777{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300778 struct parse_events_term *term;
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200779
Ian Rogerscabbf262019-10-30 15:34:45 -0700780 if (parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3)) {
781 free($3);
782 YYABORT;
783 }
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200784 $$ = term;
785}
786|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100787PE_TERM '=' PE_VALUE
788{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300789 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100790
Jiri Olsa99e71382017-02-17 15:00:56 +0100791 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, false, &@1, &@3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100792 $$ = term;
793}
794|
795PE_TERM
796{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300797 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100798
Jiri Olsa99e71382017-02-17 15:00:56 +0100799 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, true, &@1, NULL));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100800 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100801}
Wang Nane571e022016-02-22 09:10:35 +0000802|
803PE_NAME array '=' PE_NAME
804{
805 struct parse_events_term *term;
Wang Nane571e022016-02-22 09:10:35 +0000806
Ian Rogerscabbf262019-10-30 15:34:45 -0700807 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
808 $1, $4, &@1, &@4)) {
809 free($1);
810 free($4);
811 free($2.ranges);
812 YYABORT;
813 }
Wang Nane571e022016-02-22 09:10:35 +0000814 term->array = $2;
815 $$ = term;
816}
817|
818PE_NAME array '=' PE_VALUE
819{
820 struct parse_events_term *term;
821
Ian Rogerscabbf262019-10-30 15:34:45 -0700822 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
823 $1, $4, false, &@1, &@4)) {
824 free($1);
825 free($2.ranges);
826 YYABORT;
827 }
Wang Nane571e022016-02-22 09:10:35 +0000828 term->array = $2;
829 $$ = term;
830}
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600831|
832PE_DRV_CFG_TERM
833{
834 struct parse_events_term *term;
Ian Rogersb6645a72019-10-30 15:34:43 -0700835 char *config = strdup($1);
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600836
Ian Rogersb6645a72019-10-30 15:34:43 -0700837 ABORT_ON(!config);
Ian Rogerscabbf262019-10-30 15:34:45 -0700838 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG,
839 config, $1, &@1, NULL)) {
840 free($1);
841 free(config);
842 YYABORT;
843 }
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600844 $$ = term;
845}
Wang Nane571e022016-02-22 09:10:35 +0000846
847array:
848'[' array_terms ']'
849{
850 $$ = $2;
851}
852|
853PE_ARRAY_ALL
854{
855 $$.nr_ranges = 0;
856 $$.ranges = NULL;
857}
858
859array_terms:
860array_terms ',' array_term
861{
862 struct parse_events_array new_array;
863
864 new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges;
Ian Rogers826100a2019-10-22 17:53:33 -0700865 new_array.ranges = realloc($1.ranges,
866 sizeof(new_array.ranges[0]) *
867 new_array.nr_ranges);
Wang Nane571e022016-02-22 09:10:35 +0000868 ABORT_ON(!new_array.ranges);
Wang Nane571e022016-02-22 09:10:35 +0000869 memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges,
870 $3.nr_ranges * sizeof(new_array.ranges[0]));
Wang Nane571e022016-02-22 09:10:35 +0000871 free($3.ranges);
872 $$ = new_array;
873}
874|
875array_term
876
877array_term:
878PE_VALUE
879{
880 struct parse_events_array array;
881
882 array.nr_ranges = 1;
883 array.ranges = malloc(sizeof(array.ranges[0]));
884 ABORT_ON(!array.ranges);
885 array.ranges[0].start = $1;
886 array.ranges[0].length = 1;
887 $$ = array;
888}
889|
890PE_VALUE PE_ARRAY_RANGE PE_VALUE
891{
892 struct parse_events_array array;
893
894 ABORT_ON($3 < $1);
895 array.nr_ranges = 1;
896 array.ranges = malloc(sizeof(array.ranges[0]));
897 ABORT_ON(!array.ranges);
898 array.ranges[0].start = $1;
899 array.ranges[0].length = $3 - $1 + 1;
900 $$ = array;
901}
Jiri Olsa89812fc2012-03-15 20:09:15 +0100902
903sep_dc: ':' |
904
Jiri Olsa714a92d2019-02-13 13:32:40 +0100905sep_slash_slash_dc: '/' '/' | ':' |
Jiri Olsa8f707d82012-03-15 20:09:16 +0100906
Jiri Olsa89812fc2012-03-15 20:09:15 +0100907%%
908
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300909void parse_events_error(YYLTYPE *loc, void *parse_state,
Jiri Olsa6297d422015-04-22 21:10:17 +0200910 void *scanner __maybe_unused,
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300911 char const *msg __maybe_unused)
Jiri Olsa89812fc2012-03-15 20:09:15 +0100912{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300913 parse_events_evlist_error(parse_state, loc->last_column, "parser error");
Jiri Olsa89812fc2012-03-15 20:09:15 +0100914}