1 %define api.pure full !! 1 %pure-parser 2 %parse-param {void *_parse_state} !! 2 %parse-param {void *_data} 3 %parse-param {void *scanner} 3 %parse-param {void *scanner} 4 %lex-param {void* scanner} 4 %lex-param {void* scanner} 5 %locations << 6 5 7 %{ 6 %{ 8 7 9 #ifndef NDEBUG << 10 #define YYDEBUG 1 8 #define YYDEBUG 1 11 #endif << 12 9 13 #include <errno.h> << 14 #include <linux/compiler.h> 10 #include <linux/compiler.h> 15 #include <linux/types.h> !! 11 #include <linux/list.h> 16 #include "pmu.h" !! 12 #include "types.h" 17 #include "pmus.h" !! 13 #include "util.h" 18 #include "evsel.h" << 19 #include "parse-events.h" 14 #include "parse-events.h" 20 #include "parse-events-bison.h" 15 #include "parse-events-bison.h" 21 16 22 int parse_events_lex(YYSTYPE * yylval_param, Y !! 17 extern int parse_events_lex (YYSTYPE* lvalp, void* scanner); 23 void parse_events_error(YYLTYPE *loc, void *pa << 24 18 25 #define PE_ABORT(val) \ !! 19 #define ABORT_ON(val) \ 26 do { \ 20 do { \ 27 if (val == -ENOMEM) \ !! 21 if (val) \ 28 YYNOMEM; \ !! 22 YYABORT; \ 29 YYABORT; \ << 30 } while (0) 23 } while (0) 31 24 32 static struct list_head* alloc_list(void) !! 25 static inc_group_count(struct list_head *list, >> 26 struct parse_events_evlist *data) 33 { 27 { 34 struct list_head *list; !! 28 /* Count groups only have more than 1 members */ 35 !! 29 if (!list_is_last(list->next, list)) 36 list = malloc(sizeof(*list)); !! 30 data->nr_groups++; 37 if (!list) << 38 return NULL; << 39 << 40 INIT_LIST_HEAD(list); << 41 return list; << 42 } << 43 << 44 static void free_list_evsel(struct list_head* << 45 { << 46 struct evsel *evsel, *tmp; << 47 << 48 list_for_each_entry_safe(evsel, tmp, l << 49 list_del_init(&evsel->core.nod << 50 evsel__delete(evsel); << 51 } << 52 free(list_evsel); << 53 } 31 } 54 32 55 %} 33 %} 56 34 57 %token PE_START_EVENTS PE_START_TERMS 35 %token PE_START_EVENTS PE_START_TERMS 58 %token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_S !! 36 %token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM 59 %token PE_VALUE_SYM_TOOL << 60 %token PE_EVENT_NAME 37 %token PE_EVENT_NAME 61 %token PE_RAW PE_NAME !! 38 %token PE_NAME 62 %token PE_MODIFIER_EVENT PE_MODIFIER_BP PE_BP_ !! 39 %token PE_MODIFIER_EVENT PE_MODIFIER_BP 63 %token PE_LEGACY_CACHE !! 40 %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT 64 %token PE_PREFIX_MEM !! 41 %token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP 65 %token PE_ERROR 42 %token PE_ERROR 66 %token PE_DRV_CFG_TERM << 67 %token PE_TERM_HW << 68 %type <num> PE_VALUE 43 %type <num> PE_VALUE 69 %type <num> PE_VALUE_SYM_HW 44 %type <num> PE_VALUE_SYM_HW 70 %type <num> PE_VALUE_SYM_SW 45 %type <num> PE_VALUE_SYM_SW 71 %type <num> PE_VALUE_SYM_TOOL !! 46 %type <num> PE_RAW 72 %type <mod> PE_MODIFIER_EVENT !! 47 %type <num> PE_TERM 73 %type <term_type> PE_TERM << 74 %type <num> value_sym << 75 %type <str> PE_RAW << 76 %type <str> PE_NAME 48 %type <str> PE_NAME 77 %type <str> PE_LEGACY_CACHE !! 49 %type <str> PE_NAME_CACHE_TYPE >> 50 %type <str> PE_NAME_CACHE_OP_RESULT >> 51 %type <str> PE_MODIFIER_EVENT 78 %type <str> PE_MODIFIER_BP 52 %type <str> PE_MODIFIER_BP 79 %type <str> PE_EVENT_NAME 53 %type <str> PE_EVENT_NAME 80 %type <str> PE_DRV_CFG_TERM !! 54 %type <num> value_sym 81 %type <str> name_or_raw !! 55 %type <head> event_config 82 %destructor { free ($$); } <str> << 83 %type <term> event_term 56 %type <term> event_term 84 %destructor { parse_events_term__delete ($$); !! 57 %type <head> event_pmu 85 %type <list_terms> event_config !! 58 %type <head> event_legacy_symbol 86 %type <list_terms> opt_event_config !! 59 %type <head> event_legacy_cache 87 %type <list_terms> opt_pmu_config !! 60 %type <head> event_legacy_mem 88 %destructor { parse_events_terms__delete ($$); !! 61 %type <head> event_legacy_tracepoint 89 %type <list_evsel> event_pmu !! 62 %type <head> event_legacy_numeric 90 %type <list_evsel> event_legacy_symbol !! 63 %type <head> event_legacy_raw 91 %type <list_evsel> event_legacy_cache !! 64 %type <head> event_def 92 %type <list_evsel> event_legacy_mem !! 65 %type <head> event_mod 93 %type <list_evsel> event_legacy_tracepoint !! 66 %type <head> event_name 94 %type <list_evsel> event_legacy_numeric !! 67 %type <head> event 95 %type <list_evsel> event_legacy_raw !! 68 %type <head> events 96 %type <list_evsel> event_def !! 69 %type <head> group_def 97 %type <list_evsel> event_mod !! 70 %type <head> group 98 %type <list_evsel> event_name !! 71 %type <head> groups 99 %type <list_evsel> event << 100 %type <list_evsel> events << 101 %type <list_evsel> group_def << 102 %type <list_evsel> group << 103 %type <list_evsel> groups << 104 %destructor { free_list_evsel ($$); } <list_ev << 105 %type <tracepoint_name> tracepoint_name << 106 %destructor { free ($$.sys); free ($$.event); << 107 %type <hardware_term> PE_TERM_HW << 108 %destructor { free ($$.str); } <hardware_term> << 109 72 110 %union 73 %union 111 { 74 { 112 char *str; 75 char *str; 113 u64 num; 76 u64 num; 114 struct parse_events_modifier mod; !! 77 struct list_head *head; 115 enum parse_events__term_type term_type << 116 struct list_head *list_evsel; << 117 struct parse_events_terms *list_terms; << 118 struct parse_events_term *term; 78 struct parse_events_term *term; 119 struct tracepoint_name { << 120 char *sys; << 121 char *event; << 122 } tracepoint_name; << 123 struct hardware_term { << 124 char *str; << 125 u64 num; << 126 } hardware_term; << 127 } 79 } 128 %% 80 %% 129 81 130 /* << 131 * Entry points. We are either parsing events << 132 * parsing is used for parsing events in sysf << 133 */ << 134 start: 82 start: 135 PE_START_EVENTS start_events 83 PE_START_EVENTS start_events 136 | 84 | 137 PE_START_TERMS start_terms 85 PE_START_TERMS start_terms 138 86 139 start_events: groups 87 start_events: groups 140 { 88 { 141 /* Take the parsed events, groups.. an !! 89 struct parse_events_evlist *data = _data; 142 struct list_head *groups = $1; << 143 struct parse_events_state *parse_state << 144 90 145 list_splice_tail(groups, &parse_state- !! 91 parse_events_update_lists($1, &data->list); 146 free(groups); << 147 } 92 } 148 93 149 groups: /* A list of groups or events. */ !! 94 groups: 150 groups ',' group 95 groups ',' group 151 { 96 { 152 /* Merge group into the list of events !! 97 struct list_head *list = $1; 153 struct list_head *groups = $1; !! 98 struct list_head *group = $3; 154 struct list_head *group = $3; !! 99 155 !! 100 parse_events_update_lists(group, list); 156 list_splice_tail(group, groups); !! 101 $$ = list; 157 free(group); << 158 $$ = groups; << 159 } 102 } 160 | 103 | 161 groups ',' event 104 groups ',' event 162 { 105 { 163 /* Merge event into the list of events !! 106 struct list_head *list = $1; 164 struct list_head *groups = $1; << 165 struct list_head *event = $3; 107 struct list_head *event = $3; 166 108 167 !! 109 parse_events_update_lists(event, list); 168 list_splice_tail(event, groups); !! 110 $$ = list; 169 free(event); << 170 $$ = groups; << 171 } 111 } 172 | 112 | 173 group 113 group 174 | 114 | 175 event 115 event 176 116 177 group: 117 group: 178 group_def ':' PE_MODIFIER_EVENT 118 group_def ':' PE_MODIFIER_EVENT 179 { 119 { 180 /* Apply the modifier to the events in << 181 struct list_head *list = $1; 120 struct list_head *list = $1; 182 int err; << 183 121 184 err = parse_events__modifier_group(_pa !! 122 ABORT_ON(parse_events__modifier_group(list, $3)); 185 if (err) << 186 YYABORT; << 187 $$ = list; 123 $$ = list; 188 } 124 } 189 | 125 | 190 group_def 126 group_def 191 127 192 group_def: 128 group_def: 193 PE_NAME '{' events '}' 129 PE_NAME '{' events '}' 194 { 130 { 195 struct list_head *list = $3; 131 struct list_head *list = $3; 196 132 197 /* !! 133 inc_group_count(list, _data); 198 * Set the first entry of list to be t << 199 * the leader to $1 taking ownership. << 200 */ << 201 parse_events__set_leader($1, list); 134 parse_events__set_leader($1, list); 202 $$ = list; 135 $$ = list; 203 } 136 } 204 | 137 | 205 '{' events '}' 138 '{' events '}' 206 { 139 { 207 struct list_head *list = $2; 140 struct list_head *list = $2; 208 141 209 /* Set the first entry of list to be t !! 142 inc_group_count(list, _data); 210 parse_events__set_leader(NULL, list); 143 parse_events__set_leader(NULL, list); 211 $$ = list; 144 $$ = list; 212 } 145 } 213 146 214 events: 147 events: 215 events ',' event 148 events ',' event 216 { 149 { 217 struct list_head *events = $1; << 218 struct list_head *event = $3; 150 struct list_head *event = $3; >> 151 struct list_head *list = $1; 219 152 220 list_splice_tail(event, events); !! 153 parse_events_update_lists(event, list); 221 free(event); !! 154 $$ = list; 222 $$ = events; << 223 } 155 } 224 | 156 | 225 event 157 event 226 158 227 event: event_mod 159 event: event_mod 228 160 229 event_mod: 161 event_mod: 230 event_name PE_MODIFIER_EVENT 162 event_name PE_MODIFIER_EVENT 231 { 163 { 232 struct list_head *list = $1; 164 struct list_head *list = $1; 233 int err; << 234 165 235 /* 166 /* 236 * Apply modifier on all events added 167 * Apply modifier on all events added by single event definition 237 * (there could be more events added f 168 * (there could be more events added for multiple tracepoint 238 * definitions via '*?'. 169 * definitions via '*?'. 239 */ 170 */ 240 err = parse_events__modifier_event(_pa !! 171 ABORT_ON(parse_events__modifier_event(list, $2, false)); 241 if (err) << 242 YYABORT; << 243 $$ = list; 172 $$ = list; 244 } 173 } 245 | 174 | 246 event_name 175 event_name 247 176 248 event_name: 177 event_name: 249 PE_EVENT_NAME event_def 178 PE_EVENT_NAME event_def 250 { 179 { 251 /* !! 180 ABORT_ON(parse_events_name($2, $1)); 252 * When an event is parsed the text is !! 181 free($1); 253 * the event is set to the str of PE_E << 254 * no name was on an event via a term, << 255 * taking ownership of the allocation. << 256 */ << 257 int err = parse_events__set_default_na << 258 << 259 if (err) { << 260 free_list_evsel($2); << 261 YYNOMEM; << 262 } << 263 $$ = $2; 182 $$ = $2; 264 } 183 } 265 | 184 | 266 event_def 185 event_def 267 186 268 event_def: event_pmu | 187 event_def: event_pmu | 269 event_legacy_symbol | 188 event_legacy_symbol | 270 event_legacy_cache sep_dc | 189 event_legacy_cache sep_dc | 271 event_legacy_mem sep_dc | !! 190 event_legacy_mem | 272 event_legacy_tracepoint sep_dc | 191 event_legacy_tracepoint sep_dc | 273 event_legacy_numeric sep_dc | 192 event_legacy_numeric sep_dc | 274 event_legacy_raw sep_dc 193 event_legacy_raw sep_dc 275 194 276 event_pmu: 195 event_pmu: 277 PE_NAME opt_pmu_config !! 196 PE_NAME '/' event_config '/' 278 { 197 { 279 /* List of created evsels. */ !! 198 struct parse_events_evlist *data = _data; 280 struct list_head *list = NULL; 199 struct list_head *list = NULL; 281 int err = parse_events_multi_pmu_add_o << 282 << 283 parse_events_terms__delete($2); << 284 free($1); << 285 if (err) << 286 PE_ABORT(err); << 287 $$ = list; << 288 } << 289 | << 290 PE_NAME sep_dc << 291 { << 292 struct list_head *list; << 293 int err; << 294 200 295 err = parse_events_multi_pmu_add(_pars !! 201 ABORT_ON(parse_events_add_pmu(&list, &data->idx, $1, $3)); 296 if (err < 0) { !! 202 parse_events__free_terms($3); 297 struct parse_events_state *par << 298 struct parse_events_error *err << 299 char *help; << 300 << 301 if (asprintf(&help, "Unable to << 302 help = NULL; << 303 parse_events_error__handle(err << 304 free($1); << 305 PE_ABORT(err); << 306 } << 307 free($1); << 308 $$ = list; 203 $$ = list; 309 } 204 } 310 205 311 value_sym: 206 value_sym: 312 PE_VALUE_SYM_HW 207 PE_VALUE_SYM_HW 313 | 208 | 314 PE_VALUE_SYM_SW 209 PE_VALUE_SYM_SW 315 210 316 event_legacy_symbol: 211 event_legacy_symbol: 317 value_sym '/' event_config '/' 212 value_sym '/' event_config '/' 318 { 213 { 319 struct list_head *list; !! 214 struct parse_events_evlist *data = _data; >> 215 struct list_head *list = NULL; 320 int type = $1 >> 16; 216 int type = $1 >> 16; 321 int config = $1 & 255; 217 int config = $1 & 255; 322 int err; << 323 bool wildcard = (type == PERF_TYPE_HAR << 324 218 325 list = alloc_list(); !! 219 ABORT_ON(parse_events_add_numeric(&list, &data->idx, 326 if (!list) !! 220 type, config, $3)); 327 YYNOMEM; !! 221 parse_events__free_terms($3); 328 err = parse_events_add_numeric(_parse_ << 329 parse_events_terms__delete($3); << 330 if (err) { << 331 free_list_evsel(list); << 332 PE_ABORT(err); << 333 } << 334 $$ = list; 222 $$ = list; 335 } 223 } 336 | 224 | 337 value_sym sep_slash_slash_dc !! 225 value_sym sep_slash_dc 338 { 226 { 339 struct list_head *list; !! 227 struct parse_events_evlist *data = _data; >> 228 struct list_head *list = NULL; 340 int type = $1 >> 16; 229 int type = $1 >> 16; 341 int config = $1 & 255; 230 int config = $1 & 255; 342 bool wildcard = (type == PERF_TYPE_HAR << 343 int err; << 344 231 345 list = alloc_list(); !! 232 ABORT_ON(parse_events_add_numeric(&list, &data->idx, 346 if (!list) !! 233 type, config, NULL)); 347 YYNOMEM; << 348 err = parse_events_add_numeric(_parse_ << 349 if (err) << 350 PE_ABORT(err); << 351 $$ = list; << 352 } << 353 | << 354 PE_VALUE_SYM_TOOL sep_slash_slash_dc << 355 { << 356 struct list_head *list; << 357 int err; << 358 << 359 list = alloc_list(); << 360 if (!list) << 361 YYNOMEM; << 362 err = parse_events_add_tool(_parse_sta << 363 if (err) << 364 YYNOMEM; << 365 $$ = list; 234 $$ = list; 366 } 235 } 367 236 368 event_legacy_cache: 237 event_legacy_cache: 369 PE_LEGACY_CACHE opt_event_config !! 238 PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT 370 { 239 { 371 struct parse_events_state *parse_state !! 240 struct parse_events_evlist *data = _data; 372 struct list_head *list; !! 241 struct list_head *list = NULL; 373 int err; << 374 << 375 list = alloc_list(); << 376 if (!list) << 377 YYNOMEM; << 378 << 379 err = parse_events_add_cache(list, &pa << 380 242 381 parse_events_terms__delete($2); !! 243 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, $5)); 382 free($1); << 383 if (err) { << 384 free_list_evsel(list); << 385 PE_ABORT(err); << 386 } << 387 $$ = list; 244 $$ = list; 388 } 245 } 389 !! 246 | 390 event_legacy_mem: !! 247 PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT 391 PE_PREFIX_MEM PE_VALUE PE_BP_SLASH PE_VALUE PE << 392 { 248 { 393 struct list_head *list; !! 249 struct parse_events_evlist *data = _data; 394 int err; !! 250 struct list_head *list = NULL; 395 << 396 list = alloc_list(); << 397 if (!list) << 398 YYNOMEM; << 399 251 400 err = parse_events_add_breakpoint(_par !! 252 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, NULL)); 401 $2, << 402 parse_events_terms__delete($7); << 403 free($6); << 404 if (err) { << 405 free(list); << 406 PE_ABORT(err); << 407 } << 408 $$ = list; 253 $$ = list; 409 } 254 } 410 | 255 | 411 PE_PREFIX_MEM PE_VALUE PE_BP_SLASH PE_VALUE op !! 256 PE_NAME_CACHE_TYPE 412 { 257 { 413 struct list_head *list; !! 258 struct parse_events_evlist *data = _data; 414 int err; !! 259 struct list_head *list = NULL; 415 << 416 list = alloc_list(); << 417 if (!list) << 418 YYNOMEM; << 419 260 420 err = parse_events_add_breakpoint(_par !! 261 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, NULL, NULL)); 421 $2, << 422 parse_events_terms__delete($5); << 423 if (err) { << 424 free(list); << 425 PE_ABORT(err); << 426 } << 427 $$ = list; 262 $$ = list; 428 } 263 } 429 | << 430 PE_PREFIX_MEM PE_VALUE PE_BP_COLON PE_MODIFIER << 431 { << 432 struct list_head *list; << 433 int err; << 434 264 435 list = alloc_list(); !! 265 event_legacy_mem: 436 if (!list) !! 266 PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc 437 YYNOMEM; !! 267 { >> 268 struct parse_events_evlist *data = _data; >> 269 struct list_head *list = NULL; 438 270 439 err = parse_events_add_breakpoint(_par !! 271 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx, 440 $2, !! 272 (void *) $2, $4)); 441 parse_events_terms__delete($5); << 442 free($4); << 443 if (err) { << 444 free(list); << 445 PE_ABORT(err); << 446 } << 447 $$ = list; 273 $$ = list; 448 } 274 } 449 | 275 | 450 PE_PREFIX_MEM PE_VALUE opt_event_config !! 276 PE_PREFIX_MEM PE_VALUE sep_dc 451 { 277 { 452 struct list_head *list; !! 278 struct parse_events_evlist *data = _data; 453 int err; !! 279 struct list_head *list = NULL; 454 280 455 list = alloc_list(); !! 281 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx, 456 if (!list) !! 282 (void *) $2, NULL)); 457 YYNOMEM; << 458 err = parse_events_add_breakpoint(_par << 459 $2, << 460 parse_events_terms__delete($3); << 461 if (err) { << 462 free(list); << 463 PE_ABORT(err); << 464 } << 465 $$ = list; 283 $$ = list; 466 } 284 } 467 285 468 event_legacy_tracepoint: 286 event_legacy_tracepoint: 469 tracepoint_name opt_event_config << 470 { << 471 struct parse_events_state *parse_state << 472 struct parse_events_error *error = par << 473 struct list_head *list; << 474 int err; << 475 << 476 list = alloc_list(); << 477 if (!list) << 478 YYNOMEM; << 479 << 480 err = parse_events_add_tracepoint(pars << 481 error, << 482 << 483 parse_events_terms__delete($2); << 484 free($1.sys); << 485 free($1.event); << 486 if (err) { << 487 free(list); << 488 PE_ABORT(err); << 489 } << 490 $$ = list; << 491 } << 492 << 493 tracepoint_name: << 494 PE_NAME ':' PE_NAME 287 PE_NAME ':' PE_NAME 495 { 288 { 496 struct tracepoint_name tracepoint = {$ !! 289 struct parse_events_evlist *data = _data; >> 290 struct list_head *list = NULL; 497 291 498 $$ = tracepoint; !! 292 ABORT_ON(parse_events_add_tracepoint(&list, &data->idx, $1, $3)); >> 293 $$ = list; 499 } 294 } 500 295 501 event_legacy_numeric: 296 event_legacy_numeric: 502 PE_VALUE ':' PE_VALUE opt_event_config !! 297 PE_VALUE ':' PE_VALUE 503 { 298 { 504 struct list_head *list; !! 299 struct parse_events_evlist *data = _data; 505 int err; !! 300 struct list_head *list = NULL; 506 301 507 list = alloc_list(); !! 302 ABORT_ON(parse_events_add_numeric(&list, &data->idx, (u32)$1, $3, NULL)); 508 if (!list) << 509 YYNOMEM; << 510 err = parse_events_add_numeric(_parse_ << 511 /*wildc << 512 parse_events_terms__delete($4); << 513 if (err) { << 514 free(list); << 515 PE_ABORT(err); << 516 } << 517 $$ = list; 303 $$ = list; 518 } 304 } 519 305 520 event_legacy_raw: 306 event_legacy_raw: 521 PE_RAW opt_event_config !! 307 PE_RAW 522 { 308 { 523 struct list_head *list; !! 309 struct parse_events_evlist *data = _data; 524 int err; !! 310 struct list_head *list = NULL; 525 u64 num; << 526 311 527 list = alloc_list(); !! 312 ABORT_ON(parse_events_add_numeric(&list, &data->idx, 528 if (!list) !! 313 PERF_TYPE_RAW, $1, NULL)); 529 YYNOMEM; << 530 errno = 0; << 531 num = strtoull($1 + 1, NULL, 16); << 532 /* Given the lexer will only give [a-f << 533 if (errno) << 534 YYABORT; << 535 free($1); << 536 err = parse_events_add_numeric(_parse_ << 537 /*wildc << 538 parse_events_terms__delete($2); << 539 if (err) { << 540 free(list); << 541 PE_ABORT(err); << 542 } << 543 $$ = list; 314 $$ = list; 544 } 315 } 545 316 546 opt_event_config: << 547 '/' event_config '/' << 548 { << 549 $$ = $2; << 550 } << 551 | << 552 '/' '/' << 553 { << 554 $$ = NULL; << 555 } << 556 | << 557 { << 558 $$ = NULL; << 559 } << 560 << 561 opt_pmu_config: << 562 '/' event_config '/' << 563 { << 564 $$ = $2; << 565 } << 566 | << 567 '/' '/' << 568 { << 569 $$ = NULL; << 570 } << 571 << 572 start_terms: event_config 317 start_terms: event_config 573 { 318 { 574 struct parse_events_state *parse_state !! 319 struct parse_events_terms *data = _data; 575 if (parse_state->terms) { !! 320 data->terms = $1; 576 parse_events_terms__delete ($1 << 577 YYABORT; << 578 } << 579 parse_state->terms = $1; << 580 } 321 } 581 322 582 event_config: 323 event_config: 583 event_config ',' event_term 324 event_config ',' event_term 584 { 325 { 585 struct parse_events_terms *head = $1; !! 326 struct list_head *head = $1; 586 struct parse_events_term *term = $3; 327 struct parse_events_term *term = $3; 587 328 588 if (!head) { !! 329 ABORT_ON(!head); 589 parse_events_term__delete(term !! 330 list_add_tail(&term->list, head); 590 YYABORT; << 591 } << 592 list_add_tail(&term->list, &head->term << 593 $$ = $1; 331 $$ = $1; 594 } 332 } 595 | 333 | 596 event_term 334 event_term 597 { 335 { 598 struct parse_events_terms *head = mall !! 336 struct list_head *head = malloc(sizeof(*head)); 599 struct parse_events_term *term = $1; 337 struct parse_events_term *term = $1; 600 338 601 if (!head) !! 339 ABORT_ON(!head); 602 YYNOMEM; !! 340 INIT_LIST_HEAD(head); 603 parse_events_terms__init(head); !! 341 list_add_tail(&term->list, head); 604 list_add_tail(&term->list, &head->term << 605 $$ = head; 342 $$ = head; 606 } 343 } 607 344 608 name_or_raw: PE_RAW | PE_NAME | PE_LEGACY_CACH << 609 | << 610 PE_TERM_HW << 611 { << 612 $$ = $1.str; << 613 } << 614 << 615 event_term: 345 event_term: 616 PE_RAW !! 346 PE_NAME '=' PE_NAME 617 { << 618 struct parse_events_term *term; << 619 int err = parse_events_term__str(&term << 620 strdu << 621 << 622 if (err) { << 623 free($1); << 624 PE_ABORT(err); << 625 } << 626 $$ = term; << 627 } << 628 | << 629 name_or_raw '=' name_or_raw << 630 { 347 { 631 struct parse_events_term *term; 348 struct parse_events_term *term; 632 int err = parse_events_term__str(&term << 633 349 634 if (err) { !! 350 ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, 635 free($1); !! 351 $1, $3)); 636 free($3); << 637 PE_ABORT(err); << 638 } << 639 $$ = term; 352 $$ = term; 640 } 353 } 641 | 354 | 642 name_or_raw '=' PE_VALUE !! 355 PE_NAME '=' PE_VALUE 643 { 356 { 644 struct parse_events_term *term; 357 struct parse_events_term *term; 645 int err = parse_events_term__num(&term << 646 $1, $ << 647 358 648 if (err) { !! 359 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, 649 free($1); !! 360 $1, $3)); 650 PE_ABORT(err); << 651 } << 652 $$ = term; 361 $$ = term; 653 } 362 } 654 | 363 | 655 PE_LEGACY_CACHE !! 364 PE_NAME '=' PE_VALUE_SYM_HW 656 { 365 { 657 struct parse_events_term *term; 366 struct parse_events_term *term; 658 int err = parse_events_term__num(&term !! 367 int config = $3 & 255; 659 $1, / << 660 368 661 if (err) { !! 369 ABORT_ON(parse_events_term__sym_hw(&term, $1, config)); 662 free($1); << 663 PE_ABORT(err); << 664 } << 665 $$ = term; 370 $$ = term; 666 } 371 } 667 | 372 | 668 PE_NAME 373 PE_NAME 669 { 374 { 670 struct parse_events_term *term; 375 struct parse_events_term *term; 671 int err = parse_events_term__num(&term << 672 $1, / << 673 376 674 if (err) { !! 377 ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, 675 free($1); !! 378 $1, 1)); 676 PE_ABORT(err); << 677 } << 678 $$ = term; << 679 } << 680 | << 681 PE_TERM_HW << 682 { << 683 struct parse_events_term *term; << 684 int err = parse_events_term__num(&term << 685 $1.st << 686 &@1, << 687 << 688 if (err) { << 689 free($1.str); << 690 PE_ABORT(err); << 691 } << 692 $$ = term; 379 $$ = term; 693 } 380 } 694 | 381 | 695 PE_TERM '=' name_or_raw !! 382 PE_VALUE_SYM_HW 696 { 383 { 697 struct parse_events_term *term; 384 struct parse_events_term *term; 698 int err = parse_events_term__str(&term !! 385 int config = $1 & 255; 699 386 700 if (err) { !! 387 ABORT_ON(parse_events_term__sym_hw(&term, NULL, config)); 701 free($3); << 702 PE_ABORT(err); << 703 } << 704 $$ = term; 388 $$ = term; 705 } 389 } 706 | 390 | 707 PE_TERM '=' PE_TERM !! 391 PE_TERM '=' PE_NAME 708 { 392 { 709 struct parse_events_term *term; 393 struct parse_events_term *term; 710 int err = parse_events_term__term(&ter << 711 << 712 if (err) << 713 PE_ABORT(err); << 714 394 >> 395 ABORT_ON(parse_events_term__str(&term, (int)$1, NULL, $3)); 715 $$ = term; 396 $$ = term; 716 } 397 } 717 | 398 | 718 PE_TERM '=' PE_VALUE 399 PE_TERM '=' PE_VALUE 719 { 400 { 720 struct parse_events_term *term; 401 struct parse_events_term *term; 721 int err = parse_events_term__num(&term << 722 /*con << 723 &@1, << 724 << 725 if (err) << 726 PE_ABORT(err); << 727 402 >> 403 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3)); 728 $$ = term; 404 $$ = term; 729 } 405 } 730 | 406 | 731 PE_TERM 407 PE_TERM 732 { 408 { 733 struct parse_events_term *term; 409 struct parse_events_term *term; 734 int err = parse_events_term__num(&term << 735 /*con << 736 &@1, << 737 << 738 if (err) << 739 PE_ABORT(err); << 740 410 741 $$ = term; !! 411 ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1)); 742 } << 743 | << 744 PE_DRV_CFG_TERM << 745 { << 746 struct parse_events_term *term; << 747 char *config = strdup($1); << 748 int err; << 749 << 750 if (!config) << 751 YYNOMEM; << 752 err = parse_events_term__str(&term, PA << 753 if (err) { << 754 free($1); << 755 free(config); << 756 PE_ABORT(err); << 757 } << 758 $$ = term; 412 $$ = term; 759 } 413 } 760 414 761 sep_dc: ':' | 415 sep_dc: ':' | 762 416 763 sep_slash_slash_dc: '/' '/' | ':' | !! 417 sep_slash_dc: '/' | ':' | 764 418 765 %% 419 %% 766 420 767 void parse_events_error(YYLTYPE *loc, void *_p !! 421 void parse_events_error(void *data __maybe_unused, void *scanner __maybe_unused, 768 void *scanner __maybe_ << 769 char const *msg __mayb 422 char const *msg __maybe_unused) 770 { 423 { 771 struct parse_events_state *parse_state << 772 << 773 if (!parse_state->error || !list_empty << 774 return; << 775 << 776 parse_events_error__handle(parse_state << 777 strdup("Unr << 778 } 424 }
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.