blob: be8c517700517ebd1d588ed900320b6a900dd839 [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
John Garry864bc8c2022-01-17 23:10:13 +080072%token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_PMU_EVENT_SUF2 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
John Garry864bc8c2022-01-17 23:10:13 +080090%type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_PMU_EVENT_SUF2 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) {
Ian Rogerseabd4522021-10-15 10:21:31 -0700186 struct parse_events_state *parse_state = _parse_state;
187 struct parse_events_error *error = parse_state->error;
188
Ian Rogers6c191282021-11-07 01:00:00 -0800189 parse_events_error__handle(error, @3.first_column,
Ian Rogerseabd4522021-10-15 10:21:31 -0700190 strdup("Bad modifier"), NULL);
Ian Rogerscabbf262019-10-30 15:34:45 -0700191 free_list_evsel(list);
192 YYABORT;
193 }
Jiri Olsa89efb022012-08-08 12:14:14 +0200194 $$ = list;
195}
196|
197group_def
198
199group_def:
200PE_NAME '{' events '}'
201{
202 struct list_head *list = $3;
203
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300204 inc_group_count(list, _parse_state);
Kan Liang3cdc5c22018-05-07 14:13:43 -0700205 parse_events__set_leader($1, list, _parse_state);
Ian Rogerscabbf262019-10-30 15:34:45 -0700206 free($1);
Jiri Olsa89efb022012-08-08 12:14:14 +0200207 $$ = list;
208}
209|
210'{' events '}'
211{
212 struct list_head *list = $2;
213
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300214 inc_group_count(list, _parse_state);
Kan Liang3cdc5c22018-05-07 14:13:43 -0700215 parse_events__set_leader(NULL, list, _parse_state);
Jiri Olsa89efb022012-08-08 12:14:14 +0200216 $$ = list;
217}
Jiri Olsa90e2b222012-06-15 14:31:40 +0800218
Jiri Olsa89812fc2012-03-15 20:09:15 +0100219events:
Jiri Olsa89efb022012-08-08 12:14:14 +0200220events ',' event
221{
222 struct list_head *event = $3;
223 struct list_head *list = $1;
224
Ian Rogerscabbf262019-10-30 15:34:45 -0700225 /* frees $3 */
Jiri Olsa89efb022012-08-08 12:14:14 +0200226 parse_events_update_lists(event, list);
227 $$ = list;
228}
229|
230event
Jiri Olsa89812fc2012-03-15 20:09:15 +0100231
Robert Richterac2ba9f2012-08-16 21:10:21 +0200232event: event_mod
233
234event_mod:
235event_name PE_MODIFIER_EVENT
Jiri Olsa89812fc2012-03-15 20:09:15 +0100236{
Jiri Olsa89efb022012-08-08 12:14:14 +0200237 struct list_head *list = $1;
Ian Rogerscabbf262019-10-30 15:34:45 -0700238 int err;
Jiri Olsa46010ab2012-06-15 14:31:38 +0800239
Jiri Olsa5d7be902012-03-20 19:15:40 +0100240 /*
241 * Apply modifier on all events added by single event definition
242 * (there could be more events added for multiple tracepoint
243 * definitions via '*?'.
244 */
Ian Rogerscabbf262019-10-30 15:34:45 -0700245 err = parse_events__modifier_event(list, $2, false);
246 free($2);
247 if (err) {
Ian Rogerseabd4522021-10-15 10:21:31 -0700248 struct parse_events_state *parse_state = _parse_state;
249 struct parse_events_error *error = parse_state->error;
250
Ian Rogers6c191282021-11-07 01:00:00 -0800251 parse_events_error__handle(error, @2.first_column,
Ian Rogerseabd4522021-10-15 10:21:31 -0700252 strdup("Bad modifier"), NULL);
Ian Rogerscabbf262019-10-30 15:34:45 -0700253 free_list_evsel(list);
254 YYABORT;
255 }
Jiri Olsa89efb022012-08-08 12:14:14 +0200256 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100257}
258|
Robert Richterac2ba9f2012-08-16 21:10:21 +0200259event_name
260
261event_name:
262PE_EVENT_NAME event_def
263{
Ian Rogerscabbf262019-10-30 15:34:45 -0700264 int err;
265
266 err = parse_events_name($2, $1);
Robert Richterac2ba9f2012-08-16 21:10:21 +0200267 free($1);
Ian Rogerscabbf262019-10-30 15:34:45 -0700268 if (err) {
269 free_list_evsel($2);
270 YYABORT;
271 }
Robert Richterac2ba9f2012-08-16 21:10:21 +0200272 $$ = $2;
273}
274|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100275event_def
276
Jiri Olsa5f537a22012-03-15 20:09:18 +0100277event_def: event_pmu |
278 event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +0100279 event_legacy_cache sep_dc |
280 event_legacy_mem |
281 event_legacy_tracepoint sep_dc |
282 event_legacy_numeric sep_dc |
Wang Nan84c86ca2015-10-14 12:41:14 +0000283 event_legacy_raw sep_dc |
284 event_bpf_file
Jiri Olsa89812fc2012-03-15 20:09:15 +0100285
Jiri Olsa84ea6032021-03-01 13:23:15 +0100286event_pmu_name:
287PE_NAME | PE_PMU_EVENT_PRE
288
Jiri Olsa5f537a22012-03-15 20:09:18 +0100289event_pmu:
Jiri Olsa84ea6032021-03-01 13:23:15 +0100290event_pmu_name opt_pmu_config
Jiri Olsa5f537a22012-03-15 20:09:18 +0100291{
Jiri Olsaf7fa8272018-06-07 00:15:05 +0200292 struct parse_events_state *parse_state = _parse_state;
293 struct parse_events_error *error = parse_state->error;
Ian Rogerscabbf262019-10-30 15:34:45 -0700294 struct list_head *list = NULL, *orig_terms = NULL, *terms= NULL;
295 char *pattern = NULL;
296
297#define CLEANUP_YYABORT \
298 do { \
299 parse_events_terms__delete($2); \
300 parse_events_terms__delete(orig_terms); \
Ian Rogerse1e9b782019-11-08 23:58:40 -0800301 free(list); \
Ian Rogerscabbf262019-10-30 15:34:45 -0700302 free($1); \
303 free(pattern); \
304 YYABORT; \
305 } while(0)
Andi Kleen82557182017-03-20 13:17:03 -0700306
Arnaldo Carvalho de Melo4a35a902018-05-07 15:27:01 -0300307 if (parse_events_copy_term_list($2, &orig_terms))
Ian Rogerscabbf262019-10-30 15:34:45 -0700308 CLEANUP_YYABORT;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200309
Jiri Olsaf7fa8272018-06-07 00:15:05 +0200310 if (error)
311 error->idx = @1.first_column;
312
Ian Rogersa26e4712019-10-22 17:53:32 -0700313 list = alloc_list();
Ian Rogerscabbf262019-10-30 15:34:45 -0700314 if (!list)
315 CLEANUP_YYABORT;
Kan Liang3cdc5c22018-05-07 14:13:43 -0700316 if (parse_events_add_pmu(_parse_state, list, $1, $2, false, false)) {
Andi Kleen82557182017-03-20 13:17:03 -0700317 struct perf_pmu *pmu = NULL;
318 int ok = 0;
Agustin Vega-Friasb2b9d3a2018-03-06 09:04:42 -0500319
320 if (asprintf(&pattern, "%s*", $1) < 0)
Ian Rogerscabbf262019-10-30 15:34:45 -0700321 CLEANUP_YYABORT;
Andi Kleen82557182017-03-20 13:17:03 -0700322
323 while ((pmu = perf_pmu__scan(pmu)) != NULL) {
324 char *name = pmu->name;
325
Andi Kleena820e332017-03-20 13:17:04 -0700326 if (!strncmp(name, "uncore_", 7) &&
327 strncmp($1, "uncore_", 7))
328 name += 7;
Kan Liang13d60ba2021-09-02 14:59:54 +0800329 if (!perf_pmu__match(pattern, name, $1) ||
330 !perf_pmu__match(pattern, pmu->alias_name, $1)) {
Ian Rogerscabbf262019-10-30 15:34:45 -0700331 if (parse_events_copy_term_list(orig_terms, &terms))
332 CLEANUP_YYABORT;
Kan Liang3cdc5c22018-05-07 14:13:43 -0700333 if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, true, false))
Andi Kleen82557182017-03-20 13:17:03 -0700334 ok++;
335 parse_events_terms__delete(terms);
336 }
337 }
Agustin Vega-Friasb2b9d3a2018-03-06 09:04:42 -0500338
Andi Kleen82557182017-03-20 13:17:03 -0700339 if (!ok)
Ian Rogerscabbf262019-10-30 15:34:45 -0700340 CLEANUP_YYABORT;
Andi Kleen82557182017-03-20 13:17:03 -0700341 }
Arnaldo Carvalho de Melo4a35a902018-05-07 15:27:01 -0300342 parse_events_terms__delete($2);
Andi Kleen82557182017-03-20 13:17:03 -0700343 parse_events_terms__delete(orig_terms);
Ian Rogersba088292020-03-18 19:31:00 -0700344 free(pattern);
Ian Rogerscabbf262019-10-30 15:34:45 -0700345 free($1);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200346 $$ = list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700347#undef CLEANUP_YYABORT
Jiri Olsa5f537a22012-03-15 20:09:18 +0100348}
Adrian Hunterad962272014-08-15 22:08:40 +0300349|
Kan Liangba32a452014-10-07 11:08:51 -0400350PE_KERNEL_PMU_EVENT sep_dc
351{
Kan Liangba32a452014-10-07 11:08:51 -0400352 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700353 int err;
Kan Liangba32a452014-10-07 11:08:51 -0400354
Ian Rogersfb081152021-10-15 10:21:26 -0700355 err = parse_events_multi_pmu_add(_parse_state, $1, NULL, &list);
356 free($1);
357 if (err < 0)
358 YYABORT;
359 $$ = list;
360}
361|
362PE_KERNEL_PMU_EVENT opt_pmu_config
363{
364 struct list_head *list;
365 int err;
366
367 /* frees $2 */
368 err = parse_events_multi_pmu_add(_parse_state, $1, $2, &list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700369 free($1);
370 if (err < 0)
Andi Kleen231bb2a2017-01-27 18:03:39 -0800371 YYABORT;
Kan Liangba32a452014-10-07 11:08:51 -0400372 $$ = list;
373}
374|
John Garry864bc8c2022-01-17 23:10:13 +0800375PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF '-' PE_PMU_EVENT_SUF2 sep_dc
376{
377 struct list_head *list;
378 char pmu_name[128];
379 snprintf(pmu_name, sizeof(pmu_name), "%s-%s-%s", $1, $3, $5);
380 free($1);
381 free($3);
382 free($5);
383 if (parse_events_multi_pmu_add(_parse_state, pmu_name, NULL, &list) < 0)
384 YYABORT;
385 $$ = list;
386}
387|
Kan Liangba32a452014-10-07 11:08:51 -0400388PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
389{
Kan Liangba32a452014-10-07 11:08:51 -0400390 struct list_head *list;
391 char pmu_name[128];
Andi Kleen82557182017-03-20 13:17:03 -0700392
Ian Rogersc2412fa2020-06-08 22:36:09 -0700393 snprintf(pmu_name, sizeof(pmu_name), "%s-%s", $1, $3);
Ian Rogerscabbf262019-10-30 15:34:45 -0700394 free($1);
395 free($3);
Ian Rogersfb081152021-10-15 10:21:26 -0700396 if (parse_events_multi_pmu_add(_parse_state, pmu_name, NULL, &list) < 0)
Andi Kleen82557182017-03-20 13:17:03 -0700397 YYABORT;
Kan Liangba32a452014-10-07 11:08:51 -0400398 $$ = list;
399}
Jiri Olsa387ad332020-06-02 23:47:29 +0200400|
401PE_PMU_EVENT_FAKE sep_dc
402{
403 struct list_head *list;
404 int err;
405
406 list = alloc_list();
407 if (!list)
408 YYABORT;
409
410 err = parse_events_add_pmu(_parse_state, list, $1, NULL, false, false);
411 free($1);
412 if (err < 0) {
413 free(list);
414 YYABORT;
415 }
416 $$ = list;
417}
418|
419PE_PMU_EVENT_FAKE opt_pmu_config
420{
421 struct list_head *list;
422 int err;
423
424 list = alloc_list();
425 if (!list)
426 YYABORT;
427
428 err = parse_events_add_pmu(_parse_state, list, $1, $2, false, false);
429 free($1);
430 parse_events_terms__delete($2);
431 if (err < 0) {
432 free(list);
433 YYABORT;
434 }
435 $$ = list;
436}
Jiri Olsa5f537a22012-03-15 20:09:18 +0100437
Jiri Olsacf3506d2012-07-04 00:00:43 +0200438value_sym:
439PE_VALUE_SYM_HW
440|
441PE_VALUE_SYM_SW
442
Jiri Olsa89812fc2012-03-15 20:09:15 +0100443event_legacy_symbol:
Jiri Olsacf3506d2012-07-04 00:00:43 +0200444value_sym '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +0100445{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600446 struct list_head *list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100447 int type = $1 >> 16;
448 int config = $1 & 255;
Ian Rogerscabbf262019-10-30 15:34:45 -0700449 int err;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100450
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_numeric(_parse_state, list, type, config, $3);
Arnaldo Carvalho de Melo2146afc2016-02-12 17:09:17 -0300454 parse_events_terms__delete($3);
Ian Rogerscabbf262019-10-30 15:34:45 -0700455 if (err) {
456 free_list_evsel(list);
457 YYABORT;
458 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200459 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100460}
461|
Jiri Olsa714a92d2019-02-13 13:32:40 +0100462value_sym sep_slash_slash_dc
Jiri Olsa8f707d82012-03-15 20:09:16 +0100463{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600464 struct list_head *list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100465 int type = $1 >> 16;
466 int config = $1 & 255;
467
Ian Rogersa26e4712019-10-22 17:53:32 -0700468 list = alloc_list();
469 ABORT_ON(!list);
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300470 ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200471 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100472}
Andi Kleenf0fbb112019-03-26 15:18:21 -0700473|
474PE_VALUE_SYM_TOOL sep_slash_slash_dc
475{
476 struct list_head *list;
477
Ian Rogersa26e4712019-10-22 17:53:32 -0700478 list = alloc_list();
479 ABORT_ON(!list);
Andi Kleenf0fbb112019-03-26 15:18:21 -0700480 ABORT_ON(parse_events_add_tool(_parse_state, list, $1));
481 $$ = list;
482}
Jiri Olsa89812fc2012-03-15 20:09:15 +0100483
484event_legacy_cache:
Wang Nan43d0b972016-02-19 11:44:01 +0000485PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT 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);
Jin Yaoc93afad2021-04-27 15:01:24 +0800494 err = parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6,
495 parse_state);
Wang Nan43d0b972016-02-19 11:44:01 +0000496 parse_events_terms__delete($6);
Ian Rogerscabbf262019-10-30 15:34:45 -0700497 free($1);
498 free($3);
499 free($5);
500 if (err) {
501 free_list_evsel(list);
502 YYABORT;
503 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200504 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100505}
506|
Wang Nan43d0b972016-02-19 11:44:01 +0000507PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100508{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300509 struct parse_events_state *parse_state = _parse_state;
510 struct parse_events_error *error = parse_state->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600511 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700512 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200513
Ian Rogersa26e4712019-10-22 17:53:32 -0700514 list = alloc_list();
515 ABORT_ON(!list);
Jin Yaoc93afad2021-04-27 15:01:24 +0800516 err = parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4,
517 parse_state);
Wang Nan43d0b972016-02-19 11:44:01 +0000518 parse_events_terms__delete($4);
Ian Rogerscabbf262019-10-30 15:34:45 -0700519 free($1);
520 free($3);
521 if (err) {
522 free_list_evsel(list);
523 YYABORT;
524 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200525 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100526}
527|
Wang Nan43d0b972016-02-19 11:44:01 +0000528PE_NAME_CACHE_TYPE opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100529{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300530 struct parse_events_state *parse_state = _parse_state;
531 struct parse_events_error *error = parse_state->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600532 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700533 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200534
Ian Rogersa26e4712019-10-22 17:53:32 -0700535 list = alloc_list();
536 ABORT_ON(!list);
Jin Yaoc93afad2021-04-27 15:01:24 +0800537 err = parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2,
538 parse_state);
Wang Nan43d0b972016-02-19 11:44:01 +0000539 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700540 free($1);
541 if (err) {
542 free_list_evsel(list);
543 YYABORT;
544 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200545 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100546}
547
548event_legacy_mem:
Jacob Shin3741eb92014-05-29 17:26:51 +0200549PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
550{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300551 struct parse_events_state *parse_state = _parse_state;
Jacob Shin3741eb92014-05-29 17:26:51 +0200552 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700553 int err;
Jacob Shin3741eb92014-05-29 17:26:51 +0200554
Ian Rogersa26e4712019-10-22 17:53:32 -0700555 list = alloc_list();
556 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700557 err = parse_events_add_breakpoint(list, &parse_state->idx,
Ian Rogersaa98d842020-09-24 17:39:03 -0700558 $2, $6, $4);
Ian Rogerscabbf262019-10-30 15:34:45 -0700559 free($6);
560 if (err) {
561 free(list);
562 YYABORT;
563 }
Jacob Shin3741eb92014-05-29 17:26:51 +0200564 $$ = list;
565}
566|
567PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
568{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300569 struct parse_events_state *parse_state = _parse_state;
Jacob Shin3741eb92014-05-29 17:26:51 +0200570 struct list_head *list;
571
Ian Rogersa26e4712019-10-22 17:53:32 -0700572 list = alloc_list();
573 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700574 if (parse_events_add_breakpoint(list, &parse_state->idx,
Ian Rogersaa98d842020-09-24 17:39:03 -0700575 $2, NULL, $4)) {
Ian Rogerscabbf262019-10-30 15:34:45 -0700576 free(list);
577 YYABORT;
578 }
Jacob Shin3741eb92014-05-29 17:26:51 +0200579 $$ = list;
580}
581|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100582PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
583{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300584 struct parse_events_state *parse_state = _parse_state;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600585 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700586 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200587
Ian Rogersa26e4712019-10-22 17:53:32 -0700588 list = alloc_list();
589 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700590 err = parse_events_add_breakpoint(list, &parse_state->idx,
Ian Rogersaa98d842020-09-24 17:39:03 -0700591 $2, $4, 0);
Ian Rogerscabbf262019-10-30 15:34:45 -0700592 free($4);
593 if (err) {
594 free(list);
595 YYABORT;
596 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200597 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100598}
599|
600PE_PREFIX_MEM PE_VALUE sep_dc
601{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300602 struct parse_events_state *parse_state = _parse_state;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600603 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200604
Ian Rogersa26e4712019-10-22 17:53:32 -0700605 list = alloc_list();
606 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700607 if (parse_events_add_breakpoint(list, &parse_state->idx,
Ian Rogersaa98d842020-09-24 17:39:03 -0700608 $2, NULL, 0)) {
Ian Rogerscabbf262019-10-30 15:34:45 -0700609 free(list);
610 YYABORT;
611 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200612 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100613}
614
615event_legacy_tracepoint:
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300616tracepoint_name opt_event_config
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200617{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300618 struct parse_events_state *parse_state = _parse_state;
619 struct parse_events_error *error = parse_state->error;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200620 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700621 int err;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200622
Ian Rogersa26e4712019-10-22 17:53:32 -0700623 list = alloc_list();
624 ABORT_ON(!list);
He Kuange637d172015-09-28 03:52:16 +0000625 if (error)
626 error->idx = @1.first_column;
627
Ian Rogerscabbf262019-10-30 15:34:45 -0700628 err = parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event,
629 error, $2);
He Kuange637d172015-09-28 03:52:16 +0000630
Ian Rogerscabbf262019-10-30 15:34:45 -0700631 parse_events_terms__delete($2);
632 free($1.sys);
633 free($1.event);
634 if (err) {
635 free(list);
Ian Rogerse1e9b782019-11-08 23:58:40 -0800636 YYABORT;
Ian Rogerscabbf262019-10-30 15:34:45 -0700637 }
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200638 $$ = list;
639}
He Kuang865582c2015-09-28 03:52:15 +0000640
641tracepoint_name:
642PE_NAME '-' PE_NAME ':' PE_NAME
643{
He Kuang865582c2015-09-28 03:52:15 +0000644 struct tracepoint_name tracepoint;
645
Ian Rogerscabbf262019-10-30 15:34:45 -0700646 ABORT_ON(asprintf(&tracepoint.sys, "%s-%s", $1, $3) < 0);
He Kuang865582c2015-09-28 03:52:15 +0000647 tracepoint.event = $5;
Ian Rogerscabbf262019-10-30 15:34:45 -0700648 free($1);
649 free($3);
He Kuang865582c2015-09-28 03:52:15 +0000650 $$ = tracepoint;
651}
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200652|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100653PE_NAME ':' PE_NAME
654{
He Kuang865582c2015-09-28 03:52:15 +0000655 struct tracepoint_name tracepoint = {$1, $3};
Jiri Olsab847cbd2012-05-21 09:12:51 +0200656
He Kuang865582c2015-09-28 03:52:15 +0000657 $$ = tracepoint;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100658}
659
660event_legacy_numeric:
Wang Nan10bf3582016-02-19 11:44:00 +0000661PE_VALUE ':' PE_VALUE opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100662{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600663 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700664 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200665
Ian Rogersa26e4712019-10-22 17:53:32 -0700666 list = alloc_list();
667 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700668 err = parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4);
Wang Nan10bf3582016-02-19 11:44:00 +0000669 parse_events_terms__delete($4);
Ian Rogerscabbf262019-10-30 15:34:45 -0700670 if (err) {
671 free(list);
672 YYABORT;
673 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200674 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100675}
676
677event_legacy_raw:
Wang Nan10bf3582016-02-19 11:44:00 +0000678PE_RAW opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100679{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600680 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700681 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200682
Ian Rogersa26e4712019-10-22 17:53:32 -0700683 list = alloc_list();
684 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700685 err = parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, $1, $2);
Wang Nan10bf3582016-02-19 11:44:00 +0000686 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700687 if (err) {
688 free(list);
689 YYABORT;
690 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200691 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100692}
693
Wang Nan84c86ca2015-10-14 12:41:14 +0000694event_bpf_file:
Wang Nana34f3be2016-02-22 09:10:31 +0000695PE_BPF_OBJECT opt_event_config
Wang Nan84c86ca2015-10-14 12:41:14 +0000696{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300697 struct parse_events_state *parse_state = _parse_state;
Wang Nan84c86ca2015-10-14 12:41:14 +0000698 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700699 int err;
Wang Nan84c86ca2015-10-14 12:41:14 +0000700
Ian Rogersa26e4712019-10-22 17:53:32 -0700701 list = alloc_list();
702 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700703 err = parse_events_load_bpf(parse_state, list, $1, false, $2);
Wang Nana34f3be2016-02-22 09:10:31 +0000704 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700705 free($1);
706 if (err) {
707 free(list);
708 YYABORT;
709 }
Wang Nand509db02015-10-14 12:41:20 +0000710 $$ = list;
711}
712|
Wang Nana34f3be2016-02-22 09:10:31 +0000713PE_BPF_SOURCE opt_event_config
Wang Nand509db02015-10-14 12:41:20 +0000714{
Wang Nand509db02015-10-14 12:41:20 +0000715 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700716 int err;
Wang Nand509db02015-10-14 12:41:20 +0000717
Ian Rogersa26e4712019-10-22 17:53:32 -0700718 list = alloc_list();
719 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700720 err = parse_events_load_bpf(_parse_state, list, $1, true, $2);
Wang Nana34f3be2016-02-22 09:10:31 +0000721 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700722 if (err) {
723 free(list);
724 YYABORT;
725 }
Wang Nan84c86ca2015-10-14 12:41:14 +0000726 $$ = list;
727}
728
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300729opt_event_config:
730'/' event_config '/'
731{
732 $$ = $2;
733}
734|
735'/' '/'
736{
737 $$ = NULL;
738}
739|
740{
741 $$ = NULL;
742}
743
Jiri Olsaceac7b72018-06-05 14:14:16 +0200744opt_pmu_config:
745'/' event_config '/'
746{
747 $$ = $2;
748}
749|
750'/' '/'
751{
752 $$ = NULL;
753}
754
Jiri Olsa89efb022012-08-08 12:14:14 +0200755start_terms: event_config
Jiri Olsa90e2b222012-06-15 14:31:40 +0800756{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300757 struct parse_events_state *parse_state = _parse_state;
Ian Rogerscabbf262019-10-30 15:34:45 -0700758 if (parse_state->terms) {
759 parse_events_terms__delete ($1);
760 YYABORT;
761 }
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300762 parse_state->terms = $1;
Jiri Olsa90e2b222012-06-15 14:31:40 +0800763}
764
Jiri Olsa8f707d82012-03-15 20:09:16 +0100765event_config:
766event_config ',' event_term
767{
768 struct list_head *head = $1;
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300769 struct parse_events_term *term = $3;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100770
Ian Rogerscabbf262019-10-30 15:34:45 -0700771 if (!head) {
Ian Rogers1dc92552019-10-30 15:34:47 -0700772 parse_events_term__delete(term);
Ian Rogerscabbf262019-10-30 15:34:45 -0700773 YYABORT;
774 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100775 list_add_tail(&term->list, head);
776 $$ = $1;
777}
778|
779event_term
780{
781 struct list_head *head = malloc(sizeof(*head));
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300782 struct parse_events_term *term = $1;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100783
784 ABORT_ON(!head);
785 INIT_LIST_HEAD(head);
786 list_add_tail(&term->list, head);
787 $$ = head;
788}
789
790event_term:
Jiri Olsa3a6c51e2020-04-17 00:14:05 +0200791PE_RAW
792{
793 struct parse_events_term *term;
794
795 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_CONFIG,
796 NULL, $1, false, &@1, NULL));
797 $$ = term;
798}
799|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100800PE_NAME '=' PE_NAME
801{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300802 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100803
Ian Rogerscabbf262019-10-30 15:34:45 -0700804 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
805 $1, $3, &@1, &@3)) {
806 free($1);
807 free($3);
808 YYABORT;
809 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100810 $$ = term;
811}
812|
813PE_NAME '=' PE_VALUE
814{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300815 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100816
Ian Rogerscabbf262019-10-30 15:34:45 -0700817 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
818 $1, $3, false, &@1, &@3)) {
819 free($1);
820 YYABORT;
821 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100822 $$ = term;
823}
824|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200825PE_NAME '=' PE_VALUE_SYM_HW
826{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300827 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200828 int config = $3 & 255;
829
Ian Rogerscabbf262019-10-30 15:34:45 -0700830 if (parse_events_term__sym_hw(&term, $1, config)) {
831 free($1);
832 YYABORT;
833 }
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200834 $$ = term;
835}
836|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100837PE_NAME
838{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300839 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100840
Ian Rogerscabbf262019-10-30 15:34:45 -0700841 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
842 $1, 1, true, &@1, NULL)) {
843 free($1);
844 YYABORT;
845 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100846 $$ = term;
847}
848|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200849PE_VALUE_SYM_HW
850{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300851 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200852 int config = $1 & 255;
853
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300854 ABORT_ON(parse_events_term__sym_hw(&term, NULL, config));
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200855 $$ = term;
856}
857|
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200858PE_TERM '=' PE_NAME
859{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300860 struct parse_events_term *term;
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200861
Ian Rogerscabbf262019-10-30 15:34:45 -0700862 if (parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3)) {
863 free($3);
864 YYABORT;
865 }
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200866 $$ = term;
867}
868|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100869PE_TERM '=' PE_VALUE
870{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300871 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100872
Jiri Olsa99e71382017-02-17 15:00:56 +0100873 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, false, &@1, &@3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100874 $$ = term;
875}
876|
877PE_TERM
878{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300879 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100880
Jiri Olsa99e71382017-02-17 15:00:56 +0100881 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, true, &@1, NULL));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100882 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100883}
Wang Nane571e022016-02-22 09:10:35 +0000884|
885PE_NAME array '=' PE_NAME
886{
887 struct parse_events_term *term;
Wang Nane571e022016-02-22 09:10:35 +0000888
Ian Rogerscabbf262019-10-30 15:34:45 -0700889 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
890 $1, $4, &@1, &@4)) {
891 free($1);
892 free($4);
893 free($2.ranges);
894 YYABORT;
895 }
Wang Nane571e022016-02-22 09:10:35 +0000896 term->array = $2;
897 $$ = term;
898}
899|
900PE_NAME array '=' PE_VALUE
901{
902 struct parse_events_term *term;
903
Ian Rogerscabbf262019-10-30 15:34:45 -0700904 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
905 $1, $4, false, &@1, &@4)) {
906 free($1);
907 free($2.ranges);
908 YYABORT;
909 }
Wang Nane571e022016-02-22 09:10:35 +0000910 term->array = $2;
911 $$ = term;
912}
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600913|
914PE_DRV_CFG_TERM
915{
916 struct parse_events_term *term;
Ian Rogersb6645a72019-10-30 15:34:43 -0700917 char *config = strdup($1);
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600918
Ian Rogersb6645a72019-10-30 15:34:43 -0700919 ABORT_ON(!config);
Ian Rogerscabbf262019-10-30 15:34:45 -0700920 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG,
921 config, $1, &@1, NULL)) {
922 free($1);
923 free(config);
924 YYABORT;
925 }
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600926 $$ = term;
927}
Wang Nane571e022016-02-22 09:10:35 +0000928
929array:
930'[' array_terms ']'
931{
932 $$ = $2;
933}
934|
935PE_ARRAY_ALL
936{
937 $$.nr_ranges = 0;
938 $$.ranges = NULL;
939}
940
941array_terms:
942array_terms ',' array_term
943{
944 struct parse_events_array new_array;
945
946 new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges;
Ian Rogers826100a2019-10-22 17:53:33 -0700947 new_array.ranges = realloc($1.ranges,
948 sizeof(new_array.ranges[0]) *
949 new_array.nr_ranges);
Wang Nane571e022016-02-22 09:10:35 +0000950 ABORT_ON(!new_array.ranges);
Wang Nane571e022016-02-22 09:10:35 +0000951 memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges,
952 $3.nr_ranges * sizeof(new_array.ranges[0]));
Wang Nane571e022016-02-22 09:10:35 +0000953 free($3.ranges);
954 $$ = new_array;
955}
956|
957array_term
958
959array_term:
960PE_VALUE
961{
962 struct parse_events_array array;
963
964 array.nr_ranges = 1;
965 array.ranges = malloc(sizeof(array.ranges[0]));
966 ABORT_ON(!array.ranges);
967 array.ranges[0].start = $1;
968 array.ranges[0].length = 1;
969 $$ = array;
970}
971|
972PE_VALUE PE_ARRAY_RANGE PE_VALUE
973{
974 struct parse_events_array array;
975
976 ABORT_ON($3 < $1);
977 array.nr_ranges = 1;
978 array.ranges = malloc(sizeof(array.ranges[0]));
979 ABORT_ON(!array.ranges);
980 array.ranges[0].start = $1;
981 array.ranges[0].length = $3 - $1 + 1;
982 $$ = array;
983}
Jiri Olsa89812fc2012-03-15 20:09:15 +0100984
985sep_dc: ':' |
986
Jiri Olsa714a92d2019-02-13 13:32:40 +0100987sep_slash_slash_dc: '/' '/' | ':' |
Jiri Olsa8f707d82012-03-15 20:09:16 +0100988
Jiri Olsa89812fc2012-03-15 20:09:15 +0100989%%
990
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300991void parse_events_error(YYLTYPE *loc, void *parse_state,
Jiri Olsa6297d422015-04-22 21:10:17 +0200992 void *scanner __maybe_unused,
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300993 char const *msg __maybe_unused)
Jiri Olsa89812fc2012-03-15 20:09:15 +0100994{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300995 parse_events_evlist_error(parse_state, loc->last_column, "parser error");
Jiri Olsa89812fc2012-03-15 20:09:15 +0100996}