1 1 2 %option reentrant 2 %option reentrant 3 %option bison-bridge 3 %option bison-bridge 4 %option prefix="parse_events_" 4 %option prefix="parse_events_" 5 %option stack 5 %option stack 6 %option bison-locations 6 %option bison-locations 7 %option yylineno 7 %option yylineno 8 %option reject 8 %option reject 9 9 10 %{ 10 %{ 11 #include <errno.h> 11 #include <errno.h> 12 #include <sys/types.h> 12 #include <sys/types.h> 13 #include <sys/stat.h> 13 #include <sys/stat.h> 14 #include <unistd.h> 14 #include <unistd.h> 15 #include "parse-events.h" 15 #include "parse-events.h" 16 #include "parse-events-bison.h" 16 #include "parse-events-bison.h" 17 #include "evsel.h" 17 #include "evsel.h" 18 18 19 char *parse_events_get_text(yyscan_t yyscanner 19 char *parse_events_get_text(yyscan_t yyscanner); 20 YYSTYPE *parse_events_get_lval(yyscan_t yyscan 20 YYSTYPE *parse_events_get_lval(yyscan_t yyscanner); 21 int parse_events_get_column(yyscan_t yyscanner 21 int parse_events_get_column(yyscan_t yyscanner); 22 int parse_events_get_leng(yyscan_t yyscanner); 22 int parse_events_get_leng(yyscan_t yyscanner); 23 23 24 static int get_column(yyscan_t scanner) 24 static int get_column(yyscan_t scanner) 25 { 25 { 26 return parse_events_get_column(scanner 26 return parse_events_get_column(scanner) - parse_events_get_leng(scanner); 27 } 27 } 28 28 29 static int value(struct parse_events_state *pa 29 static int value(struct parse_events_state *parse_state, yyscan_t scanner, int base) 30 { 30 { 31 YYSTYPE *yylval = parse_events_get_lva 31 YYSTYPE *yylval = parse_events_get_lval(scanner); 32 char *text = parse_events_get_text(sca 32 char *text = parse_events_get_text(scanner); 33 u64 num; 33 u64 num; 34 34 35 errno = 0; 35 errno = 0; 36 num = strtoull(text, NULL, base); 36 num = strtoull(text, NULL, base); 37 if (errno) { 37 if (errno) { 38 struct parse_events_error *err 38 struct parse_events_error *error = parse_state->error; 39 char *help = NULL; 39 char *help = NULL; 40 40 41 if (asprintf(&help, "Bad base 41 if (asprintf(&help, "Bad base %d number \"%s\"", base, text) > 0) 42 parse_events_error__ha 42 parse_events_error__handle(error, get_column(scanner), help , NULL); 43 43 44 return PE_ERROR; 44 return PE_ERROR; 45 } 45 } 46 46 47 yylval->num = num; 47 yylval->num = num; 48 return PE_VALUE; 48 return PE_VALUE; 49 } 49 } 50 50 51 static int str(yyscan_t scanner, int token) 51 static int str(yyscan_t scanner, int token) 52 { 52 { 53 YYSTYPE *yylval = parse_events_get_lva 53 YYSTYPE *yylval = parse_events_get_lval(scanner); 54 char *text = parse_events_get_text(sca 54 char *text = parse_events_get_text(scanner); 55 55 56 if (text[0] != '\'') { 56 if (text[0] != '\'') { 57 yylval->str = strdup(text); 57 yylval->str = strdup(text); 58 } else { 58 } else { 59 /* 59 /* 60 * If a text tag specified on 60 * If a text tag specified on the command line 61 * contains opening single qui 61 * contains opening single quite ' then it is 62 * expected that the tag ends 62 * expected that the tag ends with single quote 63 * as well, like this: 63 * as well, like this: 64 * name=\'CPU_CLK_UNHALTED 64 * name=\'CPU_CLK_UNHALTED.THREAD:cmask=1\' 65 * quotes need to be escaped t 65 * quotes need to be escaped to bypass shell 66 * processing. 66 * processing. 67 */ 67 */ 68 yylval->str = strndup(&text[1] 68 yylval->str = strndup(&text[1], strlen(text) - 2); 69 } 69 } 70 70 71 return token; 71 return token; 72 } 72 } 73 73 74 static int lc_str(yyscan_t scanner, const stru 74 static int lc_str(yyscan_t scanner, const struct parse_events_state *state) 75 { 75 { 76 return str(scanner, state->match_legac 76 return str(scanner, state->match_legacy_cache_terms ? PE_LEGACY_CACHE : PE_NAME); 77 } 77 } 78 78 79 /* 79 /* 80 * This function is called when the parser get 80 * This function is called when the parser gets two kind of input: 81 * 81 * 82 * @cfg1 or @cfg2=config 82 * @cfg1 or @cfg2=config 83 * 83 * 84 * The leading '@' is stripped off before 'cfg 84 * The leading '@' is stripped off before 'cfg1' and 'cfg2=config' are given to 85 * bison. In the latter case it is necessary 85 * bison. In the latter case it is necessary to keep the string intact so that 86 * the PMU kernel driver can determine what co 86 * the PMU kernel driver can determine what configurable is associated to 87 * 'config'. 87 * 'config'. 88 */ 88 */ 89 static int drv_str(yyscan_t scanner, int token 89 static int drv_str(yyscan_t scanner, int token) 90 { 90 { 91 YYSTYPE *yylval = parse_events_get_lva 91 YYSTYPE *yylval = parse_events_get_lval(scanner); 92 char *text = parse_events_get_text(sca 92 char *text = parse_events_get_text(scanner); 93 93 94 /* Strip off the '@' */ 94 /* Strip off the '@' */ 95 yylval->str = strdup(text + 1); 95 yylval->str = strdup(text + 1); 96 return token; 96 return token; 97 } 97 } 98 98 99 /* 99 /* 100 * Use yyless to return all the characaters to 100 * Use yyless to return all the characaters to the input. Update the column for 101 * location debugging. If __alloc is non-zero 101 * location debugging. If __alloc is non-zero set yylval to the text for the 102 * returned token's value. 102 * returned token's value. 103 */ 103 */ 104 #define REWIND(__alloc) 104 #define REWIND(__alloc) \ 105 do { 105 do { \ 106 YYSTYPE *__yylval = parse_events_get_l 106 YYSTYPE *__yylval = parse_events_get_lval(yyscanner); \ 107 char *text = parse_events_get_text(yys 107 char *text = parse_events_get_text(yyscanner); \ 108 108 \ 109 if (__alloc) 109 if (__alloc) \ 110 __yylval->str = strdup(text); 110 __yylval->str = strdup(text); \ 111 111 \ 112 yycolumn -= strlen(text); 112 yycolumn -= strlen(text); \ 113 yyless(0); 113 yyless(0); \ 114 } while (0) 114 } while (0) 115 115 116 static int sym(yyscan_t scanner, int type, int 116 static int sym(yyscan_t scanner, int type, int config) 117 { 117 { 118 YYSTYPE *yylval = parse_events_get_lva 118 YYSTYPE *yylval = parse_events_get_lval(scanner); 119 119 120 yylval->num = (type << 16) + config; 120 yylval->num = (type << 16) + config; 121 return type == PERF_TYPE_HARDWARE ? PE 121 return type == PERF_TYPE_HARDWARE ? PE_VALUE_SYM_HW : PE_VALUE_SYM_SW; 122 } 122 } 123 123 124 static int tool(yyscan_t scanner, enum perf_to 124 static int tool(yyscan_t scanner, enum perf_tool_event event) 125 { 125 { 126 YYSTYPE *yylval = parse_events_get_lva 126 YYSTYPE *yylval = parse_events_get_lval(scanner); 127 127 128 yylval->num = event; 128 yylval->num = event; 129 return PE_VALUE_SYM_TOOL; 129 return PE_VALUE_SYM_TOOL; 130 } 130 } 131 131 132 static int term(yyscan_t scanner, enum parse_e 132 static int term(yyscan_t scanner, enum parse_events__term_type type) 133 { 133 { 134 YYSTYPE *yylval = parse_events_get_lva 134 YYSTYPE *yylval = parse_events_get_lval(scanner); 135 135 136 yylval->term_type = type; 136 yylval->term_type = type; 137 return PE_TERM; 137 return PE_TERM; 138 } 138 } 139 139 140 static int hw_term(yyscan_t scanner, int confi 140 static int hw_term(yyscan_t scanner, int config) 141 { 141 { 142 YYSTYPE *yylval = parse_events_get_lva 142 YYSTYPE *yylval = parse_events_get_lval(scanner); 143 char *text = parse_events_get_text(sca 143 char *text = parse_events_get_text(scanner); 144 144 145 yylval->hardware_term.str = strdup(tex 145 yylval->hardware_term.str = strdup(text); 146 yylval->hardware_term.num = PERF_TYPE_ 146 yylval->hardware_term.num = PERF_TYPE_HARDWARE + config; 147 return PE_TERM_HW; 147 return PE_TERM_HW; 148 } 148 } 149 149 150 static void modifiers_error(struct parse_event 150 static void modifiers_error(struct parse_events_state *parse_state, yyscan_t scanner, 151 int pos, char mod_ 151 int pos, char mod_char, const char *mod_name) 152 { 152 { 153 struct parse_events_error *error = par 153 struct parse_events_error *error = parse_state->error; 154 char *help = NULL; 154 char *help = NULL; 155 155 156 if (asprintf(&help, "Duplicate modifie 156 if (asprintf(&help, "Duplicate modifier '%c' (%s)", mod_char, mod_name) > 0) 157 parse_events_error__handle(err 157 parse_events_error__handle(error, get_column(scanner) + pos, help , NULL); 158 } 158 } 159 159 160 static int modifiers(struct parse_events_state 160 static int modifiers(struct parse_events_state *parse_state, yyscan_t scanner) 161 { 161 { 162 YYSTYPE *yylval = parse_events_get_lva 162 YYSTYPE *yylval = parse_events_get_lval(scanner); 163 char *text = parse_events_get_text(sca 163 char *text = parse_events_get_text(scanner); 164 struct parse_events_modifier mod = { . 164 struct parse_events_modifier mod = { .precise = 0, }; 165 165 166 for (size_t i = 0, n = strlen(text); i 166 for (size_t i = 0, n = strlen(text); i < n; i++) { 167 #define CASE(c, field) 167 #define CASE(c, field) \ 168 case c: 168 case c: \ 169 if (mod.field) { 169 if (mod.field) { \ 170 modifiers_erro 170 modifiers_error(parse_state, scanner, i, c, #field); \ 171 return PE_ERRO 171 return PE_ERROR; \ 172 } 172 } \ 173 mod.field = true; 173 mod.field = true; \ 174 break 174 break 175 175 176 switch (text[i]) { 176 switch (text[i]) { 177 CASE('u', user); 177 CASE('u', user); 178 CASE('k', kernel); 178 CASE('k', kernel); 179 CASE('h', hypervisor); 179 CASE('h', hypervisor); 180 CASE('I', non_idle); 180 CASE('I', non_idle); 181 CASE('G', guest); 181 CASE('G', guest); 182 CASE('H', host); 182 CASE('H', host); 183 case 'p': 183 case 'p': 184 mod.precise++; 184 mod.precise++; 185 /* 185 /* 186 * precise ip: 186 * precise ip: 187 * 187 * 188 * 0 - SAMPLE_IP can 188 * 0 - SAMPLE_IP can have arbitrary skid 189 * 1 - SAMPLE_IP must 189 * 1 - SAMPLE_IP must have constant skid 190 * 2 - SAMPLE_IP requ 190 * 2 - SAMPLE_IP requested to have 0 skid 191 * 3 - SAMPLE_IP must 191 * 3 - SAMPLE_IP must have 0 skid 192 * 192 * 193 * See also PERF_RECO 193 * See also PERF_RECORD_MISC_EXACT_IP 194 */ 194 */ 195 if (mod.precise > 3) { 195 if (mod.precise > 3) { 196 struct parse_e 196 struct parse_events_error *error = parse_state->error; 197 char *help = s 197 char *help = strdup("Maximum precise value is 3"); 198 198 199 if (help) { 199 if (help) { 200 parse_ 200 parse_events_error__handle(error, get_column(scanner) + i, 201 201 help , NULL); 202 } 202 } 203 return PE_ERRO 203 return PE_ERROR; 204 } 204 } 205 break; 205 break; 206 CASE('P', precise_max); 206 CASE('P', precise_max); 207 CASE('S', sample_read); 207 CASE('S', sample_read); 208 CASE('D', pinned); 208 CASE('D', pinned); 209 CASE('W', weak); 209 CASE('W', weak); 210 CASE('e', exclusive); 210 CASE('e', exclusive); 211 CASE('b', bpf); 211 CASE('b', bpf); 212 CASE('R', retire_lat); 212 CASE('R', retire_lat); 213 default: 213 default: 214 return PE_ERROR; 214 return PE_ERROR; 215 } 215 } 216 #undef CASE 216 #undef CASE 217 } 217 } 218 yylval->mod = mod; 218 yylval->mod = mod; 219 return PE_MODIFIER_EVENT; 219 return PE_MODIFIER_EVENT; 220 } 220 } 221 221 222 #define YY_USER_ACTION 222 #define YY_USER_ACTION \ 223 do { 223 do { \ 224 yylloc->last_column = yylloc->first_c 224 yylloc->last_column = yylloc->first_column; \ 225 yylloc->first_column = yycolumn; 225 yylloc->first_column = yycolumn; \ 226 yycolumn += yyleng; 226 yycolumn += yyleng; \ 227 } while (0); 227 } while (0); 228 228 229 #define USER_REJECT \ 229 #define USER_REJECT \ 230 yycolumn -= yyleng; \ 230 yycolumn -= yyleng; \ 231 REJECT 231 REJECT 232 232 233 %} 233 %} 234 234 235 %x mem 235 %x mem 236 %s config 236 %s config 237 %x event 237 %x event 238 238 239 group [^,{}/]*[{][^}]*[}][^,{}/]* 239 group [^,{}/]*[{][^}]*[}][^,{}/]* 240 event_pmu [^,{}/]+[/][^/]*[/][^,{}/]* 240 event_pmu [^,{}/]+[/][^/]*[/][^,{}/]* 241 event [^,{}/]+ 241 event [^,{}/]+ 242 242 243 num_dec [0-9]+ 243 num_dec [0-9]+ 244 num_hex 0x[a-fA-F0-9]{1,16} 244 num_hex 0x[a-fA-F0-9]{1,16} 245 num_raw_hex [a-fA-F0-9]{1,16} 245 num_raw_hex [a-fA-F0-9]{1,16} 246 name [a-zA-Z0-9_*?\[\]][a-zA-Z0-9_* 246 name [a-zA-Z0-9_*?\[\]][a-zA-Z0-9_*?.\[\]!\-]* 247 name_tag [\'][a-zA-Z0-9_*?\[\]][a-zA-Z0 247 name_tag [\'][a-zA-Z0-9_*?\[\]][a-zA-Z0-9_*?\-,\.\[\]:=]*[\'] 248 name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.:]* 248 name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.:]* 249 drv_cfg_term [a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*? 249 drv_cfg_term [a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)? 250 /* 250 /* 251 * If you add a modifier you need to update ch 251 * If you add a modifier you need to update check_modifier(). 252 * Also, the letters in modifier_event must no 252 * Also, the letters in modifier_event must not be in modifier_bp. 253 */ 253 */ 254 modifier_event [ukhpPGHSDIWebR]{1,16} 254 modifier_event [ukhpPGHSDIWebR]{1,16} 255 modifier_bp [rwx]{1,3} 255 modifier_bp [rwx]{1,3} 256 lc_type (L1-dcache|l1-d|l1d|L1-data|L1 256 lc_type (L1-dcache|l1-d|l1d|L1-data|L1-icache|l1-i|l1i|L1-instruction|LLC|L2|dTLB|d-tlb|Data-TLB|iTLB|i-tlb|Instruction-TLB|branch|branches|bpu|btb|bpc|node) 257 lc_op_result (load|loads|read|store|stores| 257 lc_op_result (load|loads|read|store|stores|write|prefetch|prefetches|speculative-read|speculative-load|refs|Reference|ops|access|misses|miss) 258 digit [0-9] 258 digit [0-9] 259 non_digit [^0-9] 259 non_digit [^0-9] 260 260 261 %% 261 %% 262 262 263 %{ 263 %{ 264 struct parse_events_state *_parse_stat 264 struct parse_events_state *_parse_state = parse_events_get_extra(yyscanner); 265 { 265 { 266 int start_token = _parse_state 266 int start_token = _parse_state->stoken; 267 267 268 if (start_token == PE_START_TE 268 if (start_token == PE_START_TERMS) 269 BEGIN(config); 269 BEGIN(config); 270 else if (start_token == PE_STA 270 else if (start_token == PE_START_EVENTS) 271 BEGIN(event); 271 BEGIN(event); 272 272 273 if (start_token) { 273 if (start_token) { 274 _parse_state->stoken = 274 _parse_state->stoken = 0; 275 /* 275 /* 276 * The flex parser doe 276 * The flex parser does not init locations variable 277 * via the scan_string 277 * via the scan_string interface, so we need do the 278 * init in here. 278 * init in here. 279 */ 279 */ 280 yycolumn = 0; 280 yycolumn = 0; 281 return start_token; 281 return start_token; 282 } 282 } 283 } 283 } 284 %} 284 %} 285 285 286 <event>{ 286 <event>{ 287 287 288 {group} { 288 {group} { 289 BEGIN(INITIAL); 289 BEGIN(INITIAL); 290 REWIND(0); 290 REWIND(0); 291 } 291 } 292 292 293 {event_pmu} | 293 {event_pmu} | 294 {event} { 294 {event} { 295 BEGIN(INITIAL); 295 BEGIN(INITIAL); 296 REWIND(1); 296 REWIND(1); 297 return PE_EVENT_NAME; 297 return PE_EVENT_NAME; 298 } 298 } 299 299 300 <<EOF>> { 300 <<EOF>> { 301 BEGIN(INITIAL); 301 BEGIN(INITIAL); 302 REWIND(0); 302 REWIND(0); 303 } 303 } 304 , { 304 , { 305 return ','; 305 return ','; 306 } 306 } 307 } 307 } 308 308 309 <config>{ 309 <config>{ 310 /* 310 /* 311 * Please update config_term_names whe 311 * Please update config_term_names when new static term is added. 312 */ 312 */ 313 config { return term(yyscanne 313 config { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG); } 314 config1 { return term(yyscanne 314 config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); } 315 config2 { return term(yyscanne 315 config2 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); } 316 config3 { return term(yyscanne 316 config3 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG3); } 317 name { return term(yyscanne 317 name { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); } 318 period { return term(yyscanne 318 period { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); } 319 freq { return term(yyscanne 319 freq { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ); } 320 branch_type { return term(yyscanne 320 branch_type { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); } 321 time { return term(yyscanne 321 time { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_TIME); } 322 call-graph { return term(yyscanne 322 call-graph { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CALLGRAPH); } 323 stack-size { return term(yyscanne 323 stack-size { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_STACKSIZE); } 324 max-stack { return term(yyscanne 324 max-stack { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_MAX_STACK); } 325 nr { return term(yyscanne 325 nr { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_MAX_EVENTS); } 326 inherit { return term(yyscanne 326 inherit { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_INHERIT); } 327 no-inherit { return term(yyscanne 327 no-inherit { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOINHERIT); } 328 overwrite { return term(yyscanne 328 overwrite { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_OVERWRITE); } 329 no-overwrite { return term(yyscanne 329 no-overwrite { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOOVERWRITE); } 330 percore { return term(yyscanne 330 percore { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_PERCORE); } 331 aux-output { return term(yyscanne 331 aux-output { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT); } 332 aux-sample-size { return term(yyscanne 332 aux-sample-size { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE); } 333 metric-id { return term(yyscanne 333 metric-id { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_METRIC_ID); } 334 cpu-cycles|cycles 334 cpu-cycles|cycles { return hw_term(yyscanner, PERF_COUNT_HW_CPU_CYCLES); } 335 stalled-cycles-frontend|idle-cycles-frontend 335 stalled-cycles-frontend|idle-cycles-frontend { return hw_term(yyscanner, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); } 336 stalled-cycles-backend|idle-cycles-backend 336 stalled-cycles-backend|idle-cycles-backend { return hw_term(yyscanner, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); } 337 instructions 337 instructions { return hw_term(yyscanner, PERF_COUNT_HW_INSTRUCTIONS); } 338 cache-references 338 cache-references { return hw_term(yyscanner, PERF_COUNT_HW_CACHE_REFERENCES); } 339 cache-misses 339 cache-misses { return hw_term(yyscanner, PERF_COUNT_HW_CACHE_MISSES); } 340 branch-instructions|branches 340 branch-instructions|branches { return hw_term(yyscanner, PERF_COUNT_HW_BRANCH_INSTRUCTIONS); } 341 branch-misses 341 branch-misses { return hw_term(yyscanner, PERF_COUNT_HW_BRANCH_MISSES); } 342 bus-cycles 342 bus-cycles { return hw_term(yyscanner, PERF_COUNT_HW_BUS_CYCLES); } 343 ref-cycles 343 ref-cycles { return hw_term(yyscanner, PERF_COUNT_HW_REF_CPU_CYCLES); } 344 r{num_raw_hex} { return str(yyscanner 344 r{num_raw_hex} { return str(yyscanner, PE_RAW); } 345 r0x{num_raw_hex} { return str(yyscanner 345 r0x{num_raw_hex} { return str(yyscanner, PE_RAW); } 346 , { return ','; } 346 , { return ','; } 347 "/" { BEGIN(INITIAL); retu 347 "/" { BEGIN(INITIAL); return '/'; } 348 {lc_type} { return lc_st 348 {lc_type} { return lc_str(yyscanner, _parse_state); } 349 {lc_type}-{lc_op_result} { return lc_st 349 {lc_type}-{lc_op_result} { return lc_str(yyscanner, _parse_state); } 350 {lc_type}-{lc_op_result}-{lc_op_result} { retu 350 {lc_type}-{lc_op_result}-{lc_op_result} { return lc_str(yyscanner, _parse_state); } 351 {name_minus} { return str(yyscanner 351 {name_minus} { return str(yyscanner, PE_NAME); } 352 @{drv_cfg_term} { return drv_str(yysca 352 @{drv_cfg_term} { return drv_str(yyscanner, PE_DRV_CFG_TERM); } 353 } 353 } 354 354 355 <mem>{ 355 <mem>{ 356 {modifier_bp} { return str(yyscanner 356 {modifier_bp} { return str(yyscanner, PE_MODIFIER_BP); } 357 /* 357 /* 358 * The colon before memory access modi 358 * The colon before memory access modifiers can get mixed up with the 359 * colon before event modifiers. Fortu 359 * colon before event modifiers. Fortunately none of the option letters 360 * are the same, so trailing context c 360 * are the same, so trailing context can be used disambiguate the two 361 * cases. 361 * cases. 362 */ 362 */ 363 ":"/{modifier_bp} { return PE_BP_COLON; 363 ":"/{modifier_bp} { return PE_BP_COLON; } 364 /* 364 /* 365 * The slash before memory length can 365 * The slash before memory length can get mixed up with the slash before 366 * config terms. Fortunately config te 366 * config terms. Fortunately config terms do not start with a numeric 367 * digit, so trailing context can be u 367 * digit, so trailing context can be used disambiguate the two cases. 368 */ 368 */ 369 "/"/{digit} { return PE_BP_SLASH; 369 "/"/{digit} { return PE_BP_SLASH; } 370 "/"/{non_digit} { BEGIN(config); retur 370 "/"/{non_digit} { BEGIN(config); return '/'; } 371 {num_dec} { return value(_parse_ 371 {num_dec} { return value(_parse_state, yyscanner, 10); } 372 {num_hex} { return value(_parse_ 372 {num_hex} { return value(_parse_state, yyscanner, 16); } 373 /* 373 /* 374 * We need to separate 'mem:' scanner 374 * We need to separate 'mem:' scanner part, in order to get specific 375 * modifier bits parsed out. Otherwise 375 * modifier bits parsed out. Otherwise we would need to handle PE_NAME 376 * and we'd need to parse it manually. 376 * and we'd need to parse it manually. During the escape from <mem> 377 * state we need to put the escaping c 377 * state we need to put the escaping char back, so we dont miss it. 378 */ 378 */ 379 . { unput(*yytext); BEGI 379 . { unput(*yytext); BEGIN(INITIAL); } 380 /* 380 /* 381 * We destroy the scanner after reachi 381 * We destroy the scanner after reaching EOF, 382 * but anyway just to be sure get back 382 * but anyway just to be sure get back to INIT state. 383 */ 383 */ 384 <<EOF>> { BEGIN(INITIAL); } 384 <<EOF>> { BEGIN(INITIAL); } 385 } 385 } 386 386 387 cpu-cycles|cycles 387 cpu-cycles|cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES); } 388 stalled-cycles-frontend|idle-cycles-frontend 388 stalled-cycles-frontend|idle-cycles-frontend { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); } 389 stalled-cycles-backend|idle-cycles-backend 389 stalled-cycles-backend|idle-cycles-backend { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); } 390 instructions 390 instructions { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS); } 391 cache-references 391 cache-references { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES); } 392 cache-misses 392 cache-misses { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES); } 393 branch-instructions|branches 393 branch-instructions|branches { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS); } 394 branch-misses 394 branch-misses { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES); } 395 bus-cycles 395 bus-cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES); } 396 ref-cycles 396 ref-cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES); } 397 cpu-clock 397 cpu-clock { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); } 398 task-clock 398 task-clock { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK); } 399 page-faults|faults 399 page-faults|faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS); } 400 minor-faults 400 minor-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN); } 401 major-faults 401 major-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ); } 402 context-switches|cs 402 context-switches|cs { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES); } 403 cpu-migrations|migrations 403 cpu-migrations|migrations { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS); } 404 alignment-faults 404 alignment-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_ALIGNMENT_FAULTS); } 405 emulation-faults 405 emulation-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EMULATION_FAULTS); } 406 dummy 406 dummy { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_DUMMY); } 407 duration_time 407 duration_time { return tool(yyscanner, PERF_TOOL_DURATION_TIME); } 408 user_time 408 user_time { return tool(yyscanner, PERF_TOOL_USER_TIME); } 409 system_time 409 system_time { return tool(yyscanner, PERF_TOOL_SYSTEM_TIME); } 410 bpf-output 410 bpf-output { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_BPF_OUTPUT); } 411 cgroup-switches 411 cgroup-switches { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CGROUP_SWITCHES); } 412 412 413 {lc_type} { return str(y 413 {lc_type} { return str(yyscanner, PE_LEGACY_CACHE); } 414 {lc_type}-{lc_op_result} { return str(y 414 {lc_type}-{lc_op_result} { return str(yyscanner, PE_LEGACY_CACHE); } 415 {lc_type}-{lc_op_result}-{lc_op_result} { retu 415 {lc_type}-{lc_op_result}-{lc_op_result} { return str(yyscanner, PE_LEGACY_CACHE); } 416 mem: { BEGIN(mem); return P 416 mem: { BEGIN(mem); return PE_PREFIX_MEM; } 417 r{num_raw_hex} { return str(yyscanner 417 r{num_raw_hex} { return str(yyscanner, PE_RAW); } 418 {num_dec} { return value(_parse_ 418 {num_dec} { return value(_parse_state, yyscanner, 10); } 419 {num_hex} { return value(_parse_ 419 {num_hex} { return value(_parse_state, yyscanner, 16); } 420 420 421 {modifier_event} { return modifiers(_pa 421 {modifier_event} { return modifiers(_parse_state, yyscanner); } 422 {name} { return str(yyscanner 422 {name} { return str(yyscanner, PE_NAME); } 423 {name_tag} { return str(yyscanner 423 {name_tag} { return str(yyscanner, PE_NAME); } 424 "/" { BEGIN(config); retur 424 "/" { BEGIN(config); return '/'; } 425 , { BEGIN(event); return 425 , { BEGIN(event); return ','; } 426 : { return ':'; } 426 : { return ':'; } 427 "{" { BEGIN(event); return 427 "{" { BEGIN(event); return '{'; } 428 "}" { return '}'; } 428 "}" { return '}'; } 429 = { return '='; } 429 = { return '='; } 430 \n { } 430 \n { } 431 . { } 431 . { } 432 432 433 %% 433 %% 434 434 435 int parse_events_wrap(void *scanner __maybe_un 435 int parse_events_wrap(void *scanner __maybe_unused) 436 { 436 { 437 return 1; 437 return 1; 438 } 438 }
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.