blob: c4ca932d092d8d29f588e6aa33c5990f786c7217 [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 Rogersba088292020-03-18 19:31:00 -0700329 free(pattern);
Ian Rogerscabbf262019-10-30 15:34:45 -0700330 free($1);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200331 $$ = list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700332#undef CLEANUP_YYABORT
Jiri Olsa5f537a22012-03-15 20:09:18 +0100333}
Adrian Hunterad962272014-08-15 22:08:40 +0300334|
Kan Liangba32a452014-10-07 11:08:51 -0400335PE_KERNEL_PMU_EVENT sep_dc
336{
Kan Liangba32a452014-10-07 11:08:51 -0400337 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700338 int err;
Kan Liangba32a452014-10-07 11:08:51 -0400339
Ian Rogerscabbf262019-10-30 15:34:45 -0700340 err = parse_events_multi_pmu_add(_parse_state, $1, &list);
341 free($1);
342 if (err < 0)
Andi Kleen231bb2a2017-01-27 18:03:39 -0800343 YYABORT;
Kan Liangba32a452014-10-07 11:08:51 -0400344 $$ = list;
345}
346|
347PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
348{
Kan Liangba32a452014-10-07 11:08:51 -0400349 struct list_head *list;
350 char pmu_name[128];
Andi Kleen82557182017-03-20 13:17:03 -0700351
Kan Liangba32a452014-10-07 11:08:51 -0400352 snprintf(&pmu_name, 128, "%s-%s", $1, $3);
Ian Rogerscabbf262019-10-30 15:34:45 -0700353 free($1);
354 free($3);
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300355 if (parse_events_multi_pmu_add(_parse_state, pmu_name, &list) < 0)
Andi Kleen82557182017-03-20 13:17:03 -0700356 YYABORT;
Kan Liangba32a452014-10-07 11:08:51 -0400357 $$ = list;
358}
Jiri Olsa5f537a22012-03-15 20:09:18 +0100359
Jiri Olsacf3506d2012-07-04 00:00:43 +0200360value_sym:
361PE_VALUE_SYM_HW
362|
363PE_VALUE_SYM_SW
364
Jiri Olsa89812fc2012-03-15 20:09:15 +0100365event_legacy_symbol:
Jiri Olsacf3506d2012-07-04 00:00:43 +0200366value_sym '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +0100367{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600368 struct list_head *list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100369 int type = $1 >> 16;
370 int config = $1 & 255;
Ian Rogerscabbf262019-10-30 15:34:45 -0700371 int err;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100372
Ian Rogersa26e4712019-10-22 17:53:32 -0700373 list = alloc_list();
374 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700375 err = parse_events_add_numeric(_parse_state, list, type, config, $3);
Arnaldo Carvalho de Melo2146afc2016-02-12 17:09:17 -0300376 parse_events_terms__delete($3);
Ian Rogerscabbf262019-10-30 15:34:45 -0700377 if (err) {
378 free_list_evsel(list);
379 YYABORT;
380 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200381 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100382}
383|
Jiri Olsa714a92d2019-02-13 13:32:40 +0100384value_sym sep_slash_slash_dc
Jiri Olsa8f707d82012-03-15 20:09:16 +0100385{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600386 struct list_head *list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100387 int type = $1 >> 16;
388 int config = $1 & 255;
389
Ian Rogersa26e4712019-10-22 17:53:32 -0700390 list = alloc_list();
391 ABORT_ON(!list);
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300392 ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200393 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100394}
Andi Kleenf0fbb112019-03-26 15:18:21 -0700395|
396PE_VALUE_SYM_TOOL sep_slash_slash_dc
397{
398 struct list_head *list;
399
Ian Rogersa26e4712019-10-22 17:53:32 -0700400 list = alloc_list();
401 ABORT_ON(!list);
Andi Kleenf0fbb112019-03-26 15:18:21 -0700402 ABORT_ON(parse_events_add_tool(_parse_state, list, $1));
403 $$ = list;
404}
Jiri Olsa89812fc2012-03-15 20:09:15 +0100405
406event_legacy_cache:
Wang Nan43d0b972016-02-19 11:44:01 +0000407PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100408{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300409 struct parse_events_state *parse_state = _parse_state;
410 struct parse_events_error *error = parse_state->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600411 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700412 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200413
Ian Rogersa26e4712019-10-22 17:53:32 -0700414 list = alloc_list();
415 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700416 err = parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6);
Wang Nan43d0b972016-02-19 11:44:01 +0000417 parse_events_terms__delete($6);
Ian Rogerscabbf262019-10-30 15:34:45 -0700418 free($1);
419 free($3);
420 free($5);
421 if (err) {
422 free_list_evsel(list);
423 YYABORT;
424 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200425 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100426}
427|
Wang Nan43d0b972016-02-19 11:44:01 +0000428PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100429{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300430 struct parse_events_state *parse_state = _parse_state;
431 struct parse_events_error *error = parse_state->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600432 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700433 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200434
Ian Rogersa26e4712019-10-22 17:53:32 -0700435 list = alloc_list();
436 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700437 err = parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4);
Wang Nan43d0b972016-02-19 11:44:01 +0000438 parse_events_terms__delete($4);
Ian Rogerscabbf262019-10-30 15:34:45 -0700439 free($1);
440 free($3);
441 if (err) {
442 free_list_evsel(list);
443 YYABORT;
444 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200445 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100446}
447|
Wang Nan43d0b972016-02-19 11:44:01 +0000448PE_NAME_CACHE_TYPE opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100449{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300450 struct parse_events_state *parse_state = _parse_state;
451 struct parse_events_error *error = parse_state->error;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600452 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700453 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200454
Ian Rogersa26e4712019-10-22 17:53:32 -0700455 list = alloc_list();
456 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700457 err = parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2);
Wang Nan43d0b972016-02-19 11:44:01 +0000458 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700459 free($1);
460 if (err) {
461 free_list_evsel(list);
462 YYABORT;
463 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200464 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100465}
466
467event_legacy_mem:
Jacob Shin3741eb92014-05-29 17:26:51 +0200468PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
469{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300470 struct parse_events_state *parse_state = _parse_state;
Jacob Shin3741eb92014-05-29 17:26:51 +0200471 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700472 int err;
Jacob Shin3741eb92014-05-29 17:26:51 +0200473
Ian Rogersa26e4712019-10-22 17:53:32 -0700474 list = alloc_list();
475 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700476 err = parse_events_add_breakpoint(list, &parse_state->idx,
477 (void *) $2, $6, $4);
478 free($6);
479 if (err) {
480 free(list);
481 YYABORT;
482 }
Jacob Shin3741eb92014-05-29 17:26:51 +0200483 $$ = list;
484}
485|
486PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
487{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300488 struct parse_events_state *parse_state = _parse_state;
Jacob Shin3741eb92014-05-29 17:26:51 +0200489 struct list_head *list;
490
Ian Rogersa26e4712019-10-22 17:53:32 -0700491 list = alloc_list();
492 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700493 if (parse_events_add_breakpoint(list, &parse_state->idx,
494 (void *) $2, NULL, $4)) {
495 free(list);
496 YYABORT;
497 }
Jacob Shin3741eb92014-05-29 17:26:51 +0200498 $$ = list;
499}
500|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100501PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
502{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300503 struct parse_events_state *parse_state = _parse_state;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600504 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700505 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200506
Ian Rogersa26e4712019-10-22 17:53:32 -0700507 list = alloc_list();
508 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700509 err = parse_events_add_breakpoint(list, &parse_state->idx,
510 (void *) $2, $4, 0);
511 free($4);
512 if (err) {
513 free(list);
514 YYABORT;
515 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200516 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100517}
518|
519PE_PREFIX_MEM PE_VALUE sep_dc
520{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300521 struct parse_events_state *parse_state = _parse_state;
David Ahernc5cd8ac2013-07-02 13:27:25 -0600522 struct list_head *list;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200523
Ian Rogersa26e4712019-10-22 17:53:32 -0700524 list = alloc_list();
525 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700526 if (parse_events_add_breakpoint(list, &parse_state->idx,
527 (void *) $2, NULL, 0)) {
528 free(list);
529 YYABORT;
530 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200531 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100532}
533
534event_legacy_tracepoint:
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300535tracepoint_name opt_event_config
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200536{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300537 struct parse_events_state *parse_state = _parse_state;
538 struct parse_events_error *error = parse_state->error;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200539 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700540 int err;
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200541
Ian Rogersa26e4712019-10-22 17:53:32 -0700542 list = alloc_list();
543 ABORT_ON(!list);
He Kuange637d172015-09-28 03:52:16 +0000544 if (error)
545 error->idx = @1.first_column;
546
Ian Rogerscabbf262019-10-30 15:34:45 -0700547 err = parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event,
548 error, $2);
He Kuange637d172015-09-28 03:52:16 +0000549
Ian Rogerscabbf262019-10-30 15:34:45 -0700550 parse_events_terms__delete($2);
551 free($1.sys);
552 free($1.event);
553 if (err) {
554 free(list);
Ian Rogerse1e9b782019-11-08 23:58:40 -0800555 YYABORT;
Ian Rogerscabbf262019-10-30 15:34:45 -0700556 }
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200557 $$ = list;
558}
He Kuang865582c2015-09-28 03:52:15 +0000559
560tracepoint_name:
561PE_NAME '-' PE_NAME ':' PE_NAME
562{
He Kuang865582c2015-09-28 03:52:15 +0000563 struct tracepoint_name tracepoint;
564
Ian Rogerscabbf262019-10-30 15:34:45 -0700565 ABORT_ON(asprintf(&tracepoint.sys, "%s-%s", $1, $3) < 0);
He Kuang865582c2015-09-28 03:52:15 +0000566 tracepoint.event = $5;
Ian Rogerscabbf262019-10-30 15:34:45 -0700567 free($1);
568 free($3);
He Kuang865582c2015-09-28 03:52:15 +0000569 $$ = tracepoint;
570}
Alexander Yarygin2b9032e2014-04-25 17:34:05 +0200571|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100572PE_NAME ':' PE_NAME
573{
He Kuang865582c2015-09-28 03:52:15 +0000574 struct tracepoint_name tracepoint = {$1, $3};
Jiri Olsab847cbd2012-05-21 09:12:51 +0200575
He Kuang865582c2015-09-28 03:52:15 +0000576 $$ = tracepoint;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100577}
578
579event_legacy_numeric:
Wang Nan10bf3582016-02-19 11:44:00 +0000580PE_VALUE ':' PE_VALUE opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100581{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600582 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700583 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200584
Ian Rogersa26e4712019-10-22 17:53:32 -0700585 list = alloc_list();
586 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700587 err = parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4);
Wang Nan10bf3582016-02-19 11:44:00 +0000588 parse_events_terms__delete($4);
Ian Rogerscabbf262019-10-30 15:34:45 -0700589 if (err) {
590 free(list);
591 YYABORT;
592 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200593 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100594}
595
596event_legacy_raw:
Wang Nan10bf3582016-02-19 11:44:00 +0000597PE_RAW opt_event_config
Jiri Olsa89812fc2012-03-15 20:09:15 +0100598{
David Ahernc5cd8ac2013-07-02 13:27:25 -0600599 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700600 int err;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200601
Ian Rogersa26e4712019-10-22 17:53:32 -0700602 list = alloc_list();
603 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700604 err = parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, $1, $2);
Wang Nan10bf3582016-02-19 11:44:00 +0000605 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700606 if (err) {
607 free(list);
608 YYABORT;
609 }
Jiri Olsab847cbd2012-05-21 09:12:51 +0200610 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100611}
612
Wang Nan84c86ca2015-10-14 12:41:14 +0000613event_bpf_file:
Wang Nana34f3be2016-02-22 09:10:31 +0000614PE_BPF_OBJECT opt_event_config
Wang Nan84c86ca2015-10-14 12:41:14 +0000615{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300616 struct parse_events_state *parse_state = _parse_state;
Wang Nan84c86ca2015-10-14 12:41:14 +0000617 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700618 int err;
Wang Nan84c86ca2015-10-14 12:41:14 +0000619
Ian Rogersa26e4712019-10-22 17:53:32 -0700620 list = alloc_list();
621 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700622 err = parse_events_load_bpf(parse_state, list, $1, false, $2);
Wang Nana34f3be2016-02-22 09:10:31 +0000623 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700624 free($1);
625 if (err) {
626 free(list);
627 YYABORT;
628 }
Wang Nand509db02015-10-14 12:41:20 +0000629 $$ = list;
630}
631|
Wang Nana34f3be2016-02-22 09:10:31 +0000632PE_BPF_SOURCE opt_event_config
Wang Nand509db02015-10-14 12:41:20 +0000633{
Wang Nand509db02015-10-14 12:41:20 +0000634 struct list_head *list;
Ian Rogerscabbf262019-10-30 15:34:45 -0700635 int err;
Wang Nand509db02015-10-14 12:41:20 +0000636
Ian Rogersa26e4712019-10-22 17:53:32 -0700637 list = alloc_list();
638 ABORT_ON(!list);
Ian Rogerscabbf262019-10-30 15:34:45 -0700639 err = parse_events_load_bpf(_parse_state, list, $1, true, $2);
Wang Nana34f3be2016-02-22 09:10:31 +0000640 parse_events_terms__delete($2);
Ian Rogerscabbf262019-10-30 15:34:45 -0700641 if (err) {
642 free(list);
643 YYABORT;
644 }
Wang Nan84c86ca2015-10-14 12:41:14 +0000645 $$ = list;
646}
647
Arnaldo Carvalho de Melo1d55e8e2016-02-19 18:45:12 -0300648opt_event_config:
649'/' event_config '/'
650{
651 $$ = $2;
652}
653|
654'/' '/'
655{
656 $$ = NULL;
657}
658|
659{
660 $$ = NULL;
661}
662
Jiri Olsaceac7b72018-06-05 14:14:16 +0200663opt_pmu_config:
664'/' event_config '/'
665{
666 $$ = $2;
667}
668|
669'/' '/'
670{
671 $$ = NULL;
672}
673
Jiri Olsa89efb022012-08-08 12:14:14 +0200674start_terms: event_config
Jiri Olsa90e2b222012-06-15 14:31:40 +0800675{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300676 struct parse_events_state *parse_state = _parse_state;
Ian Rogerscabbf262019-10-30 15:34:45 -0700677 if (parse_state->terms) {
678 parse_events_terms__delete ($1);
679 YYABORT;
680 }
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300681 parse_state->terms = $1;
Jiri Olsa90e2b222012-06-15 14:31:40 +0800682}
683
Jiri Olsa8f707d82012-03-15 20:09:16 +0100684event_config:
685event_config ',' event_term
686{
687 struct list_head *head = $1;
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300688 struct parse_events_term *term = $3;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100689
Ian Rogerscabbf262019-10-30 15:34:45 -0700690 if (!head) {
Ian Rogers1dc92552019-10-30 15:34:47 -0700691 parse_events_term__delete(term);
Ian Rogerscabbf262019-10-30 15:34:45 -0700692 YYABORT;
693 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100694 list_add_tail(&term->list, head);
695 $$ = $1;
696}
697|
698event_term
699{
700 struct list_head *head = malloc(sizeof(*head));
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300701 struct parse_events_term *term = $1;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100702
703 ABORT_ON(!head);
704 INIT_LIST_HEAD(head);
705 list_add_tail(&term->list, head);
706 $$ = head;
707}
708
709event_term:
Jiri Olsa3a6c51e2020-04-17 00:14:05 +0200710PE_RAW
711{
712 struct parse_events_term *term;
713
714 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_CONFIG,
715 NULL, $1, false, &@1, NULL));
716 $$ = term;
717}
718|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100719PE_NAME '=' PE_NAME
720{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300721 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100722
Ian Rogerscabbf262019-10-30 15:34:45 -0700723 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
724 $1, $3, &@1, &@3)) {
725 free($1);
726 free($3);
727 YYABORT;
728 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100729 $$ = term;
730}
731|
732PE_NAME '=' PE_VALUE
733{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300734 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100735
Ian Rogerscabbf262019-10-30 15:34:45 -0700736 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
737 $1, $3, false, &@1, &@3)) {
738 free($1);
739 YYABORT;
740 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100741 $$ = term;
742}
743|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200744PE_NAME '=' PE_VALUE_SYM_HW
745{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300746 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200747 int config = $3 & 255;
748
Ian Rogerscabbf262019-10-30 15:34:45 -0700749 if (parse_events_term__sym_hw(&term, $1, config)) {
750 free($1);
751 YYABORT;
752 }
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200753 $$ = term;
754}
755|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100756PE_NAME
757{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300758 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100759
Ian Rogerscabbf262019-10-30 15:34:45 -0700760 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
761 $1, 1, true, &@1, NULL)) {
762 free($1);
763 YYABORT;
764 }
Jiri Olsa8f707d82012-03-15 20:09:16 +0100765 $$ = term;
766}
767|
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200768PE_VALUE_SYM_HW
769{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300770 struct parse_events_term *term;
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200771 int config = $1 & 255;
772
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300773 ABORT_ON(parse_events_term__sym_hw(&term, NULL, config));
Jiri Olsa1d33d6d2012-10-10 14:53:17 +0200774 $$ = term;
775}
776|
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200777PE_TERM '=' PE_NAME
778{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300779 struct parse_events_term *term;
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200780
Ian Rogerscabbf262019-10-30 15:34:45 -0700781 if (parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3)) {
782 free($3);
783 YYABORT;
784 }
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200785 $$ = term;
786}
787|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100788PE_TERM '=' PE_VALUE
789{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300790 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100791
Jiri Olsa99e71382017-02-17 15:00:56 +0100792 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, false, &@1, &@3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100793 $$ = term;
794}
795|
796PE_TERM
797{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300798 struct parse_events_term *term;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100799
Jiri Olsa99e71382017-02-17 15:00:56 +0100800 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, true, &@1, NULL));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100801 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100802}
Wang Nane571e022016-02-22 09:10:35 +0000803|
804PE_NAME array '=' PE_NAME
805{
806 struct parse_events_term *term;
Wang Nane571e022016-02-22 09:10:35 +0000807
Ian Rogerscabbf262019-10-30 15:34:45 -0700808 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
809 $1, $4, &@1, &@4)) {
810 free($1);
811 free($4);
812 free($2.ranges);
813 YYABORT;
814 }
Wang Nane571e022016-02-22 09:10:35 +0000815 term->array = $2;
816 $$ = term;
817}
818|
819PE_NAME array '=' PE_VALUE
820{
821 struct parse_events_term *term;
822
Ian Rogerscabbf262019-10-30 15:34:45 -0700823 if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
824 $1, $4, false, &@1, &@4)) {
825 free($1);
826 free($2.ranges);
827 YYABORT;
828 }
Wang Nane571e022016-02-22 09:10:35 +0000829 term->array = $2;
830 $$ = term;
831}
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600832|
833PE_DRV_CFG_TERM
834{
835 struct parse_events_term *term;
Ian Rogersb6645a72019-10-30 15:34:43 -0700836 char *config = strdup($1);
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600837
Ian Rogersb6645a72019-10-30 15:34:43 -0700838 ABORT_ON(!config);
Ian Rogerscabbf262019-10-30 15:34:45 -0700839 if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG,
840 config, $1, &@1, NULL)) {
841 free($1);
842 free(config);
843 YYABORT;
844 }
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600845 $$ = term;
846}
Wang Nane571e022016-02-22 09:10:35 +0000847
848array:
849'[' array_terms ']'
850{
851 $$ = $2;
852}
853|
854PE_ARRAY_ALL
855{
856 $$.nr_ranges = 0;
857 $$.ranges = NULL;
858}
859
860array_terms:
861array_terms ',' array_term
862{
863 struct parse_events_array new_array;
864
865 new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges;
Ian Rogers826100a2019-10-22 17:53:33 -0700866 new_array.ranges = realloc($1.ranges,
867 sizeof(new_array.ranges[0]) *
868 new_array.nr_ranges);
Wang Nane571e022016-02-22 09:10:35 +0000869 ABORT_ON(!new_array.ranges);
Wang Nane571e022016-02-22 09:10:35 +0000870 memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges,
871 $3.nr_ranges * sizeof(new_array.ranges[0]));
Wang Nane571e022016-02-22 09:10:35 +0000872 free($3.ranges);
873 $$ = new_array;
874}
875|
876array_term
877
878array_term:
879PE_VALUE
880{
881 struct parse_events_array array;
882
883 array.nr_ranges = 1;
884 array.ranges = malloc(sizeof(array.ranges[0]));
885 ABORT_ON(!array.ranges);
886 array.ranges[0].start = $1;
887 array.ranges[0].length = 1;
888 $$ = array;
889}
890|
891PE_VALUE PE_ARRAY_RANGE PE_VALUE
892{
893 struct parse_events_array array;
894
895 ABORT_ON($3 < $1);
896 array.nr_ranges = 1;
897 array.ranges = malloc(sizeof(array.ranges[0]));
898 ABORT_ON(!array.ranges);
899 array.ranges[0].start = $1;
900 array.ranges[0].length = $3 - $1 + 1;
901 $$ = array;
902}
Jiri Olsa89812fc2012-03-15 20:09:15 +0100903
904sep_dc: ':' |
905
Jiri Olsa714a92d2019-02-13 13:32:40 +0100906sep_slash_slash_dc: '/' '/' | ':' |
Jiri Olsa8f707d82012-03-15 20:09:16 +0100907
Jiri Olsa89812fc2012-03-15 20:09:15 +0100908%%
909
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300910void parse_events_error(YYLTYPE *loc, void *parse_state,
Jiri Olsa6297d422015-04-22 21:10:17 +0200911 void *scanner __maybe_unused,
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300912 char const *msg __maybe_unused)
Jiri Olsa89812fc2012-03-15 20:09:15 +0100913{
Arnaldo Carvalho de Melo5d9cdc12017-08-17 16:13:34 -0300914 parse_events_evlist_error(parse_state, loc->last_column, "parser error");
Jiri Olsa89812fc2012-03-15 20:09:15 +0100915}