Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 1 | |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 2 | %option reentrant |
| 3 | %option bison-bridge |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 4 | %option prefix="parse_events_" |
Jiri Olsa | 08d2f76 | 2012-05-21 09:12:52 +0200 | [diff] [blame] | 5 | %option stack |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 6 | %option bison-locations |
| 7 | %option yylineno |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 8 | |
| 9 | %{ |
| 10 | #include <errno.h> |
| 11 | #include "../perf.h" |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 12 | #include "parse-events.h" |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 13 | #include "parse-events-bison.h" |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 14 | |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 15 | char *parse_events_get_text(yyscan_t yyscanner); |
| 16 | YYSTYPE *parse_events_get_lval(yyscan_t yyscanner); |
| 17 | |
| 18 | static int __value(YYSTYPE *yylval, char *str, int base, int token) |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 19 | { |
Robert Richter | b527bab | 2012-08-07 19:43:13 +0200 | [diff] [blame] | 20 | u64 num; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 21 | |
| 22 | errno = 0; |
Robert Richter | b527bab | 2012-08-07 19:43:13 +0200 | [diff] [blame] | 23 | num = strtoull(str, NULL, base); |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 24 | if (errno) |
| 25 | return PE_ERROR; |
| 26 | |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 27 | yylval->num = num; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 28 | return token; |
| 29 | } |
| 30 | |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 31 | static int value(yyscan_t scanner, int base) |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 32 | { |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 33 | YYSTYPE *yylval = parse_events_get_lval(scanner); |
| 34 | char *text = parse_events_get_text(scanner); |
| 35 | |
| 36 | return __value(yylval, text, base, PE_VALUE); |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 37 | } |
| 38 | |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 39 | static int raw(yyscan_t scanner) |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 40 | { |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 41 | YYSTYPE *yylval = parse_events_get_lval(scanner); |
| 42 | char *text = parse_events_get_text(scanner); |
| 43 | |
| 44 | return __value(yylval, text + 1, 16, PE_RAW); |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 45 | } |
| 46 | |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 47 | static int str(yyscan_t scanner, int token) |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 48 | { |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 49 | YYSTYPE *yylval = parse_events_get_lval(scanner); |
| 50 | char *text = parse_events_get_text(scanner); |
| 51 | |
| 52 | yylval->str = strdup(text); |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 53 | return token; |
| 54 | } |
| 55 | |
Andi Kleen | 77d0871 | 2017-08-11 16:26:19 -0700 | [diff] [blame] | 56 | static bool isbpf(yyscan_t scanner) |
| 57 | { |
| 58 | char *text = parse_events_get_text(scanner); |
| 59 | int len = strlen(text); |
| 60 | |
| 61 | if (len < 2) |
| 62 | return false; |
| 63 | if ((text[len - 1] == 'c' || text[len - 1] == 'o') && |
| 64 | text[len - 2] == '.') |
| 65 | return true; |
| 66 | if (len > 4 && !strcmp(text + len - 4, ".obj")) |
| 67 | return true; |
| 68 | return false; |
| 69 | } |
| 70 | |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 71 | /* |
| 72 | * This function is called when the parser gets two kind of input: |
| 73 | * |
| 74 | * @cfg1 or @cfg2=config |
| 75 | * |
| 76 | * The leading '@' is stripped off before 'cfg1' and 'cfg2=config' are given to |
| 77 | * bison. In the latter case it is necessary to keep the string intact so that |
| 78 | * the PMU kernel driver can determine what configurable is associated to |
| 79 | * 'config'. |
| 80 | */ |
| 81 | static int drv_str(yyscan_t scanner, int token) |
| 82 | { |
| 83 | YYSTYPE *yylval = parse_events_get_lval(scanner); |
| 84 | char *text = parse_events_get_text(scanner); |
| 85 | |
| 86 | /* Strip off the '@' */ |
| 87 | yylval->str = strdup(text + 1); |
| 88 | return token; |
| 89 | } |
| 90 | |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 91 | #define REWIND(__alloc) \ |
| 92 | do { \ |
| 93 | YYSTYPE *__yylval = parse_events_get_lval(yyscanner); \ |
| 94 | char *text = parse_events_get_text(yyscanner); \ |
| 95 | \ |
| 96 | if (__alloc) \ |
| 97 | __yylval->str = strdup(text); \ |
| 98 | \ |
| 99 | yycolumn -= strlen(text); \ |
| 100 | yyless(0); \ |
| 101 | } while (0) |
| 102 | |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 103 | static int pmu_str_check(yyscan_t scanner) |
| 104 | { |
| 105 | YYSTYPE *yylval = parse_events_get_lval(scanner); |
| 106 | char *text = parse_events_get_text(scanner); |
| 107 | |
| 108 | yylval->str = strdup(text); |
| 109 | switch (perf_pmu__parse_check(text)) { |
| 110 | case PMU_EVENT_SYMBOL_PREFIX: |
| 111 | return PE_PMU_EVENT_PRE; |
| 112 | case PMU_EVENT_SYMBOL_SUFFIX: |
| 113 | return PE_PMU_EVENT_SUF; |
| 114 | case PMU_EVENT_SYMBOL: |
| 115 | return PE_KERNEL_PMU_EVENT; |
| 116 | default: |
| 117 | return PE_NAME; |
| 118 | } |
| 119 | } |
| 120 | |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 121 | static int sym(yyscan_t scanner, int type, int config) |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 122 | { |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 123 | YYSTYPE *yylval = parse_events_get_lval(scanner); |
| 124 | |
| 125 | yylval->num = (type << 16) + config; |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 126 | return type == PERF_TYPE_HARDWARE ? PE_VALUE_SYM_HW : PE_VALUE_SYM_SW; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 127 | } |
| 128 | |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 129 | static int term(yyscan_t scanner, int type) |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 130 | { |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 131 | YYSTYPE *yylval = parse_events_get_lval(scanner); |
| 132 | |
| 133 | yylval->num = type; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 134 | return PE_TERM; |
| 135 | } |
| 136 | |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 137 | #define YY_USER_ACTION \ |
| 138 | do { \ |
| 139 | yylloc->last_column = yylloc->first_column; \ |
| 140 | yylloc->first_column = yycolumn; \ |
| 141 | yycolumn += yyleng; \ |
| 142 | } while (0); |
| 143 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 144 | %} |
| 145 | |
Jiri Olsa | 08d2f76 | 2012-05-21 09:12:52 +0200 | [diff] [blame] | 146 | %x mem |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 147 | %s config |
| 148 | %x event |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 149 | %x array |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 150 | |
| 151 | group [^,{}/]*[{][^}]*[}][^,{}/]* |
| 152 | event_pmu [^,{}/]+[/][^/]*[/][^,{}/]* |
| 153 | event [^,{}/]+ |
Andi Kleen | 77d0871 | 2017-08-11 16:26:19 -0700 | [diff] [blame] | 154 | bpf_object [^,{}]+\.(o|bpf)[a-zA-Z0-9._]* |
| 155 | bpf_source [^,{}]+\.c[a-zA-Z0-9._]* |
Jiri Olsa | 08d2f76 | 2012-05-21 09:12:52 +0200 | [diff] [blame] | 156 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 157 | num_dec [0-9]+ |
| 158 | num_hex 0x[a-fA-F0-9]+ |
| 159 | num_raw_hex [a-fA-F0-9]+ |
Andi Kleen | 5b021dd | 2015-06-10 00:25:11 -0700 | [diff] [blame] | 160 | name [a-zA-Z_*?][a-zA-Z0-9_*?.]* |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 161 | name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.:]* |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 162 | drv_cfg_term [a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)? |
Michael Ellerman | e9a7c41 | 2013-08-06 23:28:05 +1000 | [diff] [blame] | 163 | /* If you add a modifier you need to update check_modifier() */ |
Andi Kleen | 5a5dfe4 | 2017-08-31 12:40:26 -0700 | [diff] [blame^] | 164 | modifier_event [ukhpPGHSDIW]+ |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 165 | modifier_bp [rwx]{1,3} |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 166 | |
| 167 | %% |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 168 | |
| 169 | %{ |
| 170 | { |
| 171 | int start_token; |
| 172 | |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 173 | start_token = parse_events_get_extra(yyscanner); |
| 174 | |
| 175 | if (start_token == PE_START_TERMS) |
| 176 | BEGIN(config); |
| 177 | else if (start_token == PE_START_EVENTS) |
| 178 | BEGIN(event); |
| 179 | |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 180 | if (start_token) { |
| 181 | parse_events_set_extra(NULL, yyscanner); |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 182 | /* |
| 183 | * The flex parser does not init locations variable |
| 184 | * via the scan_string interface, so we need do the |
| 185 | * init in here. |
| 186 | */ |
| 187 | yycolumn = 0; |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 188 | return start_token; |
| 189 | } |
| 190 | } |
| 191 | %} |
| 192 | |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 193 | <event>{ |
| 194 | |
| 195 | {group} { |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 196 | BEGIN(INITIAL); |
| 197 | REWIND(0); |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | {event_pmu} | |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 201 | {bpf_object} | |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 202 | {bpf_source} | |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 203 | {event} { |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 204 | BEGIN(INITIAL); |
| 205 | REWIND(1); |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 206 | return PE_EVENT_NAME; |
| 207 | } |
| 208 | |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 209 | <<EOF>> { |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 210 | BEGIN(INITIAL); |
| 211 | REWIND(0); |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | } |
| 215 | |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 216 | <array>{ |
| 217 | "]" { BEGIN(config); return ']'; } |
| 218 | {num_dec} { return value(yyscanner, 10); } |
| 219 | {num_hex} { return value(yyscanner, 16); } |
| 220 | , { return ','; } |
| 221 | "\.\.\." { return PE_ARRAY_RANGE; } |
| 222 | } |
| 223 | |
Jiri Olsa | 8200422 | 2013-09-27 18:29:58 +0200 | [diff] [blame] | 224 | <config>{ |
Jiri Olsa | e64b020 | 2015-04-22 21:10:21 +0200 | [diff] [blame] | 225 | /* |
Wang Nan | 17cb5f8 | 2016-02-19 11:43:57 +0000 | [diff] [blame] | 226 | * Please update config_term_names when new static term is added. |
Jiri Olsa | e64b020 | 2015-04-22 21:10:21 +0200 | [diff] [blame] | 227 | */ |
Jiri Olsa | 8200422 | 2013-09-27 18:29:58 +0200 | [diff] [blame] | 228 | config { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG); } |
| 229 | config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); } |
| 230 | config2 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); } |
| 231 | name { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); } |
| 232 | period { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); } |
Namhyung Kim | 09af2a5 | 2015-08-09 15:45:23 +0900 | [diff] [blame] | 233 | freq { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ); } |
Jiri Olsa | 8200422 | 2013-09-27 18:29:58 +0200 | [diff] [blame] | 234 | branch_type { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); } |
Kan Liang | 3206771 | 2015-08-04 04:30:19 -0400 | [diff] [blame] | 235 | time { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_TIME); } |
Kan Liang | d457c96 | 2015-08-11 06:30:47 -0400 | [diff] [blame] | 236 | call-graph { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CALLGRAPH); } |
| 237 | stack-size { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_STACKSIZE); } |
Arnaldo Carvalho de Melo | 792d48b | 2016-04-28 19:03:42 -0300 | [diff] [blame] | 238 | max-stack { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_MAX_STACK); } |
Wang Nan | 374ce93 | 2015-10-28 10:55:02 +0000 | [diff] [blame] | 239 | inherit { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_INHERIT); } |
| 240 | no-inherit { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOINHERIT); } |
Wang Nan | 626a6b7 | 2016-07-14 08:34:45 +0000 | [diff] [blame] | 241 | overwrite { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_OVERWRITE); } |
| 242 | no-overwrite { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOOVERWRITE); } |
Jiri Olsa | 8200422 | 2013-09-27 18:29:58 +0200 | [diff] [blame] | 243 | , { return ','; } |
| 244 | "/" { BEGIN(INITIAL); return '/'; } |
| 245 | {name_minus} { return str(yyscanner, PE_NAME); } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 246 | \[all\] { return PE_ARRAY_ALL; } |
| 247 | "[" { BEGIN(array); return '['; } |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 248 | @{drv_cfg_term} { return drv_str(yyscanner, PE_DRV_CFG_TERM); } |
Jiri Olsa | 8200422 | 2013-09-27 18:29:58 +0200 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | <mem>{ |
| 252 | {modifier_bp} { return str(yyscanner, PE_MODIFIER_BP); } |
| 253 | : { return ':'; } |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 254 | "/" { return '/'; } |
Jiri Olsa | 8200422 | 2013-09-27 18:29:58 +0200 | [diff] [blame] | 255 | {num_dec} { return value(yyscanner, 10); } |
| 256 | {num_hex} { return value(yyscanner, 16); } |
| 257 | /* |
| 258 | * We need to separate 'mem:' scanner part, in order to get specific |
| 259 | * modifier bits parsed out. Otherwise we would need to handle PE_NAME |
| 260 | * and we'd need to parse it manually. During the escape from <mem> |
| 261 | * state we need to put the escaping char back, so we dont miss it. |
| 262 | */ |
| 263 | . { unput(*yytext); BEGIN(INITIAL); } |
| 264 | /* |
| 265 | * We destroy the scanner after reaching EOF, |
| 266 | * but anyway just to be sure get back to INIT state. |
| 267 | */ |
| 268 | <<EOF>> { BEGIN(INITIAL); } |
| 269 | } |
| 270 | |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 271 | cpu-cycles|cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES); } |
| 272 | stalled-cycles-frontend|idle-cycles-frontend { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); } |
| 273 | stalled-cycles-backend|idle-cycles-backend { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); } |
| 274 | instructions { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS); } |
| 275 | cache-references { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES); } |
| 276 | cache-misses { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES); } |
| 277 | branch-instructions|branches { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS); } |
| 278 | branch-misses { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES); } |
| 279 | bus-cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES); } |
| 280 | ref-cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES); } |
| 281 | cpu-clock { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); } |
| 282 | task-clock { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK); } |
| 283 | page-faults|faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS); } |
| 284 | minor-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN); } |
| 285 | major-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ); } |
| 286 | context-switches|cs { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES); } |
| 287 | cpu-migrations|migrations { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS); } |
| 288 | alignment-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_ALIGNMENT_FAULTS); } |
| 289 | emulation-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EMULATION_FAULTS); } |
Adrian Hunter | d22d1a2 | 2013-08-31 21:50:52 +0300 | [diff] [blame] | 290 | dummy { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_DUMMY); } |
Wang Nan | 03e0a7d | 2016-02-22 09:10:37 +0000 | [diff] [blame] | 291 | bpf-output { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_BPF_OUTPUT); } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 292 | |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 293 | /* |
| 294 | * We have to handle the kernel PMU event cycles-ct/cycles-t/mem-loads/mem-stores separately. |
| 295 | * Because the prefix cycles is mixed up with cpu-cycles. |
| 296 | * loads and stores are mixed up with cache event |
| 297 | */ |
| 298 | cycles-ct { return str(yyscanner, PE_KERNEL_PMU_EVENT); } |
| 299 | cycles-t { return str(yyscanner, PE_KERNEL_PMU_EVENT); } |
| 300 | mem-loads { return str(yyscanner, PE_KERNEL_PMU_EVENT); } |
| 301 | mem-stores { return str(yyscanner, PE_KERNEL_PMU_EVENT); } |
Andi Kleen | 44b1e60 | 2016-05-30 12:49:42 -0300 | [diff] [blame] | 302 | topdown-[a-z-]+ { return str(yyscanner, PE_KERNEL_PMU_EVENT); } |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 303 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 304 | L1-dcache|l1-d|l1d|L1-data | |
| 305 | L1-icache|l1-i|l1i|L1-instruction | |
| 306 | LLC|L2 | |
| 307 | dTLB|d-tlb|Data-TLB | |
| 308 | iTLB|i-tlb|Instruction-TLB | |
| 309 | branch|branches|bpu|btb|bpc | |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 310 | node { return str(yyscanner, PE_NAME_CACHE_TYPE); } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 311 | |
| 312 | load|loads|read | |
| 313 | store|stores|write | |
| 314 | prefetch|prefetches | |
| 315 | speculative-read|speculative-load | |
| 316 | refs|Reference|ops|access | |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 317 | misses|miss { return str(yyscanner, PE_NAME_CACHE_OP_RESULT); } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 318 | |
Jiri Olsa | 08d2f76 | 2012-05-21 09:12:52 +0200 | [diff] [blame] | 319 | mem: { BEGIN(mem); return PE_PREFIX_MEM; } |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 320 | r{num_raw_hex} { return raw(yyscanner); } |
| 321 | {num_dec} { return value(yyscanner, 10); } |
| 322 | {num_hex} { return value(yyscanner, 16); } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 323 | |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 324 | {modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); } |
Andi Kleen | 77d0871 | 2017-08-11 16:26:19 -0700 | [diff] [blame] | 325 | {bpf_object} { if (!isbpf(yyscanner)) REJECT; return str(yyscanner, PE_BPF_OBJECT); } |
| 326 | {bpf_source} { if (!isbpf(yyscanner)) REJECT; return str(yyscanner, PE_BPF_SOURCE); } |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 327 | {name} { return pmu_str_check(yyscanner); } |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 328 | "/" { BEGIN(config); return '/'; } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 329 | - { return '-'; } |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 330 | , { BEGIN(event); return ','; } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 331 | : { return ':'; } |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 332 | "{" { BEGIN(event); return '{'; } |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 333 | "}" { return '}'; } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 334 | = { return '='; } |
Jiri Olsa | 8c5f0a8 | 2012-07-04 00:00:39 +0200 | [diff] [blame] | 335 | \n { } |
Jiri Olsa | 8200422 | 2013-09-27 18:29:58 +0200 | [diff] [blame] | 336 | . { } |
Jiri Olsa | 08d2f76 | 2012-05-21 09:12:52 +0200 | [diff] [blame] | 337 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 338 | %% |
| 339 | |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 340 | int parse_events_wrap(void *scanner __maybe_unused) |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 341 | { |
| 342 | return 1; |
| 343 | } |