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