blob: d94e48e1ff9b22ddd974465b26cddd3acf470e19 [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
Jiri Olsa84ea6032021-03-01 13:23:15 +010092%type <str> event_pmu_name
Ian Rogersf2a8ecd2019-10-30 15:34:44 -070093%destructor { free ($$); } <str>
Jiri Olsa8f707d82012-03-15 20:09:16 +010094%type <term> event_term
Ian Rogers1dc92552019-10-30 15:34:47 -070095%destructor { parse_events_term__delete ($$); } <term>
Ian Rogersf2a8ecd2019-10-30 15:34:44 -070096%type <list_terms> event_config
97%type <list_terms> opt_event_config
98%type <list_terms> opt_pmu_config
99%destructor { parse_events_terms__delete ($$); } <list_terms>
100%type <list_evsel> event_pmu
101%type <list_evsel> event_legacy_symbol
102%type <list_evsel> event_legacy_cache
103%type <list_evsel> event_legacy_mem
104%type <list_evsel> event_legacy_tracepoint
105%type <list_evsel> event_legacy_numeric
106%type <list_evsel> event_legacy_raw
107%type <list_evsel> event_bpf_file
108%type <list_evsel> event_def
109%type <list_evsel> event_mod
110%type <list_evsel> event_name
111%type <list_evsel> event
112%type <list_evsel> events
113%type <list_evsel> group_def
114%type <list_evsel> group
115%type <list_evsel> groups
116%destructor { free_list_evsel ($$); } <list_evsel>
He Kuang865582c2015-09-28 03:52:15 +0000117%type <tracepoint_name> tracepoint_name
Ian Rogersf2a8ecd2019-10-30 15:34:44 -0700118%destructor { free ($$.sys); free ($$.event); } <tracepoint_name>
Wang Nane571e022016-02-22 09:10:35 +0000119%type <array> array
120%type <array> array_term
121%type <array> array_terms
Ian Rogersf2a8ecd2019-10-30 15:34:44 -0700122%destructor { free ($$.ranges); } <array>
Jiri Olsa89812fc2012-03-15 20:09:15 +0100123
124%union
125{
126 char *str;
Robert Richterb527bab2012-08-07 19:43:13 +0200127 u64 num;
Ian Rogersf2a8ecd2019-10-30 15:34:44 -0700128 struct list_head *list_evsel;
129 struct list_head *list_terms;
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300130 struct parse_events_term *term;
He Kuang865582c2015-09-28 03:52:15 +0000131 struct tracepoint_name {
132 char *sys;
133 char *event;
134 } tracepoint_name;
Wang Nane571e022016-02-22 09:10:35 +0000135 struct parse_events_array array;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100136}
137%%
138
Jiri Olsa90e2b222012-06-15 14:31:40 +0800139start:
Jiri Olsa89efb022012-08-08 12:14:14 +0200140PE_START_EVENTS start_events
Jiri Olsa90e2b222012-06-15 14:31:40 +0800141|
Jiri Olsa89efb022012-08-08 12:14:14 +0200142PE_START_TERMS start_terms
143
144start_events: groups
145{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300146 struct parse_events_state *parse_state = _parse_state;
Jiri Olsa89efb022012-08-08 12:14:14 +0200147
Ian Rogerscabbf262019-10-30 15:34:45 -0700148 /* frees $1 */
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300149 parse_events_update_lists($1, &parse_state->list);
Jiri Olsa89efb022012-08-08 12:14:14 +0200150}
151
152groups:
153groups ',' group
154{
155 struct list_head *list = $1;
156 struct list_head *group = $3;
157
Ian Rogerscabbf262019-10-30 15:34:45 -0700158 /* frees $3 */
Jiri Olsa89efb022012-08-08 12:14:14 +0200159 parse_events_update_lists(group, list);
160 $$ = list;
161}
162|
163groups ',' event
164{
165 struct list_head *list = $1;
166 struct list_head *event = $3;
167
Ian Rogerscabbf262019-10-30 15:34:45 -0700168 /* frees $3 */
Jiri Olsa89efb022012-08-08 12:14:14 +0200169 parse_events_update_lists(event, list);
170 $$ = list;
171}
172|
173group
174|
175event
176
177group:
178group_def ':' PE_MODIFIER_EVENT
179{
180 struct list_head *list = $1;
Ian Rogerscabbf262019-10-30 15:34:45 -0700181 int err;
Jiri Olsa89efb022012-08-08 12:14:14 +0200182
Ian Rogerscabbf262019-10-30 15:34:45 -0700183 err = parse_events__modifier_group(list, $3);
184 free($3);
185 if (err) {
186 free_list_evsel(list);
187 YYABORT;
188 }
Jiri Olsa89efb022012-08-08 12:14:14 +0200189 $$ = list;
190}
191|
192group_def
193
194group_def:
195PE_NAME '{' events '}'
196{
197 struct list_head *list = $3;
198
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300199 inc_group_count(list, _parse_state);
Kan Liang3cdc5c22018-05-07 14:13:43 -0700200 parse_events__set_leader($1, list, _parse_state);
Ian Rogerscabbf262019-10-30 15:34:45 -0700201 free($1);
Jiri Olsa89efb022012-08-08 12:14:14 +0200202 $$ = list;
203}
204|
205'{' events '}'
206{
207 struct list_head *list = $2;
208
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300209 inc_group_count(list, _parse_state);
Kan Liang3cdc5c22018-05-07 14:13:43 -0700210 parse_events__set_leader(NULL, list, _parse_state);
Jiri Olsa89efb022012-08-08 12:14:14 +0200211 $$ = list;
212}
Jiri Olsa90e2b222012-06-15 14:31:40 +0800213
Jiri Olsa89812fc2012-03-15 20:09:15 +0100214events:
Jiri Olsa89efb022012-08-08 12:14:14 +0200215events ',' event
216{
217 struct list_head *event = $3;
218 struct list_head *list = $1;
219
Ian Rogerscabbf262019-10-30 15:34:45 -0700220 /* frees $3 */
Jiri Olsa89efb022012-08-08 12:14:14 +0200221 parse_events_update_lists(event, list);
222 $$ = list;
223}
224|
225event
Jiri Olsa89812fc2012-03-15 20:09:15 +0100226
Robert Richterac2ba9f2012-08-16 21:10:21 +0200227event: event_mod
228
229event_mod:
230event_name PE_MODIFIER_EVENT
Jiri Olsa89812fc2012-03-15 20:09:15 +0100231{
Jiri Olsa89efb022012-08-08 12:14:14 +0200232 struct list_head *list = $1;
Ian Rogerscabbf262019-10-30 15:34:45 -0700233 int err;
Jiri Olsa46010ab2012-06-15 14:31:38 +0800234
Jiri Olsa5d7be902012-03-20 19:15:40 +0100235 /*
236 * Apply modifier on all events added by single event definition
237 * (there could be more events added for multiple tracepoint
238 * definitions via '*?'.
239 */
Ian Rogerscabbf262019-10-30 15:34:45 -0700240 err = parse_events__modifier_event(list, $2, false);
241 free($2);
242 if (err) {
243 free_list_evsel(list);
244 YYABORT;
245 }
Jiri Olsa89efb022012-08-08 12:14:14 +0200246 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100247}
248|
Robert Richterac2ba9f2012-08-16 21:10:21 +0200249event_name
250
251event_name:
252PE_EVENT_NAME event_def
253{
Ian Rogerscabbf262019-10-30 15:34:45 -0700254 int err;
255
256 err = parse_events_name($2, $1);
Robert Richterac2ba9f2012-08-16 21:10:21 +0200257 free($1);
Ian Rogerscabbf262019-10-30 15:34:45 -0700258 if (err) {
259 free_list_evsel($2);
260 YYABORT;
261 }
Robert Richterac2ba9f2012-08-16 21:10:21 +0200262 $$ = $2;
263}
264|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100265event_def
266
Jiri Olsa5f537a22012-03-15 20:09:18 +0100267event_def: event_pmu |
268 event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +0100269 event_legacy_cache sep_dc |
270 event_legacy_mem |
271 event_legacy_tracepoint sep_dc |
272 event_legacy_numeric sep_dc |
Wang Nan84c86ca2015-10-14 12:41:14 +0000273 event_legacy_raw sep_dc |
274 event_bpf_file
Jiri Olsa89812fc2012-03-15 20:09:15 +0100275
Jiri Olsa84ea6032021-03-01 13:23:15 +0100276event_pmu_name:
277PE_NAME | PE_PMU_EVENT_PRE
278
Jiri Olsa5f537a22012-03-15 20:09:18 +0100279event_pmu:
Jiri Olsa84ea6032021-03-01 13:23:15 +0100280event_pmu_name opt_pmu_config
Jiri Olsa5f537a22012-03-15 20:09:18 +0100281{
Jiri Olsaf7fa8272018-06-07 00:15:05 +0200282 struct parse_events_state *parse_state = _parse_state;
283 struct parse_events_error *error = parse_state->error;
Ian Rogerscabbf262019-10-30 15:34:45 -0700284 struct list_head *list = NULL, *orig_terms = NULL, *terms= NULL;
285 char *pattern = NULL;
286
287#define CLEANUP_YYABORT \
288 do { \
289 parse_events_terms__delete($2); \
290 parse_events_terms__delete(orig_terms); \
Ian Rogerse1e9b782019-11-08 23:58:40 -0800291 free(list); \
Ian Rogerscabbf262019-10-30 15:34:45 -0700292 free($1); \
293 free(pattern); \
294 YYABORT; \
295 } while(0)
Andi Kleen82557182017-03-20 13:17:03 -0700296
Arnaldo Carvalho de Melo4a35a902018-05-07 15:27:01 -0300297 if (parse_events_copy_term_list($2, &orig_terms))
Ian Rogerscabbf262019-10-30 15:34:45 -0700298 CLEANUP_YYABORT;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200299
Jiri Olsaf7fa8272018-06-07 00:15:05 +0200300 if (error)
301 error->idx = @1.first_column;
302
Ian Rogersa26e4712019-10-22 17:53:32 -0700303 list = alloc_list();
Ian Rogerscabbf262019-10-30 15:34:45 -0700304 if (!list)
305 CLEANUP_YYABORT;
Kan Liang3cdc5c22018-05-07 14:13:43 -0700306 if (parse_events_add_pmu(_parse_state, list, $1, $2, false, false)) {
Andi Kleen82557182017-03-20 13:17:03 -0700307 struct perf_pmu *pmu = NULL;
308 int ok = 0;
Agustin Vega-Friasb2b9d3a2018-03-06 09:04:42 -0500309
310 if (asprintf(&pattern, "%s*", $1) < 0)
Ian Rogerscabbf262019-10-30 15:34:45 -0700311 CLEANUP_YYABORT;
Andi Kleen82557182017-03-20 13:17:03 -0700312
313 while ((pmu = perf_pmu__scan(pmu)) != NULL) {
314 char *name = pmu->name;
315
Andi Kleena820e332017-03-20 13:17:04 -0700316 if (!strncmp(name, "uncore_", 7) &&
317 strncmp($1, "uncore_", 7))
318 name += 7;
Kan Liang13d60ba2021-09-02 14:59:54 +0800319 if (!perf_pmu__match(pattern, name, $1) ||
320 !perf_pmu__match(pattern, pmu->alias_name, $1)) {
Ian Rogerscabbf262019-10-30 15:34:45 -0700321 if (parse_events_copy_term_list(orig_terms, &terms))
322 CLEANUP_YYABORT;
Kan Liang3cdc5c22018-05-07 14:13:43 -0700323 if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, true, false))
Andi Kleen82557182017-03-20 13:17:03 -0700324 ok++;
325 parse_events_terms__delete(terms);
326 }
327 }
Agustin Vega-Friasb2b9d3a2018-03-06 09:04:42 -0500328
Andi Kleen82557182017-03-20 13:17:03 -0700329 if (!ok)
Ian Rogerscabbf262019-10-30 15:34:45 -0700330 CLEANUP_YYABORT;
Andi Kleen82557182017-03-20 13:17:03 -0700331 }
Arnaldo Carvalho de Melo4a35a902018-05-07 15:27:01 -0300332 parse_events_terms__delete($2);
Andi Kleen82557182017-03-20 13:17:03 -0700333 parse_events_terms__delete(orig_terms);
Ian Rogersba088292020-03-18 19:31:00 -0700334 free(pattern);
Ian Rogerscabbf262019-10-30 15:34:45 -0700335 free($1);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200336 $$ = list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700337#undef CLEANUP_YYABORT
Jiri Olsa5f537a22012-03-15 20:09:18 +0100338}
Adrian Hunterad962272014-08-15 22:08:40 +0300339|
Kan Liangba32a452014-10-07 11:08:51 -0400340PE_KERNEL_PMU_EVENT sep_dc
341{
Kan Liangba32a452014-10-07 11:08:51 -0400342 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700343 int err;
Kan Liangba32a452014-10-07 11:08:51 -0400344
Ian Rogerscabbf262019-10-30 15:34:45 -0700345 err = parse_events_multi_pmu_add(_parse_state, $1, &list);
346 free($1);
347 if (err < 0)
Andi Kleen231bb2a2017-01-27 18:03:39 -0800348 YYABORT;
Kan Liangba32a452014-10-07 11:08:51 -0400349 $$ = list;
350}
351|
352PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
353{
Kan Liangba32a452014-10-07 11:08:51 -0400354 struct list_head *list;
355 char pmu_name[128];
Andi Kleen82557182017-03-20 13:17:03 -0700356
Ian Rogersc2412fa2020-06-08 22:36:09 -0700357 snprintf(pmu_name, sizeof(pmu_name), "%s-%s", $1, $3);
Ian Rogerscabbf262019-10-30 15:34:45 -0700358 free($1);
359 free($3);
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300360 if (parse_events_multi_pmu_add(_parse_state, pmu_name, &list) < 0)
Andi Kleen82557182017-03-20 13:17:03 -0700361 YYABORT;
Kan Liangba32a452014-10-07 11:08:51 -0400362 $$ = list;
363}
Jiri Olsa387ad332020-06-02 23:47:29 +0200364|
365PE_PMU_EVENT_FAKE sep_dc
366{
367 struct list_head *list;
368 int err;
369
370 list = alloc_list();
371 if (!list)
372 YYABORT;
373
374 err = parse_events_add_pmu(_parse_state, list, $1, NULL, false, false);
375 free($1);
376 if (err < 0) {
377 free(list);
378 YYABORT;
379 }
380 $$ = list;
381}
382|
383PE_PMU_EVENT_FAKE opt_pmu_config
384{
385 struct list_head *list;
386 int err;
387
388 list = alloc_list();
389 if (!list)
390 YYABORT;
391
392 err = parse_events_add_pmu(_parse_state, list, $1, $2, false, false);
393 free($1);
394 parse_events_terms__delete($2);
395 if (err < 0) {
396 free(list);
397 YYABORT;
398 }
399 $$ = list;
400}
Jiri Olsa5f537a22012-03-15 20:09:18 +0100401
Jiri Olsacf3506d2012-07-04 00:00:43 +0200402value_sym:
403PE_VALUE_SYM_HW
404|
405PE_VALUE_SYM_SW
406
Jiri Olsa89812fc2012-03-15 20:09:15 +0100407event_legacy_symbol:
Jiri Olsacf3506d2012-07-04 00:00:43 +0200408value_sym '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +0100409{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600410 struct list_head *list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100411 int type = $1 >> 16;
412 int config = $1 & 255;
Ian Rogerscabbf262019-10-30 15:34:45 -0700413 int err;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100414
Ian Rogersa26e4712019-10-22 17:53:32 -0700415 list = alloc_list();
416 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700417 err = parse_events_add_numeric(_parse_state, list, type, config, $3);
Arnaldo Carvalho de Melo2146afc2016-02-12 17:09:17 -0300418 parse_events_terms__delete($3);
Ian Rogerscabbf262019-10-30 15:34:45 -0700419 if (err) {
420 free_list_evsel(list);
421 YYABORT;
422 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200423 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100424}
425|
Jiri Olsa714a92d2019-02-13 13:32:40 +0100426value_sym sep_slash_slash_dc
Jiri Olsa8f707d82012-03-15 20:09:16 +0100427{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600428 struct list_head *list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100429 int type = $1 >> 16;
430 int config = $1 & 255;
431
Ian Rogersa26e4712019-10-22 17:53:32 -0700432 list = alloc_list();
433 ABORT_ON(!list);
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300434 ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200435 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100436}
Andi Kleenf0fbb112019-03-26 15:18:21 -0700437|
438PE_VALUE_SYM_TOOL sep_slash_slash_dc
439{
440 struct list_head *list;
441
Ian Rogersa26e4712019-10-22 17:53:32 -0700442 list = alloc_list();
443 ABORT_ON(!list);
Andi Kleenf0fbb112019-03-26 15:18:21 -0700444 ABORT_ON(parse_events_add_tool(_parse_state, list, $1));
445 $$ = list;
446}
Jiri Olsa89812fc2012-03-15 20:09:15 +0100447
448event_legacy_cache:
Wang Nan43d0b972016-02-19 11:44:01 +0000449PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100450{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300451 struct parse_events_state *parse_state = _parse_state;
452 struct parse_events_error *error = parse_state->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600453 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700454 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200455
Ian Rogersa26e4712019-10-22 17:53:32 -0700456 list = alloc_list();
457 ABORT_ON(!list);
Jin Yaoc93afad2021-04-27 15:01:24 +0800458 err = parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6,
459 parse_state);
Wang Nan43d0b972016-02-19 11:44:01 +0000460 parse_events_terms__delete($6);
Ian Rogerscabbf262019-10-30 15:34:45 -0700461 free($1);
462 free($3);
463 free($5);
464 if (err) {
465 free_list_evsel(list);
466 YYABORT;
467 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200468 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100469}
470|
Wang Nan43d0b972016-02-19 11:44:01 +0000471PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100472{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300473 struct parse_events_state *parse_state = _parse_state;
474 struct parse_events_error *error = parse_state->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600475 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700476 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200477
Ian Rogersa26e4712019-10-22 17:53:32 -0700478 list = alloc_list();
479 ABORT_ON(!list);
Jin Yaoc93afad2021-04-27 15:01:24 +0800480 err = parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4,
481 parse_state);
Wang Nan43d0b972016-02-19 11:44:01 +0000482 parse_events_terms__delete($4);
Ian Rogerscabbf262019-10-30 15:34:45 -0700483 free($1);
484 free($3);
485 if (err) {
486 free_list_evsel(list);
487 YYABORT;
488 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200489 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100490}
491|
Wang Nan43d0b972016-02-19 11:44:01 +0000492PE_NAME_CACHE_TYPE opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100493{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300494 struct parse_events_state *parse_state = _parse_state;
495 struct parse_events_error *error = parse_state->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600496 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700497 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200498
Ian Rogersa26e4712019-10-22 17:53:32 -0700499 list = alloc_list();
500 ABORT_ON(!list);
Jin Yaoc93afad2021-04-27 15:01:24 +0800501 err = parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2,
502 parse_state);
Wang Nan43d0b972016-02-19 11:44:01 +0000503 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700504 free($1);
505 if (err) {
506 free_list_evsel(list);
507 YYABORT;
508 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200509 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100510}
511
512event_legacy_mem:
Jacob Shin3741eb92014-05-29 17:26:51 +0200513PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
514{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300515 struct parse_events_state *parse_state = _parse_state;
Jacob Shin3741eb92014-05-29 17:26:51 +0200516 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700517 int err;
Jacob Shin3741eb92014-05-29 17:26:51 +0200518
Ian Rogersa26e4712019-10-22 17:53:32 -0700519 list = alloc_list();
520 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700521 err = parse_events_add_breakpoint(list, &parse_state->idx,
Ian Rogersaa98d842020-09-24 17:39:03 -0700522 $2, $6, $4);
Ian Rogerscabbf262019-10-30 15:34:45 -0700523 free($6);
524 if (err) {
525 free(list);
526 YYABORT;
527 }
Jacob Shin3741eb92014-05-29 17:26:51 +0200528 $$ = list;
529}
530|
531PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
532{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300533 struct parse_events_state *parse_state = _parse_state;
Jacob Shin3741eb92014-05-29 17:26:51 +0200534 struct list_head *list;
535
Ian Rogersa26e4712019-10-22 17:53:32 -0700536 list = alloc_list();
537 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700538 if (parse_events_add_breakpoint(list, &parse_state->idx,
Ian Rogersaa98d842020-09-24 17:39:03 -0700539 $2, NULL, $4)) {
Ian Rogerscabbf262019-10-30 15:34:45 -0700540 free(list);
541 YYABORT;
542 }
Jacob Shin3741eb92014-05-29 17:26:51 +0200543 $$ = list;
544}
545|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100546PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
547{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300548 struct parse_events_state *parse_state = _parse_state;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600549 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700550 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200551
Ian Rogersa26e4712019-10-22 17:53:32 -0700552 list = alloc_list();
553 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700554 err = parse_events_add_breakpoint(list, &parse_state->idx,
Ian Rogersaa98d842020-09-24 17:39:03 -0700555 $2, $4, 0);
Ian Rogerscabbf262019-10-30 15:34:45 -0700556 free($4);
557 if (err) {
558 free(list);
559 YYABORT;
560 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200561 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100562}
563|
564PE_PREFIX_MEM PE_VALUE sep_dc
565{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300566 struct parse_events_state *parse_state = _parse_state;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600567 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200568
Ian Rogersa26e4712019-10-22 17:53:32 -0700569 list = alloc_list();
570 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700571 if (parse_events_add_breakpoint(list, &parse_state->idx,
Ian Rogersaa98d842020-09-24 17:39:03 -0700572 $2, NULL, 0)) {
Ian Rogerscabbf262019-10-30 15:34:45 -0700573 free(list);
574 YYABORT;
575 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200576 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100577}
578
579event_legacy_tracepoint:
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300580tracepoint_name opt_event_config
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200581{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300582 struct parse_events_state *parse_state = _parse_state;
583 struct parse_events_error *error = parse_state->error;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200584 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700585 int err;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200586
Ian Rogersa26e4712019-10-22 17:53:32 -0700587 list = alloc_list();
588 ABORT_ON(!list);
He Kuange637d172015-09-28 03:52:16 +0000589 if (error)
590 error->idx = @1.first_column;
591
Ian Rogerscabbf262019-10-30 15:34:45 -0700592 err = parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event,
593 error, $2);
He Kuange637d172015-09-28 03:52:16 +0000594
Ian Rogerscabbf262019-10-30 15:34:45 -0700595 parse_events_terms__delete($2);
596 free($1.sys);
597 free($1.event);
598 if (err) {
599 free(list);
Ian Rogerse1e9b782019-11-08 23:58:40 -0800600 YYABORT;
Ian Rogerscabbf262019-10-30 15:34:45 -0700601 }
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200602 $$ = list;
603}
He Kuang865582c2015-09-28 03:52:15 +0000604
605tracepoint_name:
606PE_NAME '-' PE_NAME ':' PE_NAME
607{
He Kuang865582c2015-09-28 03:52:15 +0000608 struct tracepoint_name tracepoint;
609
Ian Rogerscabbf262019-10-30 15:34:45 -0700610 ABORT_ON(asprintf(&tracepoint.sys, "%s-%s", $1, $3) < 0);
He Kuang865582c2015-09-28 03:52:15 +0000611 tracepoint.event = $5;
Ian Rogerscabbf262019-10-30 15:34:45 -0700612 free($1);
613 free($3);
He Kuang865582c2015-09-28 03:52:15 +0000614 $$ = tracepoint;
615}
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200616|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100617PE_NAME ':' PE_NAME
618{
He Kuang865582c2015-09-28 03:52:15 +0000619 struct tracepoint_name tracepoint = {$1, $3};
Jiri Olsab847cbd2012-05-21 09:12:51 +0200620
He Kuang865582c2015-09-28 03:52:15 +0000621 $$ = tracepoint;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100622}
623
624event_legacy_numeric:
Wang Nan10bf3582016-02-19 11:44:00 +0000625PE_VALUE ':' PE_VALUE opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100626{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600627 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700628 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200629
Ian Rogersa26e4712019-10-22 17:53:32 -0700630 list = alloc_list();
631 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700632 err = parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4);
Wang Nan10bf3582016-02-19 11:44:00 +0000633 parse_events_terms__delete($4);
Ian Rogerscabbf262019-10-30 15:34:45 -0700634 if (err) {
635 free(list);
636 YYABORT;
637 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200638 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100639}
640
641event_legacy_raw:
Wang Nan10bf3582016-02-19 11:44:00 +0000642PE_RAW opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100643{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600644 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700645 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200646
Ian Rogersa26e4712019-10-22 17:53:32 -0700647 list = alloc_list();
648 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700649 err = parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, $1, $2);
Wang Nan10bf3582016-02-19 11:44:00 +0000650 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700651 if (err) {
652 free(list);
653 YYABORT;
654 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200655 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100656}
657
Wang Nan84c86ca2015-10-14 12:41:14 +0000658event_bpf_file:
Wang Nana34f3be2016-02-22 09:10:31 +0000659PE_BPF_OBJECT opt_event_config
Wang Nan84c86ca2015-10-14 12:41:14 +0000660{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300661 struct parse_events_state *parse_state = _parse_state;
Wang Nan84c86ca2015-10-14 12:41:14 +0000662 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700663 int err;
Wang Nan84c86ca2015-10-14 12:41:14 +0000664
Ian Rogersa26e4712019-10-22 17:53:32 -0700665 list = alloc_list();
666 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700667 err = parse_events_load_bpf(parse_state, list, $1, false, $2);
Wang Nana34f3be2016-02-22 09:10:31 +0000668 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700669 free($1);
670 if (err) {
671 free(list);
672 YYABORT;
673 }
Wang Nand509db02015-10-14 12:41:20 +0000674 $$ = list;
675}
676|
Wang Nana34f3be2016-02-22 09:10:31 +0000677PE_BPF_SOURCE opt_event_config
Wang Nand509db02015-10-14 12:41:20 +0000678{
Wang Nand509db02015-10-14 12:41:20 +0000679 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700680 int err;
Wang Nand509db02015-10-14 12:41:20 +0000681
Ian Rogersa26e4712019-10-22 17:53:32 -0700682 list = alloc_list();
683 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700684 err = parse_events_load_bpf(_parse_state, list, $1, true, $2);
Wang Nana34f3be2016-02-22 09:10:31 +0000685 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700686 if (err) {
687 free(list);
688 YYABORT;
689 }
Wang Nan84c86ca2015-10-14 12:41:14 +0000690 $$ = list;
691}
692
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300693opt_event_config:
694'/' event_config '/'
695{
696 $$ = $2;
697}
698|
699'/' '/'
700{
701 $$ = NULL;
702}
703|
704{
705 $$ = NULL;
706}
707
Jiri Olsaceac7b72018-06-05 14:14:16 +0200708opt_pmu_config:
709'/' event_config '/'
710{
711 $$ = $2;
712}
713|
714'/' '/'
715{
716 $$ = NULL;
717}
718
Jiri Olsa89efb022012-08-08 12:14:14 +0200719start_terms: event_config
Jiri Olsa90e2b222012-06-15 14:31:40 +0800720{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300721 struct parse_events_state *parse_state = _parse_state;
Ian Rogerscabbf262019-10-30 15:34:45 -0700722 if (parse_state->terms) {
723 parse_events_terms__delete ($1);
724 YYABORT;
725 }
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300726 parse_state->terms = $1;
Jiri Olsa90e2b222012-06-15 14:31:40 +0800727}
728
Jiri Olsa8f707d82012-03-15 20:09:16 +0100729event_config:
730event_config ',' event_term
731{
732 struct list_head *head = $1;
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300733 struct parse_events_term *term = $3;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100734
Ian Rogerscabbf262019-10-30 15:34:45 -0700735 if (!head) {
Ian Rogers1dc92552019-10-30 15:34:47 -0700736 parse_events_term__delete(term);
Ian Rogerscabbf262019-10-30 15:34:45 -0700737 YYABORT;
738 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100739 list_add_tail(&term->list, head);
740 $$ = $1;
741}
742|
743event_term
744{
745 struct list_head *head = malloc(sizeof(*head));
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300746 struct parse_events_term *term = $1;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100747
748 ABORT_ON(!head);
749 INIT_LIST_HEAD(head);
750 list_add_tail(&term->list, head);
751 $$ = head;
752}
753
754event_term:
Jiri Olsa3a6c51e2020-04-17 00:14:05 +0200755PE_RAW
756{
757 struct parse_events_term *term;
758
759 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_CONFIG,
760 NULL, $1, false, &@1, NULL));
761 $$ = term;
762}
763|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100764PE_NAME '=' PE_NAME
765{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300766 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100767
Ian Rogerscabbf262019-10-30 15:34:45 -0700768 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
769 $1, $3, &@1, &@3)) {
770 free($1);
771 free($3);
772 YYABORT;
773 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100774 $$ = term;
775}
776|
777PE_NAME '=' PE_VALUE
778{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300779 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100780
Ian Rogerscabbf262019-10-30 15:34:45 -0700781 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
782 $1, $3, false, &@1, &@3)) {
783 free($1);
784 YYABORT;
785 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100786 $$ = term;
787}
788|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200789PE_NAME '=' PE_VALUE_SYM_HW
790{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300791 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200792 int config = $3 & 255;
793
Ian Rogerscabbf262019-10-30 15:34:45 -0700794 if (parse_events_term__sym_hw(&term, $1, config)) {
795 free($1);
796 YYABORT;
797 }
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200798 $$ = term;
799}
800|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100801PE_NAME
802{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300803 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100804
Ian Rogerscabbf262019-10-30 15:34:45 -0700805 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
806 $1, 1, true, &@1, NULL)) {
807 free($1);
808 YYABORT;
809 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100810 $$ = term;
811}
812|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200813PE_VALUE_SYM_HW
814{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300815 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200816 int config = $1 & 255;
817
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300818 ABORT_ON(parse_events_term__sym_hw(&term, NULL, config));
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200819 $$ = term;
820}
821|
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200822PE_TERM '=' PE_NAME
823{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300824 struct parse_events_term *term;
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200825
Ian Rogerscabbf262019-10-30 15:34:45 -0700826 if (parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3)) {
827 free($3);
828 YYABORT;
829 }
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200830 $$ = term;
831}
832|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100833PE_TERM '=' PE_VALUE
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, $3, false, &@1, &@3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100838 $$ = term;
839}
840|
841PE_TERM
842{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300843 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100844
Jiri Olsa99e71382017-02-17 15:00:56 +0100845 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, true, &@1, NULL));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100846 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100847}
Wang Nane571e022016-02-22 09:10:35 +0000848|
849PE_NAME array '=' PE_NAME
850{
851 struct parse_events_term *term;
Wang Nane571e022016-02-22 09:10:35 +0000852
Ian Rogerscabbf262019-10-30 15:34:45 -0700853 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
854 $1, $4, &@1, &@4)) {
855 free($1);
856 free($4);
857 free($2.ranges);
858 YYABORT;
859 }
Wang Nane571e022016-02-22 09:10:35 +0000860 term->array = $2;
861 $$ = term;
862}
863|
864PE_NAME array '=' PE_VALUE
865{
866 struct parse_events_term *term;
867
Ian Rogerscabbf262019-10-30 15:34:45 -0700868 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
869 $1, $4, false, &@1, &@4)) {
870 free($1);
871 free($2.ranges);
872 YYABORT;
873 }
Wang Nane571e022016-02-22 09:10:35 +0000874 term->array = $2;
875 $$ = term;
876}
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600877|
878PE_DRV_CFG_TERM
879{
880 struct parse_events_term *term;
Ian Rogersb6645a72019-10-30 15:34:43 -0700881 char *config = strdup($1);
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600882
Ian Rogersb6645a72019-10-30 15:34:43 -0700883 ABORT_ON(!config);
Ian Rogerscabbf262019-10-30 15:34:45 -0700884 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG,
885 config, $1, &@1, NULL)) {
886 free($1);
887 free(config);
888 YYABORT;
889 }
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600890 $$ = term;
891}
Wang Nane571e022016-02-22 09:10:35 +0000892
893array:
894'[' array_terms ']'
895{
896 $$ = $2;
897}
898|
899PE_ARRAY_ALL
900{
901 $$.nr_ranges = 0;
902 $$.ranges = NULL;
903}
904
905array_terms:
906array_terms ',' array_term
907{
908 struct parse_events_array new_array;
909
910 new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges;
Ian Rogers826100a2019-10-22 17:53:33 -0700911 new_array.ranges = realloc($1.ranges,
912 sizeof(new_array.ranges[0]) *
913 new_array.nr_ranges);
Wang Nane571e022016-02-22 09:10:35 +0000914 ABORT_ON(!new_array.ranges);
Wang Nane571e022016-02-22 09:10:35 +0000915 memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges,
916 $3.nr_ranges * sizeof(new_array.ranges[0]));
Wang Nane571e022016-02-22 09:10:35 +0000917 free($3.ranges);
918 $$ = new_array;
919}
920|
921array_term
922
923array_term:
924PE_VALUE
925{
926 struct parse_events_array array;
927
928 array.nr_ranges = 1;
929 array.ranges = malloc(sizeof(array.ranges[0]));
930 ABORT_ON(!array.ranges);
931 array.ranges[0].start = $1;
932 array.ranges[0].length = 1;
933 $$ = array;
934}
935|
936PE_VALUE PE_ARRAY_RANGE PE_VALUE
937{
938 struct parse_events_array array;
939
940 ABORT_ON($3 < $1);
941 array.nr_ranges = 1;
942 array.ranges = malloc(sizeof(array.ranges[0]));
943 ABORT_ON(!array.ranges);
944 array.ranges[0].start = $1;
945 array.ranges[0].length = $3 - $1 + 1;
946 $$ = array;
947}
Jiri Olsa89812fc2012-03-15 20:09:15 +0100948
949sep_dc: ':' |
950
Jiri Olsa714a92d2019-02-13 13:32:40 +0100951sep_slash_slash_dc: '/' '/' | ':' |
Jiri Olsa8f707d82012-03-15 20:09:16 +0100952
Jiri Olsa89812fc2012-03-15 20:09:15 +0100953%%
954
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300955void parse_events_error(YYLTYPE *loc, void *parse_state,
Jiri Olsa6297d422015-04-22 21:10:17 +0200956 void *scanner __maybe_unused,
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300957 char const *msg __maybe_unused)
Jiri Olsa89812fc2012-03-15 20:09:15 +0100958{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300959 parse_events_evlist_error(parse_state, loc->last_column, "parser error");
Jiri Olsa89812fc2012-03-15 20:09:15 +0100960}