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 29ffaecd7dSIan 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 72864bc8c9SJohn Garry %token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_PMU_EVENT_SUF2 PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE 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 90864bc8c9SJohn Garry %type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_PMU_EVENT_SUF2 PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE 91dd60fba7SMathieu Poirier %type <str> PE_DRV_CFG_TERM 9284ea6036SJiri Olsa %type <str> event_pmu_name 93f2a8ecd8SIan Rogers %destructor { free ($$); } <str> 948f707d84SJiri Olsa %type <term> event_term 951dc92556SIan Rogers %destructor { parse_events_term__delete ($$); } <term> 96f2a8ecd8SIan Rogers %type <list_terms> event_config 97f2a8ecd8SIan Rogers %type <list_terms> opt_event_config 98f2a8ecd8SIan Rogers %type <list_terms> opt_pmu_config 99f2a8ecd8SIan Rogers %destructor { parse_events_terms__delete ($$); } <list_terms> 100f2a8ecd8SIan Rogers %type <list_evsel> event_pmu 101f2a8ecd8SIan Rogers %type <list_evsel> event_legacy_symbol 102f2a8ecd8SIan Rogers %type <list_evsel> event_legacy_cache 103f2a8ecd8SIan Rogers %type <list_evsel> event_legacy_mem 104f2a8ecd8SIan Rogers %type <list_evsel> event_legacy_tracepoint 105f2a8ecd8SIan Rogers %type <list_evsel> event_legacy_numeric 106f2a8ecd8SIan Rogers %type <list_evsel> event_legacy_raw 107f2a8ecd8SIan Rogers %type <list_evsel> event_bpf_file 108f2a8ecd8SIan Rogers %type <list_evsel> event_def 109f2a8ecd8SIan Rogers %type <list_evsel> event_mod 110f2a8ecd8SIan Rogers %type <list_evsel> event_name 111f2a8ecd8SIan Rogers %type <list_evsel> event 112f2a8ecd8SIan Rogers %type <list_evsel> events 113f2a8ecd8SIan Rogers %type <list_evsel> group_def 114f2a8ecd8SIan Rogers %type <list_evsel> group 115f2a8ecd8SIan Rogers %type <list_evsel> groups 116f2a8ecd8SIan Rogers %destructor { free_list_evsel ($$); } <list_evsel> 117865582c3SHe Kuang %type <tracepoint_name> tracepoint_name 118f2a8ecd8SIan Rogers %destructor { free ($$.sys); free ($$.event); } <tracepoint_name> 119e571e029SWang Nan %type <array> array 120e571e029SWang Nan %type <array> array_term 121e571e029SWang Nan %type <array> array_terms 122f2a8ecd8SIan Rogers %destructor { free ($$.ranges); } <array> 12389812fc8SJiri Olsa 12489812fc8SJiri Olsa %union 12589812fc8SJiri Olsa { 12689812fc8SJiri Olsa char *str; 127b527bab5SRobert Richter u64 num; 128f2a8ecd8SIan Rogers struct list_head *list_evsel; 129f2a8ecd8SIan Rogers struct list_head *list_terms; 1306cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 131865582c3SHe Kuang struct tracepoint_name { 132865582c3SHe Kuang char *sys; 133865582c3SHe Kuang char *event; 134865582c3SHe Kuang } tracepoint_name; 135e571e029SWang Nan struct parse_events_array array; 13689812fc8SJiri Olsa } 13789812fc8SJiri Olsa %% 13889812fc8SJiri Olsa 13990e2b22dSJiri Olsa start: 14089efb029SJiri Olsa PE_START_EVENTS start_events 14190e2b22dSJiri Olsa | 14289efb029SJiri Olsa PE_START_TERMS start_terms 14389efb029SJiri Olsa 14489efb029SJiri Olsa start_events: groups 14589efb029SJiri Olsa { 1465d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 14789efb029SJiri Olsa 148cabbf268SIan Rogers /* frees $1 */ 1495d9cdc11SArnaldo Carvalho de Melo parse_events_update_lists($1, &parse_state->list); 15089efb029SJiri Olsa } 15189efb029SJiri Olsa 15289efb029SJiri Olsa groups: 15389efb029SJiri Olsa groups ',' group 15489efb029SJiri Olsa { 15589efb029SJiri Olsa struct list_head *list = $1; 15689efb029SJiri Olsa struct list_head *group = $3; 15789efb029SJiri Olsa 158cabbf268SIan Rogers /* frees $3 */ 15989efb029SJiri Olsa parse_events_update_lists(group, list); 16089efb029SJiri Olsa $$ = list; 16189efb029SJiri Olsa } 16289efb029SJiri Olsa | 16389efb029SJiri Olsa groups ',' event 16489efb029SJiri Olsa { 16589efb029SJiri Olsa struct list_head *list = $1; 16689efb029SJiri Olsa struct list_head *event = $3; 16789efb029SJiri Olsa 168cabbf268SIan Rogers /* frees $3 */ 16989efb029SJiri Olsa parse_events_update_lists(event, list); 17089efb029SJiri Olsa $$ = list; 17189efb029SJiri Olsa } 17289efb029SJiri Olsa | 17389efb029SJiri Olsa group 17489efb029SJiri Olsa | 17589efb029SJiri Olsa event 17689efb029SJiri Olsa 17789efb029SJiri Olsa group: 17889efb029SJiri Olsa group_def ':' PE_MODIFIER_EVENT 17989efb029SJiri Olsa { 18089efb029SJiri Olsa struct list_head *list = $1; 181cabbf268SIan Rogers int err; 18289efb029SJiri Olsa 183cabbf268SIan Rogers err = parse_events__modifier_group(list, $3); 184cabbf268SIan Rogers free($3); 185cabbf268SIan Rogers if (err) { 186eabd4523SIan Rogers struct parse_events_state *parse_state = _parse_state; 187eabd4523SIan Rogers struct parse_events_error *error = parse_state->error; 188eabd4523SIan Rogers 1896c191289SIan Rogers parse_events_error__handle(error, @3.first_column, 190eabd4523SIan Rogers strdup("Bad modifier"), NULL); 191cabbf268SIan Rogers free_list_evsel(list); 192cabbf268SIan Rogers YYABORT; 193cabbf268SIan Rogers } 19489efb029SJiri Olsa $$ = list; 19589efb029SJiri Olsa } 19689efb029SJiri Olsa | 19789efb029SJiri Olsa group_def 19889efb029SJiri Olsa 19989efb029SJiri Olsa group_def: 20089efb029SJiri Olsa PE_NAME '{' events '}' 20189efb029SJiri Olsa { 20289efb029SJiri Olsa struct list_head *list = $3; 20389efb029SJiri Olsa 2045d9cdc11SArnaldo Carvalho de Melo inc_group_count(list, _parse_state); 205*4bb311b2SIan Rogers /* Takes ownership of $1. */ 2063cdc5c2cSKan Liang parse_events__set_leader($1, list, _parse_state); 20789efb029SJiri Olsa $$ = list; 20889efb029SJiri Olsa } 20989efb029SJiri Olsa | 21089efb029SJiri Olsa '{' events '}' 21189efb029SJiri Olsa { 21289efb029SJiri Olsa struct list_head *list = $2; 21389efb029SJiri Olsa 2145d9cdc11SArnaldo Carvalho de Melo inc_group_count(list, _parse_state); 2153cdc5c2cSKan Liang parse_events__set_leader(NULL, list, _parse_state); 21689efb029SJiri Olsa $$ = list; 21789efb029SJiri Olsa } 21890e2b22dSJiri Olsa 21989812fc8SJiri Olsa events: 22089efb029SJiri Olsa events ',' event 22189efb029SJiri Olsa { 22289efb029SJiri Olsa struct list_head *event = $3; 22389efb029SJiri Olsa struct list_head *list = $1; 22489efb029SJiri Olsa 225cabbf268SIan Rogers /* frees $3 */ 22689efb029SJiri Olsa parse_events_update_lists(event, list); 22789efb029SJiri Olsa $$ = list; 22889efb029SJiri Olsa } 22989efb029SJiri Olsa | 23089efb029SJiri Olsa event 23189812fc8SJiri Olsa 232ac2ba9f3SRobert Richter event: event_mod 233ac2ba9f3SRobert Richter 234ac2ba9f3SRobert Richter event_mod: 235ac2ba9f3SRobert Richter event_name PE_MODIFIER_EVENT 23689812fc8SJiri Olsa { 23789efb029SJiri Olsa struct list_head *list = $1; 238cabbf268SIan Rogers int err; 23946010ab2SJiri Olsa 2405d7be90eSJiri Olsa /* 2415d7be90eSJiri Olsa * Apply modifier on all events added by single event definition 2425d7be90eSJiri Olsa * (there could be more events added for multiple tracepoint 2435d7be90eSJiri Olsa * definitions via '*?'. 2445d7be90eSJiri Olsa */ 245cabbf268SIan Rogers err = parse_events__modifier_event(list, $2, false); 246cabbf268SIan Rogers free($2); 247cabbf268SIan Rogers if (err) { 248eabd4523SIan Rogers struct parse_events_state *parse_state = _parse_state; 249eabd4523SIan Rogers struct parse_events_error *error = parse_state->error; 250eabd4523SIan Rogers 2516c191289SIan Rogers parse_events_error__handle(error, @2.first_column, 252eabd4523SIan Rogers strdup("Bad modifier"), NULL); 253cabbf268SIan Rogers free_list_evsel(list); 254cabbf268SIan Rogers YYABORT; 255cabbf268SIan Rogers } 25689efb029SJiri Olsa $$ = list; 25789812fc8SJiri Olsa } 25889812fc8SJiri Olsa | 259ac2ba9f3SRobert Richter event_name 260ac2ba9f3SRobert Richter 261ac2ba9f3SRobert Richter event_name: 262ac2ba9f3SRobert Richter PE_EVENT_NAME event_def 263ac2ba9f3SRobert Richter { 264cabbf268SIan Rogers int err; 265cabbf268SIan Rogers 266cabbf268SIan Rogers err = parse_events_name($2, $1); 267ac2ba9f3SRobert Richter free($1); 268cabbf268SIan Rogers if (err) { 269cabbf268SIan Rogers free_list_evsel($2); 270cabbf268SIan Rogers YYABORT; 271cabbf268SIan Rogers } 272ac2ba9f3SRobert Richter $$ = $2; 273ac2ba9f3SRobert Richter } 274ac2ba9f3SRobert Richter | 27589812fc8SJiri Olsa event_def 27689812fc8SJiri Olsa 2775f537a26SJiri Olsa event_def: event_pmu | 2785f537a26SJiri Olsa event_legacy_symbol | 27989812fc8SJiri Olsa event_legacy_cache sep_dc | 28089812fc8SJiri Olsa event_legacy_mem | 28189812fc8SJiri Olsa event_legacy_tracepoint sep_dc | 28289812fc8SJiri Olsa event_legacy_numeric sep_dc | 28384c86ca1SWang Nan event_legacy_raw sep_dc | 28484c86ca1SWang Nan event_bpf_file 28589812fc8SJiri Olsa 28684ea6036SJiri Olsa event_pmu_name: 28784ea6036SJiri Olsa PE_NAME | PE_PMU_EVENT_PRE 28884ea6036SJiri Olsa 2895f537a26SJiri Olsa event_pmu: 29084ea6036SJiri Olsa event_pmu_name opt_pmu_config 2915f537a26SJiri Olsa { 292f7fa827fSJiri Olsa struct parse_events_state *parse_state = _parse_state; 293f7fa827fSJiri Olsa struct parse_events_error *error = parse_state->error; 294cabbf268SIan Rogers struct list_head *list = NULL, *orig_terms = NULL, *terms= NULL; 295cabbf268SIan Rogers char *pattern = NULL; 296cabbf268SIan Rogers 297cabbf268SIan Rogers #define CLEANUP_YYABORT \ 298cabbf268SIan Rogers do { \ 299cabbf268SIan Rogers parse_events_terms__delete($2); \ 300cabbf268SIan Rogers parse_events_terms__delete(orig_terms); \ 301e1e9b78dSIan Rogers free(list); \ 302cabbf268SIan Rogers free($1); \ 303cabbf268SIan Rogers free(pattern); \ 304cabbf268SIan Rogers YYABORT; \ 305cabbf268SIan Rogers } while(0) 3068255718fSAndi Kleen 3074a35a902SArnaldo Carvalho de Melo if (parse_events_copy_term_list($2, &orig_terms)) 308cabbf268SIan Rogers CLEANUP_YYABORT; 309b847cbdcSJiri Olsa 310f7fa827fSJiri Olsa if (error) 311f7fa827fSJiri Olsa error->idx = @1.first_column; 312f7fa827fSJiri Olsa 313a26e4716SIan Rogers list = alloc_list(); 314cabbf268SIan Rogers if (!list) 315cabbf268SIan Rogers CLEANUP_YYABORT; 3163cdc5c2cSKan Liang if (parse_events_add_pmu(_parse_state, list, $1, $2, false, false)) { 3178255718fSAndi Kleen struct perf_pmu *pmu = NULL; 3188255718fSAndi Kleen int ok = 0; 319b2b9d3a3SAgustin Vega-Frias 320b2b9d3a3SAgustin Vega-Frias if (asprintf(&pattern, "%s*", $1) < 0) 321cabbf268SIan Rogers CLEANUP_YYABORT; 3228255718fSAndi Kleen 3238255718fSAndi Kleen while ((pmu = perf_pmu__scan(pmu)) != NULL) { 3248255718fSAndi Kleen char *name = pmu->name; 3258255718fSAndi Kleen 326a820e335SAndi Kleen if (!strncmp(name, "uncore_", 7) && 327a820e335SAndi Kleen strncmp($1, "uncore_", 7)) 328a820e335SAndi Kleen name += 7; 32913d60ba0SKan Liang if (!perf_pmu__match(pattern, name, $1) || 33013d60ba0SKan Liang !perf_pmu__match(pattern, pmu->alias_name, $1)) { 331cabbf268SIan Rogers if (parse_events_copy_term_list(orig_terms, &terms)) 332cabbf268SIan Rogers CLEANUP_YYABORT; 3333cdc5c2cSKan Liang if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, true, false)) 3348255718fSAndi Kleen ok++; 3358255718fSAndi Kleen parse_events_terms__delete(terms); 3368255718fSAndi Kleen } 3378255718fSAndi Kleen } 338b2b9d3a3SAgustin Vega-Frias 3398255718fSAndi Kleen if (!ok) 340cabbf268SIan Rogers CLEANUP_YYABORT; 3418255718fSAndi Kleen } 3424a35a902SArnaldo Carvalho de Melo parse_events_terms__delete($2); 3438255718fSAndi Kleen parse_events_terms__delete(orig_terms); 344ba08829aSIan Rogers free(pattern); 345cabbf268SIan Rogers free($1); 346b847cbdcSJiri Olsa $$ = list; 347cabbf268SIan Rogers #undef CLEANUP_YYABORT 3485f537a26SJiri Olsa } 349ad962273SAdrian Hunter | 350ba32a451SKan Liang PE_KERNEL_PMU_EVENT sep_dc 351ba32a451SKan Liang { 352ba32a451SKan Liang struct list_head *list; 353cabbf268SIan Rogers int err; 354ba32a451SKan Liang 355fb081153SIan Rogers err = parse_events_multi_pmu_add(_parse_state, $1, NULL, &list); 356fb081153SIan Rogers free($1); 357fb081153SIan Rogers if (err < 0) 358fb081153SIan Rogers YYABORT; 359fb081153SIan Rogers $$ = list; 360fb081153SIan Rogers } 361fb081153SIan Rogers | 362fb081153SIan Rogers PE_KERNEL_PMU_EVENT opt_pmu_config 363fb081153SIan Rogers { 364fb081153SIan Rogers struct list_head *list; 365fb081153SIan Rogers int err; 366fb081153SIan Rogers 367fb081153SIan Rogers /* frees $2 */ 368fb081153SIan Rogers err = parse_events_multi_pmu_add(_parse_state, $1, $2, &list); 369cabbf268SIan Rogers free($1); 370cabbf268SIan Rogers if (err < 0) 371231bb2aaSAndi Kleen YYABORT; 372ba32a451SKan Liang $$ = list; 373ba32a451SKan Liang } 374ba32a451SKan Liang | 375864bc8c9SJohn Garry PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF '-' PE_PMU_EVENT_SUF2 sep_dc 376864bc8c9SJohn Garry { 377864bc8c9SJohn Garry struct list_head *list; 378864bc8c9SJohn Garry char pmu_name[128]; 379864bc8c9SJohn Garry snprintf(pmu_name, sizeof(pmu_name), "%s-%s-%s", $1, $3, $5); 380864bc8c9SJohn Garry free($1); 381864bc8c9SJohn Garry free($3); 382864bc8c9SJohn Garry free($5); 383864bc8c9SJohn Garry if (parse_events_multi_pmu_add(_parse_state, pmu_name, NULL, &list) < 0) 384864bc8c9SJohn Garry YYABORT; 385864bc8c9SJohn Garry $$ = list; 386864bc8c9SJohn Garry } 387864bc8c9SJohn Garry | 388ba32a451SKan Liang PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc 389ba32a451SKan Liang { 390ba32a451SKan Liang struct list_head *list; 391ba32a451SKan Liang char pmu_name[128]; 3928255718fSAndi Kleen 393c2412faeSIan Rogers snprintf(pmu_name, sizeof(pmu_name), "%s-%s", $1, $3); 394cabbf268SIan Rogers free($1); 395cabbf268SIan Rogers free($3); 396fb081153SIan Rogers if (parse_events_multi_pmu_add(_parse_state, pmu_name, NULL, &list) < 0) 3978255718fSAndi Kleen YYABORT; 398ba32a451SKan Liang $$ = list; 399ba32a451SKan Liang } 400387ad33fSJiri Olsa | 401387ad33fSJiri Olsa PE_PMU_EVENT_FAKE sep_dc 402387ad33fSJiri Olsa { 403387ad33fSJiri Olsa struct list_head *list; 404387ad33fSJiri Olsa int err; 405387ad33fSJiri Olsa 406387ad33fSJiri Olsa list = alloc_list(); 407387ad33fSJiri Olsa if (!list) 408387ad33fSJiri Olsa YYABORT; 409387ad33fSJiri Olsa 410387ad33fSJiri Olsa err = parse_events_add_pmu(_parse_state, list, $1, NULL, false, false); 411387ad33fSJiri Olsa free($1); 412387ad33fSJiri Olsa if (err < 0) { 413387ad33fSJiri Olsa free(list); 414387ad33fSJiri Olsa YYABORT; 415387ad33fSJiri Olsa } 416387ad33fSJiri Olsa $$ = list; 417387ad33fSJiri Olsa } 418387ad33fSJiri Olsa | 419387ad33fSJiri Olsa PE_PMU_EVENT_FAKE opt_pmu_config 420387ad33fSJiri Olsa { 421387ad33fSJiri Olsa struct list_head *list; 422387ad33fSJiri Olsa int err; 423387ad33fSJiri Olsa 424387ad33fSJiri Olsa list = alloc_list(); 425387ad33fSJiri Olsa if (!list) 426387ad33fSJiri Olsa YYABORT; 427387ad33fSJiri Olsa 428387ad33fSJiri Olsa err = parse_events_add_pmu(_parse_state, list, $1, $2, false, false); 429387ad33fSJiri Olsa free($1); 430387ad33fSJiri Olsa parse_events_terms__delete($2); 431387ad33fSJiri Olsa if (err < 0) { 432387ad33fSJiri Olsa free(list); 433387ad33fSJiri Olsa YYABORT; 434387ad33fSJiri Olsa } 435387ad33fSJiri Olsa $$ = list; 436387ad33fSJiri Olsa } 4375f537a26SJiri Olsa 438cf3506dcSJiri Olsa value_sym: 439cf3506dcSJiri Olsa PE_VALUE_SYM_HW 440cf3506dcSJiri Olsa | 441cf3506dcSJiri Olsa PE_VALUE_SYM_SW 442cf3506dcSJiri Olsa 44389812fc8SJiri Olsa event_legacy_symbol: 444cf3506dcSJiri Olsa value_sym '/' event_config '/' 44589812fc8SJiri Olsa { 446c5cd8ac0SDavid Ahern struct list_head *list; 44789812fc8SJiri Olsa int type = $1 >> 16; 44889812fc8SJiri Olsa int config = $1 & 255; 449cabbf268SIan Rogers int err; 45089812fc8SJiri Olsa 451a26e4716SIan Rogers list = alloc_list(); 452a26e4716SIan Rogers ABORT_ON(!list); 453cabbf268SIan Rogers err = parse_events_add_numeric(_parse_state, list, type, config, $3); 4542146afc6SArnaldo Carvalho de Melo parse_events_terms__delete($3); 455cabbf268SIan Rogers if (err) { 456cabbf268SIan Rogers free_list_evsel(list); 457cabbf268SIan Rogers YYABORT; 458cabbf268SIan Rogers } 459b847cbdcSJiri Olsa $$ = list; 4608f707d84SJiri Olsa } 4618f707d84SJiri Olsa | 462714a92d8SJiri Olsa value_sym sep_slash_slash_dc 4638f707d84SJiri Olsa { 464c5cd8ac0SDavid Ahern struct list_head *list; 4658f707d84SJiri Olsa int type = $1 >> 16; 4668f707d84SJiri Olsa int config = $1 & 255; 4678f707d84SJiri Olsa 468a26e4716SIan Rogers list = alloc_list(); 469a26e4716SIan Rogers ABORT_ON(!list); 4705d9cdc11SArnaldo Carvalho de Melo ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL)); 471b847cbdcSJiri Olsa $$ = list; 47289812fc8SJiri Olsa } 473f0fbb114SAndi Kleen | 474f0fbb114SAndi Kleen PE_VALUE_SYM_TOOL sep_slash_slash_dc 475f0fbb114SAndi Kleen { 476f0fbb114SAndi Kleen struct list_head *list; 477f0fbb114SAndi Kleen 478a26e4716SIan Rogers list = alloc_list(); 479a26e4716SIan Rogers ABORT_ON(!list); 480f0fbb114SAndi Kleen ABORT_ON(parse_events_add_tool(_parse_state, list, $1)); 481f0fbb114SAndi Kleen $$ = list; 482f0fbb114SAndi Kleen } 48389812fc8SJiri Olsa 48489812fc8SJiri Olsa event_legacy_cache: 48543d0b978SWang Nan PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config 48689812fc8SJiri Olsa { 4875d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 4885d9cdc11SArnaldo Carvalho de Melo struct parse_events_error *error = parse_state->error; 489c5cd8ac0SDavid Ahern struct list_head *list; 490cabbf268SIan Rogers int err; 491b847cbdcSJiri Olsa 492a26e4716SIan Rogers list = alloc_list(); 493a26e4716SIan Rogers ABORT_ON(!list); 494c93afadcSJin Yao err = parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6, 495c93afadcSJin Yao parse_state); 49643d0b978SWang Nan parse_events_terms__delete($6); 497cabbf268SIan Rogers free($1); 498cabbf268SIan Rogers free($3); 499cabbf268SIan Rogers free($5); 500cabbf268SIan Rogers if (err) { 501cabbf268SIan Rogers free_list_evsel(list); 502cabbf268SIan Rogers YYABORT; 503cabbf268SIan Rogers } 504b847cbdcSJiri Olsa $$ = list; 50589812fc8SJiri Olsa } 50689812fc8SJiri Olsa | 50743d0b978SWang Nan PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config 50889812fc8SJiri Olsa { 5095d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 5105d9cdc11SArnaldo Carvalho de Melo struct parse_events_error *error = parse_state->error; 511c5cd8ac0SDavid Ahern struct list_head *list; 512cabbf268SIan Rogers int err; 513b847cbdcSJiri Olsa 514a26e4716SIan Rogers list = alloc_list(); 515a26e4716SIan Rogers ABORT_ON(!list); 516c93afadcSJin Yao err = parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4, 517c93afadcSJin Yao parse_state); 51843d0b978SWang Nan parse_events_terms__delete($4); 519cabbf268SIan Rogers free($1); 520cabbf268SIan Rogers free($3); 521cabbf268SIan Rogers if (err) { 522cabbf268SIan Rogers free_list_evsel(list); 523cabbf268SIan Rogers YYABORT; 524cabbf268SIan Rogers } 525b847cbdcSJiri Olsa $$ = list; 52689812fc8SJiri Olsa } 52789812fc8SJiri Olsa | 52843d0b978SWang Nan PE_NAME_CACHE_TYPE opt_event_config 52989812fc8SJiri Olsa { 5305d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 5315d9cdc11SArnaldo Carvalho de Melo struct parse_events_error *error = parse_state->error; 532c5cd8ac0SDavid Ahern struct list_head *list; 533cabbf268SIan Rogers int err; 534b847cbdcSJiri Olsa 535a26e4716SIan Rogers list = alloc_list(); 536a26e4716SIan Rogers ABORT_ON(!list); 537c93afadcSJin Yao err = parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2, 538c93afadcSJin Yao parse_state); 53943d0b978SWang Nan parse_events_terms__delete($2); 540cabbf268SIan Rogers free($1); 541cabbf268SIan Rogers if (err) { 542cabbf268SIan Rogers free_list_evsel(list); 543cabbf268SIan Rogers YYABORT; 544cabbf268SIan Rogers } 545b847cbdcSJiri Olsa $$ = list; 54689812fc8SJiri Olsa } 54789812fc8SJiri Olsa 54889812fc8SJiri Olsa event_legacy_mem: 5493741eb9fSJacob Shin PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc 5503741eb9fSJacob Shin { 5515d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 5523741eb9fSJacob Shin struct list_head *list; 553cabbf268SIan Rogers int err; 5543741eb9fSJacob Shin 555a26e4716SIan Rogers list = alloc_list(); 556a26e4716SIan Rogers ABORT_ON(!list); 557cabbf268SIan Rogers err = parse_events_add_breakpoint(list, &parse_state->idx, 558aa98d848SIan Rogers $2, $6, $4); 559cabbf268SIan Rogers free($6); 560cabbf268SIan Rogers if (err) { 561cabbf268SIan Rogers free(list); 562cabbf268SIan Rogers YYABORT; 563cabbf268SIan Rogers } 5643741eb9fSJacob Shin $$ = list; 5653741eb9fSJacob Shin } 5663741eb9fSJacob Shin | 5673741eb9fSJacob Shin PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc 5683741eb9fSJacob Shin { 5695d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 5703741eb9fSJacob Shin struct list_head *list; 5713741eb9fSJacob Shin 572a26e4716SIan Rogers list = alloc_list(); 573a26e4716SIan Rogers ABORT_ON(!list); 574cabbf268SIan Rogers if (parse_events_add_breakpoint(list, &parse_state->idx, 575aa98d848SIan Rogers $2, NULL, $4)) { 576cabbf268SIan Rogers free(list); 577cabbf268SIan Rogers YYABORT; 578cabbf268SIan Rogers } 5793741eb9fSJacob Shin $$ = list; 5803741eb9fSJacob Shin } 5813741eb9fSJacob Shin | 58289812fc8SJiri Olsa PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc 58389812fc8SJiri Olsa { 5845d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 585c5cd8ac0SDavid Ahern struct list_head *list; 586cabbf268SIan Rogers int err; 587b847cbdcSJiri Olsa 588a26e4716SIan Rogers list = alloc_list(); 589a26e4716SIan Rogers ABORT_ON(!list); 590cabbf268SIan Rogers err = parse_events_add_breakpoint(list, &parse_state->idx, 591aa98d848SIan Rogers $2, $4, 0); 592cabbf268SIan Rogers free($4); 593cabbf268SIan Rogers if (err) { 594cabbf268SIan Rogers free(list); 595cabbf268SIan Rogers YYABORT; 596cabbf268SIan Rogers } 597b847cbdcSJiri Olsa $$ = list; 59889812fc8SJiri Olsa } 59989812fc8SJiri Olsa | 60089812fc8SJiri Olsa PE_PREFIX_MEM PE_VALUE sep_dc 60189812fc8SJiri Olsa { 6025d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 603c5cd8ac0SDavid Ahern struct list_head *list; 604b847cbdcSJiri Olsa 605a26e4716SIan Rogers list = alloc_list(); 606a26e4716SIan Rogers ABORT_ON(!list); 607cabbf268SIan Rogers if (parse_events_add_breakpoint(list, &parse_state->idx, 608aa98d848SIan Rogers $2, NULL, 0)) { 609cabbf268SIan Rogers free(list); 610cabbf268SIan Rogers YYABORT; 611cabbf268SIan Rogers } 612b847cbdcSJiri Olsa $$ = list; 61389812fc8SJiri Olsa } 61489812fc8SJiri Olsa 61589812fc8SJiri Olsa event_legacy_tracepoint: 6161d55e8efSArnaldo Carvalho de Melo tracepoint_name opt_event_config 6172b9032e0SAlexander Yarygin { 6185d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 6195d9cdc11SArnaldo Carvalho de Melo struct parse_events_error *error = parse_state->error; 6202b9032e0SAlexander Yarygin struct list_head *list; 621cabbf268SIan Rogers int err; 6222b9032e0SAlexander Yarygin 623a26e4716SIan Rogers list = alloc_list(); 624a26e4716SIan Rogers ABORT_ON(!list); 62519658171SJiri Olsa if (error) 62619658171SJiri Olsa error->idx = @1.first_column; 627e637d177SHe Kuang 628cabbf268SIan Rogers err = parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event, 629cabbf268SIan Rogers error, $2); 630e637d177SHe Kuang 631cabbf268SIan Rogers parse_events_terms__delete($2); 632cabbf268SIan Rogers free($1.sys); 633cabbf268SIan Rogers free($1.event); 634cabbf268SIan Rogers if (err) { 635cabbf268SIan Rogers free(list); 636e1e9b78dSIan Rogers YYABORT; 637cabbf268SIan Rogers } 6382b9032e0SAlexander Yarygin $$ = list; 6392b9032e0SAlexander Yarygin } 640865582c3SHe Kuang 641865582c3SHe Kuang tracepoint_name: 642865582c3SHe Kuang PE_NAME '-' PE_NAME ':' PE_NAME 643865582c3SHe Kuang { 644865582c3SHe Kuang struct tracepoint_name tracepoint; 645865582c3SHe Kuang 646cabbf268SIan Rogers ABORT_ON(asprintf(&tracepoint.sys, "%s-%s", $1, $3) < 0); 647865582c3SHe Kuang tracepoint.event = $5; 648cabbf268SIan Rogers free($1); 649cabbf268SIan Rogers free($3); 650865582c3SHe Kuang $$ = tracepoint; 651865582c3SHe Kuang } 6522b9032e0SAlexander Yarygin | 65389812fc8SJiri Olsa PE_NAME ':' PE_NAME 65489812fc8SJiri Olsa { 655865582c3SHe Kuang struct tracepoint_name tracepoint = {$1, $3}; 656b847cbdcSJiri Olsa 657865582c3SHe Kuang $$ = tracepoint; 65889812fc8SJiri Olsa } 65989812fc8SJiri Olsa 66089812fc8SJiri Olsa event_legacy_numeric: 66110bf358aSWang Nan PE_VALUE ':' PE_VALUE opt_event_config 66289812fc8SJiri Olsa { 663c5cd8ac0SDavid Ahern struct list_head *list; 664cabbf268SIan Rogers int err; 665b847cbdcSJiri Olsa 666a26e4716SIan Rogers list = alloc_list(); 667a26e4716SIan Rogers ABORT_ON(!list); 668cabbf268SIan Rogers err = parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4); 66910bf358aSWang Nan parse_events_terms__delete($4); 670cabbf268SIan Rogers if (err) { 671cabbf268SIan Rogers free(list); 672cabbf268SIan Rogers YYABORT; 673cabbf268SIan Rogers } 674b847cbdcSJiri Olsa $$ = list; 67589812fc8SJiri Olsa } 67689812fc8SJiri Olsa 67789812fc8SJiri Olsa event_legacy_raw: 67810bf358aSWang Nan PE_RAW opt_event_config 67989812fc8SJiri Olsa { 680c5cd8ac0SDavid Ahern struct list_head *list; 681cabbf268SIan Rogers int err; 682b847cbdcSJiri Olsa 683a26e4716SIan Rogers list = alloc_list(); 684a26e4716SIan Rogers ABORT_ON(!list); 685cabbf268SIan Rogers err = parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, $1, $2); 68610bf358aSWang Nan parse_events_terms__delete($2); 687cabbf268SIan Rogers if (err) { 688cabbf268SIan Rogers free(list); 689cabbf268SIan Rogers YYABORT; 690cabbf268SIan Rogers } 691b847cbdcSJiri Olsa $$ = list; 6928f707d84SJiri Olsa } 6938f707d84SJiri Olsa 69484c86ca1SWang Nan event_bpf_file: 695a34f3be7SWang Nan PE_BPF_OBJECT opt_event_config 69684c86ca1SWang Nan { 6975d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 69884c86ca1SWang Nan struct list_head *list; 699cabbf268SIan Rogers int err; 70084c86ca1SWang Nan 701a26e4716SIan Rogers list = alloc_list(); 702a26e4716SIan Rogers ABORT_ON(!list); 703cabbf268SIan Rogers err = parse_events_load_bpf(parse_state, list, $1, false, $2); 704a34f3be7SWang Nan parse_events_terms__delete($2); 705cabbf268SIan Rogers free($1); 706cabbf268SIan Rogers if (err) { 707cabbf268SIan Rogers free(list); 708cabbf268SIan Rogers YYABORT; 709cabbf268SIan Rogers } 710d509db04SWang Nan $$ = list; 711d509db04SWang Nan } 712d509db04SWang Nan | 713a34f3be7SWang Nan PE_BPF_SOURCE opt_event_config 714d509db04SWang Nan { 715d509db04SWang Nan struct list_head *list; 716cabbf268SIan Rogers int err; 717d509db04SWang Nan 718a26e4716SIan Rogers list = alloc_list(); 719a26e4716SIan Rogers ABORT_ON(!list); 720cabbf268SIan Rogers err = parse_events_load_bpf(_parse_state, list, $1, true, $2); 721a34f3be7SWang Nan parse_events_terms__delete($2); 722cabbf268SIan Rogers if (err) { 723cabbf268SIan Rogers free(list); 724cabbf268SIan Rogers YYABORT; 725cabbf268SIan Rogers } 72684c86ca1SWang Nan $$ = list; 72784c86ca1SWang Nan } 72884c86ca1SWang Nan 7291d55e8efSArnaldo Carvalho de Melo opt_event_config: 7301d55e8efSArnaldo Carvalho de Melo '/' event_config '/' 7311d55e8efSArnaldo Carvalho de Melo { 7321d55e8efSArnaldo Carvalho de Melo $$ = $2; 7331d55e8efSArnaldo Carvalho de Melo } 7341d55e8efSArnaldo Carvalho de Melo | 7351d55e8efSArnaldo Carvalho de Melo '/' '/' 7361d55e8efSArnaldo Carvalho de Melo { 7371d55e8efSArnaldo Carvalho de Melo $$ = NULL; 7381d55e8efSArnaldo Carvalho de Melo } 7391d55e8efSArnaldo Carvalho de Melo | 7401d55e8efSArnaldo Carvalho de Melo { 7411d55e8efSArnaldo Carvalho de Melo $$ = NULL; 7421d55e8efSArnaldo Carvalho de Melo } 7431d55e8efSArnaldo Carvalho de Melo 744ceac7b79SJiri Olsa opt_pmu_config: 745ceac7b79SJiri Olsa '/' event_config '/' 746ceac7b79SJiri Olsa { 747ceac7b79SJiri Olsa $$ = $2; 748ceac7b79SJiri Olsa } 749ceac7b79SJiri Olsa | 750ceac7b79SJiri Olsa '/' '/' 751ceac7b79SJiri Olsa { 752ceac7b79SJiri Olsa $$ = NULL; 753ceac7b79SJiri Olsa } 754ceac7b79SJiri Olsa 75589efb029SJiri Olsa start_terms: event_config 75690e2b22dSJiri Olsa { 7575d9cdc11SArnaldo Carvalho de Melo struct parse_events_state *parse_state = _parse_state; 758cabbf268SIan Rogers if (parse_state->terms) { 759cabbf268SIan Rogers parse_events_terms__delete ($1); 760cabbf268SIan Rogers YYABORT; 761cabbf268SIan Rogers } 7625d9cdc11SArnaldo Carvalho de Melo parse_state->terms = $1; 76390e2b22dSJiri Olsa } 76490e2b22dSJiri Olsa 7658f707d84SJiri Olsa event_config: 7668f707d84SJiri Olsa event_config ',' event_term 7678f707d84SJiri Olsa { 7688f707d84SJiri Olsa struct list_head *head = $1; 7696cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term = $3; 7708f707d84SJiri Olsa 771cabbf268SIan Rogers if (!head) { 7721dc92556SIan Rogers parse_events_term__delete(term); 773cabbf268SIan Rogers YYABORT; 774cabbf268SIan Rogers } 7758f707d84SJiri Olsa list_add_tail(&term->list, head); 7768f707d84SJiri Olsa $$ = $1; 7778f707d84SJiri Olsa } 7788f707d84SJiri Olsa | 7798f707d84SJiri Olsa event_term 7808f707d84SJiri Olsa { 7818f707d84SJiri Olsa struct list_head *head = malloc(sizeof(*head)); 7826cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term = $1; 7838f707d84SJiri Olsa 7848f707d84SJiri Olsa ABORT_ON(!head); 7858f707d84SJiri Olsa INIT_LIST_HEAD(head); 7868f707d84SJiri Olsa list_add_tail(&term->list, head); 7878f707d84SJiri Olsa $$ = head; 7888f707d84SJiri Olsa } 7898f707d84SJiri Olsa 7908f707d84SJiri Olsa event_term: 7913a6c51e4SJiri Olsa PE_RAW 7923a6c51e4SJiri Olsa { 7933a6c51e4SJiri Olsa struct parse_events_term *term; 7943a6c51e4SJiri Olsa 7953a6c51e4SJiri Olsa ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_CONFIG, 7963a6c51e4SJiri Olsa NULL, $1, false, &@1, NULL)); 7973a6c51e4SJiri Olsa $$ = term; 7983a6c51e4SJiri Olsa } 7993a6c51e4SJiri Olsa | 8008f707d84SJiri Olsa PE_NAME '=' PE_NAME 8018f707d84SJiri Olsa { 8026cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 8038f707d84SJiri Olsa 804cabbf268SIan Rogers if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, 805cabbf268SIan Rogers $1, $3, &@1, &@3)) { 806cabbf268SIan Rogers free($1); 807cabbf268SIan Rogers free($3); 808cabbf268SIan Rogers YYABORT; 809cabbf268SIan Rogers } 8108f707d84SJiri Olsa $$ = term; 8118f707d84SJiri Olsa } 8128f707d84SJiri Olsa | 8138f707d84SJiri Olsa PE_NAME '=' PE_VALUE 8148f707d84SJiri Olsa { 8156cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 8168f707d84SJiri Olsa 817cabbf268SIan Rogers if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, 818cabbf268SIan Rogers $1, $3, false, &@1, &@3)) { 819cabbf268SIan Rogers free($1); 820cabbf268SIan Rogers YYABORT; 821cabbf268SIan Rogers } 8228f707d84SJiri Olsa $$ = term; 8238f707d84SJiri Olsa } 8248f707d84SJiri Olsa | 8251d33d6dcSJiri Olsa PE_NAME '=' PE_VALUE_SYM_HW 8261d33d6dcSJiri Olsa { 8276cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 8281d33d6dcSJiri Olsa int config = $3 & 255; 8291d33d6dcSJiri Olsa 830cabbf268SIan Rogers if (parse_events_term__sym_hw(&term, $1, config)) { 831cabbf268SIan Rogers free($1); 832cabbf268SIan Rogers YYABORT; 833cabbf268SIan Rogers } 8341d33d6dcSJiri Olsa $$ = term; 8351d33d6dcSJiri Olsa } 8361d33d6dcSJiri Olsa | 8378f707d84SJiri Olsa PE_NAME 8388f707d84SJiri Olsa { 8396cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 8408f707d84SJiri Olsa 841cabbf268SIan Rogers if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, 842cabbf268SIan Rogers $1, 1, true, &@1, NULL)) { 843cabbf268SIan Rogers free($1); 844cabbf268SIan Rogers YYABORT; 845cabbf268SIan Rogers } 8468f707d84SJiri Olsa $$ = term; 8478f707d84SJiri Olsa } 8488f707d84SJiri Olsa | 8491d33d6dcSJiri Olsa PE_VALUE_SYM_HW 8501d33d6dcSJiri Olsa { 8516cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 8521d33d6dcSJiri Olsa int config = $1 & 255; 8531d33d6dcSJiri Olsa 8546cee6cd3SArnaldo Carvalho de Melo ABORT_ON(parse_events_term__sym_hw(&term, NULL, config)); 8551d33d6dcSJiri Olsa $$ = term; 8561d33d6dcSJiri Olsa } 8571d33d6dcSJiri Olsa | 8586b5fc39bSJiri Olsa PE_TERM '=' PE_NAME 8596b5fc39bSJiri Olsa { 8606cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 8616b5fc39bSJiri Olsa 862cabbf268SIan Rogers if (parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3)) { 863cabbf268SIan Rogers free($3); 864cabbf268SIan Rogers YYABORT; 865cabbf268SIan Rogers } 8666b5fc39bSJiri Olsa $$ = term; 8676b5fc39bSJiri Olsa } 8686b5fc39bSJiri Olsa | 8698f707d84SJiri Olsa PE_TERM '=' PE_VALUE 8708f707d84SJiri Olsa { 8716cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 8728f707d84SJiri Olsa 87399e7138eSJiri Olsa ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, false, &@1, &@3)); 8748f707d84SJiri Olsa $$ = term; 8758f707d84SJiri Olsa } 8768f707d84SJiri Olsa | 8778f707d84SJiri Olsa PE_TERM 8788f707d84SJiri Olsa { 8796cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 8808f707d84SJiri Olsa 88199e7138eSJiri Olsa ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, true, &@1, NULL)); 8828f707d84SJiri Olsa $$ = term; 88389812fc8SJiri Olsa } 884e571e029SWang Nan | 885e571e029SWang Nan PE_NAME array '=' PE_NAME 886e571e029SWang Nan { 887e571e029SWang Nan struct parse_events_term *term; 888e571e029SWang Nan 889cabbf268SIan Rogers if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, 890cabbf268SIan Rogers $1, $4, &@1, &@4)) { 891cabbf268SIan Rogers free($1); 892cabbf268SIan Rogers free($4); 893cabbf268SIan Rogers free($2.ranges); 894cabbf268SIan Rogers YYABORT; 895cabbf268SIan Rogers } 896e571e029SWang Nan term->array = $2; 897e571e029SWang Nan $$ = term; 898e571e029SWang Nan } 899e571e029SWang Nan | 900e571e029SWang Nan PE_NAME array '=' PE_VALUE 901e571e029SWang Nan { 902e571e029SWang Nan struct parse_events_term *term; 903e571e029SWang Nan 904cabbf268SIan Rogers if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, 905cabbf268SIan Rogers $1, $4, false, &@1, &@4)) { 906cabbf268SIan Rogers free($1); 907cabbf268SIan Rogers free($2.ranges); 908cabbf268SIan Rogers YYABORT; 909cabbf268SIan Rogers } 910e571e029SWang Nan term->array = $2; 911e571e029SWang Nan $$ = term; 912e571e029SWang Nan } 913dd60fba7SMathieu Poirier | 914dd60fba7SMathieu Poirier PE_DRV_CFG_TERM 915dd60fba7SMathieu Poirier { 916dd60fba7SMathieu Poirier struct parse_events_term *term; 917b6645a72SIan Rogers char *config = strdup($1); 918dd60fba7SMathieu Poirier 919b6645a72SIan Rogers ABORT_ON(!config); 920cabbf268SIan Rogers if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG, 921cabbf268SIan Rogers config, $1, &@1, NULL)) { 922cabbf268SIan Rogers free($1); 923cabbf268SIan Rogers free(config); 924cabbf268SIan Rogers YYABORT; 925cabbf268SIan Rogers } 926dd60fba7SMathieu Poirier $$ = term; 927dd60fba7SMathieu Poirier } 928e571e029SWang Nan 929e571e029SWang Nan array: 930e571e029SWang Nan '[' array_terms ']' 931e571e029SWang Nan { 932e571e029SWang Nan $$ = $2; 933e571e029SWang Nan } 934e571e029SWang Nan | 935e571e029SWang Nan PE_ARRAY_ALL 936e571e029SWang Nan { 937e571e029SWang Nan $$.nr_ranges = 0; 938e571e029SWang Nan $$.ranges = NULL; 939e571e029SWang Nan } 940e571e029SWang Nan 941e571e029SWang Nan array_terms: 942e571e029SWang Nan array_terms ',' array_term 943e571e029SWang Nan { 944e571e029SWang Nan struct parse_events_array new_array; 945e571e029SWang Nan 946e571e029SWang Nan new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges; 947826100a7SIan Rogers new_array.ranges = realloc($1.ranges, 948826100a7SIan Rogers sizeof(new_array.ranges[0]) * 949e571e029SWang Nan new_array.nr_ranges); 950e571e029SWang Nan ABORT_ON(!new_array.ranges); 951e571e029SWang Nan memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges, 952e571e029SWang Nan $3.nr_ranges * sizeof(new_array.ranges[0])); 953e571e029SWang Nan free($3.ranges); 954e571e029SWang Nan $$ = new_array; 955e571e029SWang Nan } 956e571e029SWang Nan | 957e571e029SWang Nan array_term 958e571e029SWang Nan 959e571e029SWang Nan array_term: 960e571e029SWang Nan PE_VALUE 961e571e029SWang Nan { 962e571e029SWang Nan struct parse_events_array array; 963e571e029SWang Nan 964e571e029SWang Nan array.nr_ranges = 1; 965e571e029SWang Nan array.ranges = malloc(sizeof(array.ranges[0])); 966e571e029SWang Nan ABORT_ON(!array.ranges); 967e571e029SWang Nan array.ranges[0].start = $1; 968e571e029SWang Nan array.ranges[0].length = 1; 969e571e029SWang Nan $$ = array; 970e571e029SWang Nan } 971e571e029SWang Nan | 972e571e029SWang Nan PE_VALUE PE_ARRAY_RANGE PE_VALUE 973e571e029SWang Nan { 974e571e029SWang Nan struct parse_events_array array; 975e571e029SWang Nan 976e571e029SWang Nan ABORT_ON($3 < $1); 977e571e029SWang Nan array.nr_ranges = 1; 978e571e029SWang Nan array.ranges = malloc(sizeof(array.ranges[0])); 979e571e029SWang Nan ABORT_ON(!array.ranges); 980e571e029SWang Nan array.ranges[0].start = $1; 981e571e029SWang Nan array.ranges[0].length = $3 - $1 + 1; 982e571e029SWang Nan $$ = array; 983e571e029SWang Nan } 98489812fc8SJiri Olsa 98589812fc8SJiri Olsa sep_dc: ':' | 98689812fc8SJiri Olsa 987714a92d8SJiri Olsa sep_slash_slash_dc: '/' '/' | ':' | 9888f707d84SJiri Olsa 98989812fc8SJiri Olsa %% 99089812fc8SJiri Olsa 9915d9cdc11SArnaldo Carvalho de Melo void parse_events_error(YYLTYPE *loc, void *parse_state, 9926297d423SJiri Olsa void *scanner __maybe_unused, 9931d037ca1SIrina Tirdea char const *msg __maybe_unused) 99489812fc8SJiri Olsa { 9955d9cdc11SArnaldo Carvalho de Melo parse_events_evlist_error(parse_state, loc->last_column, "parser error"); 99689812fc8SJiri Olsa } 997