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