1fc8c0a99SJiri Olsa %define api.pure full 25d9cdc11SArnaldo Carvalho de Melo %parse-param {void *_parse_state} 3ac20de6fSZheng Yan %parse-param {void *scanner} 4ac20de6fSZheng Yan %lex-param {void* scanner} 56297d423SJiri Olsa %locations 689812fc8SJiri Olsa 789812fc8SJiri Olsa %{ 889812fc8SJiri Olsa 989812fc8SJiri Olsa #define YYDEBUG 1 1089812fc8SJiri Olsa 11b2b9d3a3SAgustin Vega-Frias #include <fnmatch.h> 12bd704620SArnaldo Carvalho de Melo #include <stdio.h> 1389812fc8SJiri Olsa #include <linux/compiler.h> 14d944c4eeSBorislav Petkov #include <linux/types.h> 15f2a8ecd8SIan Rogers #include <linux/zalloc.h> 16231bb2aaSAndi Kleen #include "pmu.h" 17f0fbb114SAndi Kleen #include "evsel.h" 1889812fc8SJiri Olsa #include "parse-events.h" 19ac20de6fSZheng Yan #include "parse-events-bison.h" 2089812fc8SJiri Olsa 215d9cdc11SArnaldo Carvalho de Melo void parse_events_error(YYLTYPE *loc, void *parse_state, void *scanner, char const *msg); 2234a0548fSArnaldo Carvalho de Melo 2389812fc8SJiri Olsa #define ABORT_ON(val) \ 2489812fc8SJiri Olsa do { \ 2589812fc8SJiri Olsa if (val) \ 2689812fc8SJiri Olsa YYABORT; \ 2789812fc8SJiri Olsa } while (0) 2889812fc8SJiri Olsa 29*ffaecd7dSIan Rogers static struct list_head* alloc_list(void) 30a26e4716SIan Rogers { 31a26e4716SIan Rogers struct list_head *list; 32a26e4716SIan Rogers 33a26e4716SIan Rogers list = malloc(sizeof(*list)); 34a26e4716SIan Rogers if (!list) 35a26e4716SIan Rogers return NULL; 36a26e4716SIan Rogers 37a26e4716SIan Rogers INIT_LIST_HEAD(list); 38a26e4716SIan Rogers return list; 39a26e4716SIan Rogers } 40c5cd8ac0SDavid Ahern 41f2a8ecd8SIan Rogers static void free_list_evsel(struct list_head* list_evsel) 42f2a8ecd8SIan Rogers { 43f2a8ecd8SIan Rogers struct evsel *evsel, *tmp; 44f2a8ecd8SIan Rogers 45f2a8ecd8SIan Rogers list_for_each_entry_safe(evsel, tmp, list_evsel, core.node) { 46f2a8ecd8SIan Rogers list_del_init(&evsel->core.node); 47672f707eSIan Rogers evsel__delete(evsel); 48f2a8ecd8SIan Rogers } 49f2a8ecd8SIan Rogers free(list_evsel); 50f2a8ecd8SIan Rogers } 51f2a8ecd8SIan Rogers 5207ef7574SColin Ian King static void inc_group_count(struct list_head *list, 535d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state) 5497f63e4aSNamhyung Kim { 5597f63e4aSNamhyung Kim /* Count groups only have more than 1 members */ 5697f63e4aSNamhyung Kim if (!list_is_last(list->next, list)) 575d9cdc11SArnaldo Carvalho de Melo parse_state->nr_groups++; 5897f63e4aSNamhyung Kim } 5997f63e4aSNamhyung Kim 6089812fc8SJiri Olsa %} 6189812fc8SJiri Olsa 6290e2b22dSJiri Olsa %token PE_START_EVENTS PE_START_TERMS 63cf3506dcSJiri Olsa %token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM 64f0fbb114SAndi Kleen %token PE_VALUE_SYM_TOOL 65ac2ba9f3SRobert Richter %token PE_EVENT_NAME 6689812fc8SJiri Olsa %token PE_NAME 67d509db04SWang Nan %token PE_BPF_OBJECT PE_BPF_SOURCE 6889812fc8SJiri Olsa %token PE_MODIFIER_EVENT PE_MODIFIER_BP 6989812fc8SJiri Olsa %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT 7089efb029SJiri Olsa %token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP 7189812fc8SJiri Olsa %token PE_ERROR 72ba32a451SKan Liang %token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT 73e571e029SWang Nan %token PE_ARRAY_ALL PE_ARRAY_RANGE 74dd60fba7SMathieu Poirier %token PE_DRV_CFG_TERM 7589812fc8SJiri Olsa %type <num> PE_VALUE 76cf3506dcSJiri Olsa %type <num> PE_VALUE_SYM_HW 77cf3506dcSJiri Olsa %type <num> PE_VALUE_SYM_SW 78f0fbb114SAndi Kleen %type <num> PE_VALUE_SYM_TOOL 7989812fc8SJiri Olsa %type <num> PE_RAW 808f707d84SJiri Olsa %type <num> PE_TERM 81f2a8ecd8SIan Rogers %type <num> value_sym 8289812fc8SJiri Olsa %type <str> PE_NAME 8384c86ca1SWang Nan %type <str> PE_BPF_OBJECT 84d509db04SWang Nan %type <str> PE_BPF_SOURCE 8589812fc8SJiri Olsa %type <str> PE_NAME_CACHE_TYPE 8689812fc8SJiri Olsa %type <str> PE_NAME_CACHE_OP_RESULT 8789812fc8SJiri Olsa %type <str> PE_MODIFIER_EVENT 8889812fc8SJiri Olsa %type <str> PE_MODIFIER_BP 89ac2ba9f3SRobert Richter %type <str> PE_EVENT_NAME 90ba32a451SKan Liang %type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT 91dd60fba7SMathieu Poirier %type <str> PE_DRV_CFG_TERM 92f2a8ecd8SIan Rogers %destructor { free ($$); } <str> 938f707d84SJiri Olsa %type <term> event_term 941dc92556SIan Rogers %destructor { parse_events_term__delete ($$); } <term> 95f2a8ecd8SIan Rogers %type <list_terms> event_config 96f2a8ecd8SIan Rogers %type <list_terms> opt_event_config 97f2a8ecd8SIan Rogers %type <list_terms> opt_pmu_config 98f2a8ecd8SIan Rogers %destructor { parse_events_terms__delete ($$); } <list_terms> 99f2a8ecd8SIan Rogers %type <list_evsel> event_pmu 100f2a8ecd8SIan Rogers %type <list_evsel> event_legacy_symbol 101f2a8ecd8SIan Rogers %type <list_evsel> event_legacy_cache 102f2a8ecd8SIan Rogers %type <list_evsel> event_legacy_mem 103f2a8ecd8SIan Rogers %type <list_evsel> event_legacy_tracepoint 104f2a8ecd8SIan Rogers %type <list_evsel> event_legacy_numeric 105f2a8ecd8SIan Rogers %type <list_evsel> event_legacy_raw 106f2a8ecd8SIan Rogers %type <list_evsel> event_bpf_file 107f2a8ecd8SIan Rogers %type <list_evsel> event_def 108f2a8ecd8SIan Rogers %type <list_evsel> event_mod 109f2a8ecd8SIan Rogers %type <list_evsel> event_name 110f2a8ecd8SIan Rogers %type <list_evsel> event 111f2a8ecd8SIan Rogers %type <list_evsel> events 112f2a8ecd8SIan Rogers %type <list_evsel> group_def 113f2a8ecd8SIan Rogers %type <list_evsel> group 114f2a8ecd8SIan Rogers %type <list_evsel> groups 115f2a8ecd8SIan Rogers %destructor { free_list_evsel ($$); } <list_evsel> 116865582c3SHe Kuang %type <tracepoint_name> tracepoint_name 117f2a8ecd8SIan Rogers %destructor { free ($$.sys); free ($$.event); } <tracepoint_name> 118e571e029SWang Nan %type <array> array 119e571e029SWang Nan %type <array> array_term 120e571e029SWang Nan %type <array> array_terms 121f2a8ecd8SIan Rogers %destructor { free ($$.ranges); } <array> 12289812fc8SJiri Olsa 12389812fc8SJiri Olsa %union 12489812fc8SJiri Olsa { 12589812fc8SJiri Olsa char *str; 126b527bab5SRobert Richter u64 num; 127f2a8ecd8SIan Rogers struct list_head *list_evsel; 128f2a8ecd8SIan Rogers struct list_head *list_terms; 1296cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 130865582c3SHe Kuang struct tracepoint_name { 131865582c3SHe Kuang char *sys; 132865582c3SHe Kuang char *event; 133865582c3SHe Kuang } tracepoint_name; 134e571e029SWang Nan struct parse_events_array array; 13589812fc8SJiri Olsa } 13689812fc8SJiri Olsa %% 13789812fc8SJiri Olsa 13890e2b22dSJiri Olsa start: 13989efb029SJiri Olsa PE_START_EVENTS start_events 14090e2b22dSJiri Olsa | 14189efb029SJiri Olsa PE_START_TERMS start_terms 14289efb029SJiri Olsa 14389efb029SJiri Olsa start_events: groups 14489efb029SJiri Olsa { 1455d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 14689efb029SJiri Olsa 147cabbf268SIan Rogers /* frees $1 */ 1485d9cdc11SArnaldo Carvalho de Melo parse_events_update_lists($1, &parse_state->list); 14989efb029SJiri Olsa } 15089efb029SJiri Olsa 15189efb029SJiri Olsa groups: 15289efb029SJiri Olsa groups ',' group 15389efb029SJiri Olsa { 15489efb029SJiri Olsa struct list_head *list = $1; 15589efb029SJiri Olsa struct list_head *group = $3; 15689efb029SJiri Olsa 157cabbf268SIan Rogers /* frees $3 */ 15889efb029SJiri Olsa parse_events_update_lists(group, list); 15989efb029SJiri Olsa $$ = list; 16089efb029SJiri Olsa } 16189efb029SJiri Olsa | 16289efb029SJiri Olsa groups ',' event 16389efb029SJiri Olsa { 16489efb029SJiri Olsa struct list_head *list = $1; 16589efb029SJiri Olsa struct list_head *event = $3; 16689efb029SJiri Olsa 167cabbf268SIan Rogers /* frees $3 */ 16889efb029SJiri Olsa parse_events_update_lists(event, list); 16989efb029SJiri Olsa $$ = list; 17089efb029SJiri Olsa } 17189efb029SJiri Olsa | 17289efb029SJiri Olsa group 17389efb029SJiri Olsa | 17489efb029SJiri Olsa event 17589efb029SJiri Olsa 17689efb029SJiri Olsa group: 17789efb029SJiri Olsa group_def ':' PE_MODIFIER_EVENT 17889efb029SJiri Olsa { 17989efb029SJiri Olsa struct list_head *list = $1; 180cabbf268SIan Rogers int err; 18189efb029SJiri Olsa 182cabbf268SIan Rogers err = parse_events__modifier_group(list, $3); 183cabbf268SIan Rogers free($3); 184cabbf268SIan Rogers if (err) { 185cabbf268SIan Rogers free_list_evsel(list); 186cabbf268SIan Rogers YYABORT; 187cabbf268SIan Rogers } 18889efb029SJiri Olsa $$ = list; 18989efb029SJiri Olsa } 19089efb029SJiri Olsa | 19189efb029SJiri Olsa group_def 19289efb029SJiri Olsa 19389efb029SJiri Olsa group_def: 19489efb029SJiri Olsa PE_NAME '{' events '}' 19589efb029SJiri Olsa { 19689efb029SJiri Olsa struct list_head *list = $3; 19789efb029SJiri Olsa 1985d9cdc11SArnaldo Carvalho de Melo inc_group_count(list, _parse_state); 1993cdc5c2cSKan Liang parse_events__set_leader($1, list, _parse_state); 200cabbf268SIan Rogers free($1); 20189efb029SJiri Olsa $$ = list; 20289efb029SJiri Olsa } 20389efb029SJiri Olsa | 20489efb029SJiri Olsa '{' events '}' 20589efb029SJiri Olsa { 20689efb029SJiri Olsa struct list_head *list = $2; 20789efb029SJiri Olsa 2085d9cdc11SArnaldo Carvalho de Melo inc_group_count(list, _parse_state); 2093cdc5c2cSKan Liang parse_events__set_leader(NULL, list, _parse_state); 21089efb029SJiri Olsa $$ = list; 21189efb029SJiri Olsa } 21290e2b22dSJiri Olsa 21389812fc8SJiri Olsa events: 21489efb029SJiri Olsa events ',' event 21589efb029SJiri Olsa { 21689efb029SJiri Olsa struct list_head *event = $3; 21789efb029SJiri Olsa struct list_head *list = $1; 21889efb029SJiri Olsa 219cabbf268SIan Rogers /* frees $3 */ 22089efb029SJiri Olsa parse_events_update_lists(event, list); 22189efb029SJiri Olsa $$ = list; 22289efb029SJiri Olsa } 22389efb029SJiri Olsa | 22489efb029SJiri Olsa event 22589812fc8SJiri Olsa 226ac2ba9f3SRobert Richter event: event_mod 227ac2ba9f3SRobert Richter 228ac2ba9f3SRobert Richter event_mod: 229ac2ba9f3SRobert Richter event_name PE_MODIFIER_EVENT 23089812fc8SJiri Olsa { 23189efb029SJiri Olsa struct list_head *list = $1; 232cabbf268SIan Rogers int err; 23346010ab2SJiri Olsa 2345d7be90eSJiri Olsa /* 2355d7be90eSJiri Olsa * Apply modifier on all events added by single event definition 2365d7be90eSJiri Olsa * (there could be more events added for multiple tracepoint 2375d7be90eSJiri Olsa * definitions via '*?'. 2385d7be90eSJiri Olsa */ 239cabbf268SIan Rogers err = parse_events__modifier_event(list, $2, false); 240cabbf268SIan Rogers free($2); 241cabbf268SIan Rogers if (err) { 242cabbf268SIan Rogers free_list_evsel(list); 243cabbf268SIan Rogers YYABORT; 244cabbf268SIan Rogers } 24589efb029SJiri Olsa $$ = list; 24689812fc8SJiri Olsa } 24789812fc8SJiri Olsa | 248ac2ba9f3SRobert Richter event_name 249ac2ba9f3SRobert Richter 250ac2ba9f3SRobert Richter event_name: 251ac2ba9f3SRobert Richter PE_EVENT_NAME event_def 252ac2ba9f3SRobert Richter { 253cabbf268SIan Rogers int err; 254cabbf268SIan Rogers 255cabbf268SIan Rogers err = parse_events_name($2, $1); 256ac2ba9f3SRobert Richter free($1); 257cabbf268SIan Rogers if (err) { 258cabbf268SIan Rogers free_list_evsel($2); 259cabbf268SIan Rogers YYABORT; 260cabbf268SIan Rogers } 261ac2ba9f3SRobert Richter $$ = $2; 262ac2ba9f3SRobert Richter } 263ac2ba9f3SRobert Richter | 26489812fc8SJiri Olsa event_def 26589812fc8SJiri Olsa 2665f537a26SJiri Olsa event_def: event_pmu | 2675f537a26SJiri Olsa event_legacy_symbol | 26889812fc8SJiri Olsa event_legacy_cache sep_dc | 26989812fc8SJiri Olsa event_legacy_mem | 27089812fc8SJiri Olsa event_legacy_tracepoint sep_dc | 27189812fc8SJiri Olsa event_legacy_numeric sep_dc | 27284c86ca1SWang Nan event_legacy_raw sep_dc | 27384c86ca1SWang Nan event_bpf_file 27489812fc8SJiri Olsa 2755f537a26SJiri Olsa event_pmu: 276ceac7b79SJiri Olsa PE_NAME opt_pmu_config 2775f537a26SJiri Olsa { 278f7fa827fSJiri Olsa struct parse_events_state *parse_state = _parse_state; 279f7fa827fSJiri Olsa struct parse_events_error *error = parse_state->error; 280cabbf268SIan Rogers struct list_head *list = NULL, *orig_terms = NULL, *terms= NULL; 281cabbf268SIan Rogers char *pattern = NULL; 282cabbf268SIan Rogers 283cabbf268SIan Rogers #define CLEANUP_YYABORT \ 284cabbf268SIan Rogers do { \ 285cabbf268SIan Rogers parse_events_terms__delete($2); \ 286cabbf268SIan Rogers parse_events_terms__delete(orig_terms); \ 287e1e9b78dSIan Rogers free(list); \ 288cabbf268SIan Rogers free($1); \ 289cabbf268SIan Rogers free(pattern); \ 290cabbf268SIan Rogers YYABORT; \ 291cabbf268SIan Rogers } while(0) 2928255718fSAndi Kleen 2934a35a902SArnaldo Carvalho de Melo if (parse_events_copy_term_list($2, &orig_terms)) 294cabbf268SIan Rogers CLEANUP_YYABORT; 295b847cbdcSJiri Olsa 296f7fa827fSJiri Olsa if (error) 297f7fa827fSJiri Olsa error->idx = @1.first_column; 298f7fa827fSJiri Olsa 299a26e4716SIan Rogers list = alloc_list(); 300cabbf268SIan Rogers if (!list) 301cabbf268SIan Rogers CLEANUP_YYABORT; 3023cdc5c2cSKan Liang if (parse_events_add_pmu(_parse_state, list, $1, $2, false, false)) { 3038255718fSAndi Kleen struct perf_pmu *pmu = NULL; 3048255718fSAndi Kleen int ok = 0; 305b2b9d3a3SAgustin Vega-Frias 306b2b9d3a3SAgustin Vega-Frias if (asprintf(&pattern, "%s*", $1) < 0) 307cabbf268SIan Rogers CLEANUP_YYABORT; 3088255718fSAndi Kleen 3098255718fSAndi Kleen while ((pmu = perf_pmu__scan(pmu)) != NULL) { 3108255718fSAndi Kleen char *name = pmu->name; 3118255718fSAndi Kleen 312a820e335SAndi Kleen if (!strncmp(name, "uncore_", 7) && 313a820e335SAndi Kleen strncmp($1, "uncore_", 7)) 314a820e335SAndi Kleen name += 7; 315b2b9d3a3SAgustin Vega-Frias if (!fnmatch(pattern, name, 0)) { 316cabbf268SIan Rogers if (parse_events_copy_term_list(orig_terms, &terms)) 317cabbf268SIan Rogers CLEANUP_YYABORT; 3183cdc5c2cSKan Liang if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, true, false)) 3198255718fSAndi Kleen ok++; 3208255718fSAndi Kleen parse_events_terms__delete(terms); 3218255718fSAndi Kleen } 3228255718fSAndi Kleen } 323b2b9d3a3SAgustin Vega-Frias 3248255718fSAndi Kleen if (!ok) 325cabbf268SIan Rogers CLEANUP_YYABORT; 3268255718fSAndi Kleen } 3274a35a902SArnaldo Carvalho de Melo parse_events_terms__delete($2); 3288255718fSAndi Kleen parse_events_terms__delete(orig_terms); 329ba08829aSIan Rogers free(pattern); 330cabbf268SIan Rogers free($1); 331b847cbdcSJiri Olsa $$ = list; 332cabbf268SIan Rogers #undef CLEANUP_YYABORT 3335f537a26SJiri Olsa } 334ad962273SAdrian Hunter | 335ba32a451SKan Liang PE_KERNEL_PMU_EVENT sep_dc 336ba32a451SKan Liang { 337ba32a451SKan Liang struct list_head *list; 338cabbf268SIan Rogers int err; 339ba32a451SKan Liang 340cabbf268SIan Rogers err = parse_events_multi_pmu_add(_parse_state, $1, &list); 341cabbf268SIan Rogers free($1); 342cabbf268SIan Rogers if (err < 0) 343231bb2aaSAndi Kleen YYABORT; 344ba32a451SKan Liang $$ = list; 345ba32a451SKan Liang } 346ba32a451SKan Liang | 347ba32a451SKan Liang PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc 348ba32a451SKan Liang { 349ba32a451SKan Liang struct list_head *list; 350ba32a451SKan Liang char pmu_name[128]; 3518255718fSAndi Kleen 352c2412faeSIan Rogers snprintf(pmu_name, sizeof(pmu_name), "%s-%s", $1, $3); 353cabbf268SIan Rogers free($1); 354cabbf268SIan Rogers free($3); 3555d9cdc11SArnaldo Carvalho de Melo if (parse_events_multi_pmu_add(_parse_state, pmu_name, &list) < 0) 3568255718fSAndi Kleen YYABORT; 357ba32a451SKan Liang $$ = list; 358ba32a451SKan Liang } 3595f537a26SJiri Olsa 360cf3506dcSJiri Olsa value_sym: 361cf3506dcSJiri Olsa PE_VALUE_SYM_HW 362cf3506dcSJiri Olsa | 363cf3506dcSJiri Olsa PE_VALUE_SYM_SW 364cf3506dcSJiri Olsa 36589812fc8SJiri Olsa event_legacy_symbol: 366cf3506dcSJiri Olsa value_sym '/' event_config '/' 36789812fc8SJiri Olsa { 368c5cd8ac0SDavid Ahern struct list_head *list; 36989812fc8SJiri Olsa int type = $1 >> 16; 37089812fc8SJiri Olsa int config = $1 & 255; 371cabbf268SIan Rogers int err; 37289812fc8SJiri Olsa 373a26e4716SIan Rogers list = alloc_list(); 374a26e4716SIan Rogers ABORT_ON(!list); 375cabbf268SIan Rogers err = parse_events_add_numeric(_parse_state, list, type, config, $3); 3762146afc6SArnaldo Carvalho de Melo parse_events_terms__delete($3); 377cabbf268SIan Rogers if (err) { 378cabbf268SIan Rogers free_list_evsel(list); 379cabbf268SIan Rogers YYABORT; 380cabbf268SIan Rogers } 381b847cbdcSJiri Olsa $$ = list; 3828f707d84SJiri Olsa } 3838f707d84SJiri Olsa | 384714a92d8SJiri Olsa value_sym sep_slash_slash_dc 3858f707d84SJiri Olsa { 386c5cd8ac0SDavid Ahern struct list_head *list; 3878f707d84SJiri Olsa int type = $1 >> 16; 3888f707d84SJiri Olsa int config = $1 & 255; 3898f707d84SJiri Olsa 390a26e4716SIan Rogers list = alloc_list(); 391a26e4716SIan Rogers ABORT_ON(!list); 3925d9cdc11SArnaldo Carvalho de Melo ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL)); 393b847cbdcSJiri Olsa $$ = list; 39489812fc8SJiri Olsa } 395f0fbb114SAndi Kleen | 396f0fbb114SAndi Kleen PE_VALUE_SYM_TOOL sep_slash_slash_dc 397f0fbb114SAndi Kleen { 398f0fbb114SAndi Kleen struct list_head *list; 399f0fbb114SAndi Kleen 400a26e4716SIan Rogers list = alloc_list(); 401a26e4716SIan Rogers ABORT_ON(!list); 402f0fbb114SAndi Kleen ABORT_ON(parse_events_add_tool(_parse_state, list, $1)); 403f0fbb114SAndi Kleen $$ = list; 404f0fbb114SAndi Kleen } 40589812fc8SJiri Olsa 40689812fc8SJiri Olsa event_legacy_cache: 40743d0b978SWang Nan PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config 40889812fc8SJiri Olsa { 4095d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 4105d9cdc11SArnaldo Carvalho de Melo struct parse_events_error *error = parse_state->error; 411c5cd8ac0SDavid Ahern struct list_head *list; 412cabbf268SIan Rogers int err; 413b847cbdcSJiri Olsa 414a26e4716SIan Rogers list = alloc_list(); 415a26e4716SIan Rogers ABORT_ON(!list); 416cabbf268SIan Rogers err = parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6); 41743d0b978SWang Nan parse_events_terms__delete($6); 418cabbf268SIan Rogers free($1); 419cabbf268SIan Rogers free($3); 420cabbf268SIan Rogers free($5); 421cabbf268SIan Rogers if (err) { 422cabbf268SIan Rogers free_list_evsel(list); 423cabbf268SIan Rogers YYABORT; 424cabbf268SIan Rogers } 425b847cbdcSJiri Olsa $$ = list; 42689812fc8SJiri Olsa } 42789812fc8SJiri Olsa | 42843d0b978SWang Nan PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config 42989812fc8SJiri Olsa { 4305d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 4315d9cdc11SArnaldo Carvalho de Melo struct parse_events_error *error = parse_state->error; 432c5cd8ac0SDavid Ahern struct list_head *list; 433cabbf268SIan Rogers int err; 434b847cbdcSJiri Olsa 435a26e4716SIan Rogers list = alloc_list(); 436a26e4716SIan Rogers ABORT_ON(!list); 437cabbf268SIan Rogers err = parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4); 43843d0b978SWang Nan parse_events_terms__delete($4); 439cabbf268SIan Rogers free($1); 440cabbf268SIan Rogers free($3); 441cabbf268SIan Rogers if (err) { 442cabbf268SIan Rogers free_list_evsel(list); 443cabbf268SIan Rogers YYABORT; 444cabbf268SIan Rogers } 445b847cbdcSJiri Olsa $$ = list; 44689812fc8SJiri Olsa } 44789812fc8SJiri Olsa | 44843d0b978SWang Nan PE_NAME_CACHE_TYPE opt_event_config 44989812fc8SJiri Olsa { 4505d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 4515d9cdc11SArnaldo Carvalho de Melo struct parse_events_error *error = parse_state->error; 452c5cd8ac0SDavid Ahern struct list_head *list; 453cabbf268SIan Rogers int err; 454b847cbdcSJiri Olsa 455a26e4716SIan Rogers list = alloc_list(); 456a26e4716SIan Rogers ABORT_ON(!list); 457cabbf268SIan Rogers err = parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2); 45843d0b978SWang Nan parse_events_terms__delete($2); 459cabbf268SIan Rogers free($1); 460cabbf268SIan Rogers if (err) { 461cabbf268SIan Rogers free_list_evsel(list); 462cabbf268SIan Rogers YYABORT; 463cabbf268SIan Rogers } 464b847cbdcSJiri Olsa $$ = list; 46589812fc8SJiri Olsa } 46689812fc8SJiri Olsa 46789812fc8SJiri Olsa event_legacy_mem: 4683741eb9fSJacob Shin PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc 4693741eb9fSJacob Shin { 4705d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 4713741eb9fSJacob Shin struct list_head *list; 472cabbf268SIan Rogers int err; 4733741eb9fSJacob Shin 474a26e4716SIan Rogers list = alloc_list(); 475a26e4716SIan Rogers ABORT_ON(!list); 476cabbf268SIan Rogers err = parse_events_add_breakpoint(list, &parse_state->idx, 477cabbf268SIan Rogers (void *) $2, $6, $4); 478cabbf268SIan Rogers free($6); 479cabbf268SIan Rogers if (err) { 480cabbf268SIan Rogers free(list); 481cabbf268SIan Rogers YYABORT; 482cabbf268SIan Rogers } 4833741eb9fSJacob Shin $$ = list; 4843741eb9fSJacob Shin } 4853741eb9fSJacob Shin | 4863741eb9fSJacob Shin PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc 4873741eb9fSJacob Shin { 4885d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 4893741eb9fSJacob Shin struct list_head *list; 4903741eb9fSJacob Shin 491a26e4716SIan Rogers list = alloc_list(); 492a26e4716SIan Rogers ABORT_ON(!list); 493cabbf268SIan Rogers if (parse_events_add_breakpoint(list, &parse_state->idx, 494cabbf268SIan Rogers (void *) $2, NULL, $4)) { 495cabbf268SIan Rogers free(list); 496cabbf268SIan Rogers YYABORT; 497cabbf268SIan Rogers } 4983741eb9fSJacob Shin $$ = list; 4993741eb9fSJacob Shin } 5003741eb9fSJacob Shin | 50189812fc8SJiri Olsa PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc 50289812fc8SJiri Olsa { 5035d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 504c5cd8ac0SDavid Ahern struct list_head *list; 505cabbf268SIan Rogers int err; 506b847cbdcSJiri Olsa 507a26e4716SIan Rogers list = alloc_list(); 508a26e4716SIan Rogers ABORT_ON(!list); 509cabbf268SIan Rogers err = parse_events_add_breakpoint(list, &parse_state->idx, 510cabbf268SIan Rogers (void *) $2, $4, 0); 511cabbf268SIan Rogers free($4); 512cabbf268SIan Rogers if (err) { 513cabbf268SIan Rogers free(list); 514cabbf268SIan Rogers YYABORT; 515cabbf268SIan Rogers } 516b847cbdcSJiri Olsa $$ = list; 51789812fc8SJiri Olsa } 51889812fc8SJiri Olsa | 51989812fc8SJiri Olsa PE_PREFIX_MEM PE_VALUE sep_dc 52089812fc8SJiri Olsa { 5215d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 522c5cd8ac0SDavid Ahern struct list_head *list; 523b847cbdcSJiri Olsa 524a26e4716SIan Rogers list = alloc_list(); 525a26e4716SIan Rogers ABORT_ON(!list); 526cabbf268SIan Rogers if (parse_events_add_breakpoint(list, &parse_state->idx, 527cabbf268SIan Rogers (void *) $2, NULL, 0)) { 528cabbf268SIan Rogers free(list); 529cabbf268SIan Rogers YYABORT; 530cabbf268SIan Rogers } 531b847cbdcSJiri Olsa $$ = list; 53289812fc8SJiri Olsa } 53389812fc8SJiri Olsa 53489812fc8SJiri Olsa event_legacy_tracepoint: 5351d55e8efSArnaldo Carvalho de Melo tracepoint_name opt_event_config 5362b9032e0SAlexander Yarygin { 5375d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 5385d9cdc11SArnaldo Carvalho de Melo struct parse_events_error *error = parse_state->error; 5392b9032e0SAlexander Yarygin struct list_head *list; 540cabbf268SIan Rogers int err; 5412b9032e0SAlexander Yarygin 542a26e4716SIan Rogers list = alloc_list(); 543a26e4716SIan Rogers ABORT_ON(!list); 54419658171SJiri Olsa if (error) 54519658171SJiri Olsa error->idx = @1.first_column; 546e637d177SHe Kuang 547cabbf268SIan Rogers err = parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event, 548cabbf268SIan Rogers error, $2); 549e637d177SHe Kuang 550cabbf268SIan Rogers parse_events_terms__delete($2); 551cabbf268SIan Rogers free($1.sys); 552cabbf268SIan Rogers free($1.event); 553cabbf268SIan Rogers if (err) { 554cabbf268SIan Rogers free(list); 555e1e9b78dSIan Rogers YYABORT; 556cabbf268SIan Rogers } 5572b9032e0SAlexander Yarygin $$ = list; 5582b9032e0SAlexander Yarygin } 559865582c3SHe Kuang 560865582c3SHe Kuang tracepoint_name: 561865582c3SHe Kuang PE_NAME '-' PE_NAME ':' PE_NAME 562865582c3SHe Kuang { 563865582c3SHe Kuang struct tracepoint_name tracepoint; 564865582c3SHe Kuang 565cabbf268SIan Rogers ABORT_ON(asprintf(&tracepoint.sys, "%s-%s", $1, $3) < 0); 566865582c3SHe Kuang tracepoint.event = $5; 567cabbf268SIan Rogers free($1); 568cabbf268SIan Rogers free($3); 569865582c3SHe Kuang $$ = tracepoint; 570865582c3SHe Kuang } 5712b9032e0SAlexander Yarygin | 57289812fc8SJiri Olsa PE_NAME ':' PE_NAME 57389812fc8SJiri Olsa { 574865582c3SHe Kuang struct tracepoint_name tracepoint = {$1, $3}; 575b847cbdcSJiri Olsa 576865582c3SHe Kuang $$ = tracepoint; 57789812fc8SJiri Olsa } 57889812fc8SJiri Olsa 57989812fc8SJiri Olsa event_legacy_numeric: 58010bf358aSWang Nan PE_VALUE ':' PE_VALUE opt_event_config 58189812fc8SJiri Olsa { 582c5cd8ac0SDavid Ahern struct list_head *list; 583cabbf268SIan Rogers int err; 584b847cbdcSJiri Olsa 585a26e4716SIan Rogers list = alloc_list(); 586a26e4716SIan Rogers ABORT_ON(!list); 587cabbf268SIan Rogers err = parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4); 58810bf358aSWang Nan parse_events_terms__delete($4); 589cabbf268SIan Rogers if (err) { 590cabbf268SIan Rogers free(list); 591cabbf268SIan Rogers YYABORT; 592cabbf268SIan Rogers } 593b847cbdcSJiri Olsa $$ = list; 59489812fc8SJiri Olsa } 59589812fc8SJiri Olsa 59689812fc8SJiri Olsa event_legacy_raw: 59710bf358aSWang Nan PE_RAW opt_event_config 59889812fc8SJiri Olsa { 599c5cd8ac0SDavid Ahern struct list_head *list; 600cabbf268SIan Rogers int err; 601b847cbdcSJiri Olsa 602a26e4716SIan Rogers list = alloc_list(); 603a26e4716SIan Rogers ABORT_ON(!list); 604cabbf268SIan Rogers err = parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, $1, $2); 60510bf358aSWang Nan parse_events_terms__delete($2); 606cabbf268SIan Rogers if (err) { 607cabbf268SIan Rogers free(list); 608cabbf268SIan Rogers YYABORT; 609cabbf268SIan Rogers } 610b847cbdcSJiri Olsa $$ = list; 6118f707d84SJiri Olsa } 6128f707d84SJiri Olsa 61384c86ca1SWang Nan event_bpf_file: 614a34f3be7SWang Nan PE_BPF_OBJECT opt_event_config 61584c86ca1SWang Nan { 6165d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 61784c86ca1SWang Nan struct list_head *list; 618cabbf268SIan Rogers int err; 61984c86ca1SWang Nan 620a26e4716SIan Rogers list = alloc_list(); 621a26e4716SIan Rogers ABORT_ON(!list); 622cabbf268SIan Rogers err = parse_events_load_bpf(parse_state, list, $1, false, $2); 623a34f3be7SWang Nan parse_events_terms__delete($2); 624cabbf268SIan Rogers free($1); 625cabbf268SIan Rogers if (err) { 626cabbf268SIan Rogers free(list); 627cabbf268SIan Rogers YYABORT; 628cabbf268SIan Rogers } 629d509db04SWang Nan $$ = list; 630d509db04SWang Nan } 631d509db04SWang Nan | 632a34f3be7SWang Nan PE_BPF_SOURCE opt_event_config 633d509db04SWang Nan { 634d509db04SWang Nan struct list_head *list; 635cabbf268SIan Rogers int err; 636d509db04SWang Nan 637a26e4716SIan Rogers list = alloc_list(); 638a26e4716SIan Rogers ABORT_ON(!list); 639cabbf268SIan Rogers err = parse_events_load_bpf(_parse_state, list, $1, true, $2); 640a34f3be7SWang Nan parse_events_terms__delete($2); 641cabbf268SIan Rogers if (err) { 642cabbf268SIan Rogers free(list); 643cabbf268SIan Rogers YYABORT; 644cabbf268SIan Rogers } 64584c86ca1SWang Nan $$ = list; 64684c86ca1SWang Nan } 64784c86ca1SWang Nan 6481d55e8efSArnaldo Carvalho de Melo opt_event_config: 6491d55e8efSArnaldo Carvalho de Melo '/' event_config '/' 6501d55e8efSArnaldo Carvalho de Melo { 6511d55e8efSArnaldo Carvalho de Melo $$ = $2; 6521d55e8efSArnaldo Carvalho de Melo } 6531d55e8efSArnaldo Carvalho de Melo | 6541d55e8efSArnaldo Carvalho de Melo '/' '/' 6551d55e8efSArnaldo Carvalho de Melo { 6561d55e8efSArnaldo Carvalho de Melo $$ = NULL; 6571d55e8efSArnaldo Carvalho de Melo } 6581d55e8efSArnaldo Carvalho de Melo | 6591d55e8efSArnaldo Carvalho de Melo { 6601d55e8efSArnaldo Carvalho de Melo $$ = NULL; 6611d55e8efSArnaldo Carvalho de Melo } 6621d55e8efSArnaldo Carvalho de Melo 663ceac7b79SJiri Olsa opt_pmu_config: 664ceac7b79SJiri Olsa '/' event_config '/' 665ceac7b79SJiri Olsa { 666ceac7b79SJiri Olsa $$ = $2; 667ceac7b79SJiri Olsa } 668ceac7b79SJiri Olsa | 669ceac7b79SJiri Olsa '/' '/' 670ceac7b79SJiri Olsa { 671ceac7b79SJiri Olsa $$ = NULL; 672ceac7b79SJiri Olsa } 673ceac7b79SJiri Olsa 67489efb029SJiri Olsa start_terms: event_config 67590e2b22dSJiri Olsa { 6765d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 677cabbf268SIan Rogers if (parse_state->terms) { 678cabbf268SIan Rogers parse_events_terms__delete ($1); 679cabbf268SIan Rogers YYABORT; 680cabbf268SIan Rogers } 6815d9cdc11SArnaldo Carvalho de Melo parse_state->terms = $1; 68290e2b22dSJiri Olsa } 68390e2b22dSJiri Olsa 6848f707d84SJiri Olsa event_config: 6858f707d84SJiri Olsa event_config ',' event_term 6868f707d84SJiri Olsa { 6878f707d84SJiri Olsa struct list_head *head = $1; 6886cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term = $3; 6898f707d84SJiri Olsa 690cabbf268SIan Rogers if (!head) { 6911dc92556SIan Rogers parse_events_term__delete(term); 692cabbf268SIan Rogers YYABORT; 693cabbf268SIan Rogers } 6948f707d84SJiri Olsa list_add_tail(&term->list, head); 6958f707d84SJiri Olsa $$ = $1; 6968f707d84SJiri Olsa } 6978f707d84SJiri Olsa | 6988f707d84SJiri Olsa event_term 6998f707d84SJiri Olsa { 7008f707d84SJiri Olsa struct list_head *head = malloc(sizeof(*head)); 7016cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term = $1; 7028f707d84SJiri Olsa 7038f707d84SJiri Olsa ABORT_ON(!head); 7048f707d84SJiri Olsa INIT_LIST_HEAD(head); 7058f707d84SJiri Olsa list_add_tail(&term->list, head); 7068f707d84SJiri Olsa $$ = head; 7078f707d84SJiri Olsa } 7088f707d84SJiri Olsa 7098f707d84SJiri Olsa event_term: 7103a6c51e4SJiri Olsa PE_RAW 7113a6c51e4SJiri Olsa { 7123a6c51e4SJiri Olsa struct parse_events_term *term; 7133a6c51e4SJiri Olsa 7143a6c51e4SJiri Olsa ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_CONFIG, 7153a6c51e4SJiri Olsa NULL, $1, false, &@1, NULL)); 7163a6c51e4SJiri Olsa $$ = term; 7173a6c51e4SJiri Olsa } 7183a6c51e4SJiri Olsa | 7198f707d84SJiri Olsa PE_NAME '=' PE_NAME 7208f707d84SJiri Olsa { 7216cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 7228f707d84SJiri Olsa 723cabbf268SIan Rogers if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, 724cabbf268SIan Rogers $1, $3, &@1, &@3)) { 725cabbf268SIan Rogers free($1); 726cabbf268SIan Rogers free($3); 727cabbf268SIan Rogers YYABORT; 728cabbf268SIan Rogers } 7298f707d84SJiri Olsa $$ = term; 7308f707d84SJiri Olsa } 7318f707d84SJiri Olsa | 7328f707d84SJiri Olsa PE_NAME '=' PE_VALUE 7338f707d84SJiri Olsa { 7346cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 7358f707d84SJiri Olsa 736cabbf268SIan Rogers if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, 737cabbf268SIan Rogers $1, $3, false, &@1, &@3)) { 738cabbf268SIan Rogers free($1); 739cabbf268SIan Rogers YYABORT; 740cabbf268SIan Rogers } 7418f707d84SJiri Olsa $$ = term; 7428f707d84SJiri Olsa } 7438f707d84SJiri Olsa | 7441d33d6dcSJiri Olsa PE_NAME '=' PE_VALUE_SYM_HW 7451d33d6dcSJiri Olsa { 7466cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 7471d33d6dcSJiri Olsa int config = $3 & 255; 7481d33d6dcSJiri Olsa 749cabbf268SIan Rogers if (parse_events_term__sym_hw(&term, $1, config)) { 750cabbf268SIan Rogers free($1); 751cabbf268SIan Rogers YYABORT; 752cabbf268SIan Rogers } 7531d33d6dcSJiri Olsa $$ = term; 7541d33d6dcSJiri Olsa } 7551d33d6dcSJiri Olsa | 7568f707d84SJiri Olsa PE_NAME 7578f707d84SJiri Olsa { 7586cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 7598f707d84SJiri Olsa 760cabbf268SIan Rogers if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, 761cabbf268SIan Rogers $1, 1, true, &@1, NULL)) { 762cabbf268SIan Rogers free($1); 763cabbf268SIan Rogers YYABORT; 764cabbf268SIan Rogers } 7658f707d84SJiri Olsa $$ = term; 7668f707d84SJiri Olsa } 7678f707d84SJiri Olsa | 7681d33d6dcSJiri Olsa PE_VALUE_SYM_HW 7691d33d6dcSJiri Olsa { 7706cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 7711d33d6dcSJiri Olsa int config = $1 & 255; 7721d33d6dcSJiri Olsa 7736cee6cd3SArnaldo Carvalho de Melo ABORT_ON(parse_events_term__sym_hw(&term, NULL, config)); 7741d33d6dcSJiri Olsa $$ = term; 7751d33d6dcSJiri Olsa } 7761d33d6dcSJiri Olsa | 7776b5fc39bSJiri Olsa PE_TERM '=' PE_NAME 7786b5fc39bSJiri Olsa { 7796cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 7806b5fc39bSJiri Olsa 781cabbf268SIan Rogers if (parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3)) { 782cabbf268SIan Rogers free($3); 783cabbf268SIan Rogers YYABORT; 784cabbf268SIan Rogers } 7856b5fc39bSJiri Olsa $$ = term; 7866b5fc39bSJiri Olsa } 7876b5fc39bSJiri Olsa | 7888f707d84SJiri Olsa PE_TERM '=' PE_VALUE 7898f707d84SJiri Olsa { 7906cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 7918f707d84SJiri Olsa 79299e7138eSJiri Olsa ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, false, &@1, &@3)); 7938f707d84SJiri Olsa $$ = term; 7948f707d84SJiri Olsa } 7958f707d84SJiri Olsa | 7968f707d84SJiri Olsa PE_TERM 7978f707d84SJiri Olsa { 7986cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 7998f707d84SJiri Olsa 80099e7138eSJiri Olsa ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, true, &@1, NULL)); 8018f707d84SJiri Olsa $$ = term; 80289812fc8SJiri Olsa } 803e571e029SWang Nan | 804e571e029SWang Nan PE_NAME array '=' PE_NAME 805e571e029SWang Nan { 806e571e029SWang Nan struct parse_events_term *term; 807e571e029SWang Nan 808cabbf268SIan Rogers if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, 809cabbf268SIan Rogers $1, $4, &@1, &@4)) { 810cabbf268SIan Rogers free($1); 811cabbf268SIan Rogers free($4); 812cabbf268SIan Rogers free($2.ranges); 813cabbf268SIan Rogers YYABORT; 814cabbf268SIan Rogers } 815e571e029SWang Nan term->array = $2; 816e571e029SWang Nan $$ = term; 817e571e029SWang Nan } 818e571e029SWang Nan | 819e571e029SWang Nan PE_NAME array '=' PE_VALUE 820e571e029SWang Nan { 821e571e029SWang Nan struct parse_events_term *term; 822e571e029SWang Nan 823cabbf268SIan Rogers if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, 824cabbf268SIan Rogers $1, $4, false, &@1, &@4)) { 825cabbf268SIan Rogers free($1); 826cabbf268SIan Rogers free($2.ranges); 827cabbf268SIan Rogers YYABORT; 828cabbf268SIan Rogers } 829e571e029SWang Nan term->array = $2; 830e571e029SWang Nan $$ = term; 831e571e029SWang Nan } 832dd60fba7SMathieu Poirier | 833dd60fba7SMathieu Poirier PE_DRV_CFG_TERM 834dd60fba7SMathieu Poirier { 835dd60fba7SMathieu Poirier struct parse_events_term *term; 836b6645a72SIan Rogers char *config = strdup($1); 837dd60fba7SMathieu Poirier 838b6645a72SIan Rogers ABORT_ON(!config); 839cabbf268SIan Rogers if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG, 840cabbf268SIan Rogers config, $1, &@1, NULL)) { 841cabbf268SIan Rogers free($1); 842cabbf268SIan Rogers free(config); 843cabbf268SIan Rogers YYABORT; 844cabbf268SIan Rogers } 845dd60fba7SMathieu Poirier $$ = term; 846dd60fba7SMathieu Poirier } 847e571e029SWang Nan 848e571e029SWang Nan array: 849e571e029SWang Nan '[' array_terms ']' 850e571e029SWang Nan { 851e571e029SWang Nan $$ = $2; 852e571e029SWang Nan } 853e571e029SWang Nan | 854e571e029SWang Nan PE_ARRAY_ALL 855e571e029SWang Nan { 856e571e029SWang Nan $$.nr_ranges = 0; 857e571e029SWang Nan $$.ranges = NULL; 858e571e029SWang Nan } 859e571e029SWang Nan 860e571e029SWang Nan array_terms: 861e571e029SWang Nan array_terms ',' array_term 862e571e029SWang Nan { 863e571e029SWang Nan struct parse_events_array new_array; 864e571e029SWang Nan 865e571e029SWang Nan new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges; 866826100a7SIan Rogers new_array.ranges = realloc($1.ranges, 867826100a7SIan Rogers sizeof(new_array.ranges[0]) * 868e571e029SWang Nan new_array.nr_ranges); 869e571e029SWang Nan ABORT_ON(!new_array.ranges); 870e571e029SWang Nan memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges, 871e571e029SWang Nan $3.nr_ranges * sizeof(new_array.ranges[0])); 872e571e029SWang Nan free($3.ranges); 873e571e029SWang Nan $$ = new_array; 874e571e029SWang Nan } 875e571e029SWang Nan | 876e571e029SWang Nan array_term 877e571e029SWang Nan 878e571e029SWang Nan array_term: 879e571e029SWang Nan PE_VALUE 880e571e029SWang Nan { 881e571e029SWang Nan struct parse_events_array array; 882e571e029SWang Nan 883e571e029SWang Nan array.nr_ranges = 1; 884e571e029SWang Nan array.ranges = malloc(sizeof(array.ranges[0])); 885e571e029SWang Nan ABORT_ON(!array.ranges); 886e571e029SWang Nan array.ranges[0].start = $1; 887e571e029SWang Nan array.ranges[0].length = 1; 888e571e029SWang Nan $$ = array; 889e571e029SWang Nan } 890e571e029SWang Nan | 891e571e029SWang Nan PE_VALUE PE_ARRAY_RANGE PE_VALUE 892e571e029SWang Nan { 893e571e029SWang Nan struct parse_events_array array; 894e571e029SWang Nan 895e571e029SWang Nan ABORT_ON($3 < $1); 896e571e029SWang Nan array.nr_ranges = 1; 897e571e029SWang Nan array.ranges = malloc(sizeof(array.ranges[0])); 898e571e029SWang Nan ABORT_ON(!array.ranges); 899e571e029SWang Nan array.ranges[0].start = $1; 900e571e029SWang Nan array.ranges[0].length = $3 - $1 + 1; 901e571e029SWang Nan $$ = array; 902e571e029SWang Nan } 90389812fc8SJiri Olsa 90489812fc8SJiri Olsa sep_dc: ':' | 90589812fc8SJiri Olsa 906714a92d8SJiri Olsa sep_slash_slash_dc: '/' '/' | ':' | 9078f707d84SJiri Olsa 90889812fc8SJiri Olsa %% 90989812fc8SJiri Olsa 9105d9cdc11SArnaldo Carvalho de Melo void parse_events_error(YYLTYPE *loc, void *parse_state, 9116297d423SJiri Olsa void *scanner __maybe_unused, 9121d037ca1SIrina Tirdea char const *msg __maybe_unused) 91389812fc8SJiri Olsa { 9145d9cdc11SArnaldo Carvalho de Melo parse_events_evlist_error(parse_state, loc->last_column, "parser error"); 91589812fc8SJiri Olsa } 916