Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 1 | %pure-parser |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 2 | %parse-param {void *_parse_state} |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 3 | %parse-param {void *scanner} |
| 4 | %lex-param {void* scanner} |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 5 | %locations |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 6 | |
| 7 | %{ |
| 8 | |
| 9 | #define YYDEBUG 1 |
| 10 | |
Agustin Vega-Frias | b2b9d3a | 2018-03-06 09:04:42 -0500 | [diff] [blame] | 11 | #include <fnmatch.h> |
Arnaldo Carvalho de Melo | bd70462 | 2019-09-24 15:45:21 -0300 | [diff] [blame] | 12 | #include <stdio.h> |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 13 | #include <linux/compiler.h> |
Borislav Petkov | d944c4e | 2014-04-25 21:31:02 +0200 | [diff] [blame] | 14 | #include <linux/types.h> |
Andi Kleen | 231bb2a | 2017-01-27 18:03:39 -0800 | [diff] [blame] | 15 | #include "pmu.h" |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 16 | #include "evsel.h" |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 17 | #include "parse-events.h" |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 18 | #include "parse-events-bison.h" |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 19 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 20 | void parse_events_error(YYLTYPE *loc, void *parse_state, void *scanner, char const *msg); |
Arnaldo Carvalho de Melo | 34a0548 | 2017-02-15 10:09:11 -0300 | [diff] [blame] | 21 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 22 | #define ABORT_ON(val) \ |
| 23 | do { \ |
| 24 | if (val) \ |
| 25 | YYABORT; \ |
| 26 | } while (0) |
| 27 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 28 | #define ALLOC_LIST(list) \ |
| 29 | do { \ |
| 30 | list = malloc(sizeof(*list)); \ |
| 31 | ABORT_ON(!list); \ |
| 32 | INIT_LIST_HEAD(list); \ |
| 33 | } while (0) |
| 34 | |
Colin Ian King | 07ef757 | 2016-03-07 16:44:37 -0300 | [diff] [blame] | 35 | static void inc_group_count(struct list_head *list, |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 36 | struct parse_events_state *parse_state) |
Namhyung Kim | 97f63e4 | 2013-01-22 18:09:29 +0900 | [diff] [blame] | 37 | { |
| 38 | /* Count groups only have more than 1 members */ |
| 39 | if (!list_is_last(list->next, list)) |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 40 | parse_state->nr_groups++; |
Namhyung Kim | 97f63e4 | 2013-01-22 18:09:29 +0900 | [diff] [blame] | 41 | } |
| 42 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 43 | %} |
| 44 | |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 45 | %token PE_START_EVENTS PE_START_TERMS |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 46 | %token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 47 | %token PE_VALUE_SYM_TOOL |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 48 | %token PE_EVENT_NAME |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 49 | %token PE_NAME |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 50 | %token PE_BPF_OBJECT PE_BPF_SOURCE |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 51 | %token PE_MODIFIER_EVENT PE_MODIFIER_BP |
| 52 | %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 53 | %token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 54 | %token PE_ERROR |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 55 | %token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 56 | %token PE_ARRAY_ALL PE_ARRAY_RANGE |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 57 | %token PE_DRV_CFG_TERM |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 58 | %type <num> PE_VALUE |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 59 | %type <num> PE_VALUE_SYM_HW |
| 60 | %type <num> PE_VALUE_SYM_SW |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 61 | %type <num> PE_VALUE_SYM_TOOL |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 62 | %type <num> PE_RAW |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 63 | %type <num> PE_TERM |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 64 | %type <str> PE_NAME |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 65 | %type <str> PE_BPF_OBJECT |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 66 | %type <str> PE_BPF_SOURCE |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 67 | %type <str> PE_NAME_CACHE_TYPE |
| 68 | %type <str> PE_NAME_CACHE_OP_RESULT |
| 69 | %type <str> PE_MODIFIER_EVENT |
| 70 | %type <str> PE_MODIFIER_BP |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 71 | %type <str> PE_EVENT_NAME |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 72 | %type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 73 | %type <str> PE_DRV_CFG_TERM |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 74 | %type <num> value_sym |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 75 | %type <head> event_config |
Arnaldo Carvalho de Melo | 1d55e8e | 2016-02-19 18:45:12 -0300 | [diff] [blame] | 76 | %type <head> opt_event_config |
Jiri Olsa | ceac7b7 | 2018-06-05 14:14:16 +0200 | [diff] [blame] | 77 | %type <head> opt_pmu_config |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 78 | %type <term> event_term |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 79 | %type <head> event_pmu |
| 80 | %type <head> event_legacy_symbol |
| 81 | %type <head> event_legacy_cache |
| 82 | %type <head> event_legacy_mem |
| 83 | %type <head> event_legacy_tracepoint |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 84 | %type <tracepoint_name> tracepoint_name |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 85 | %type <head> event_legacy_numeric |
| 86 | %type <head> event_legacy_raw |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 87 | %type <head> event_bpf_file |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 88 | %type <head> event_def |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 89 | %type <head> event_mod |
| 90 | %type <head> event_name |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 91 | %type <head> event |
| 92 | %type <head> events |
| 93 | %type <head> group_def |
| 94 | %type <head> group |
| 95 | %type <head> groups |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 96 | %type <array> array |
| 97 | %type <array> array_term |
| 98 | %type <array> array_terms |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 99 | |
| 100 | %union |
| 101 | { |
| 102 | char *str; |
Robert Richter | b527bab | 2012-08-07 19:43:13 +0200 | [diff] [blame] | 103 | u64 num; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 104 | struct list_head *head; |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 105 | struct parse_events_term *term; |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 106 | struct tracepoint_name { |
| 107 | char *sys; |
| 108 | char *event; |
| 109 | } tracepoint_name; |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 110 | struct parse_events_array array; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 111 | } |
| 112 | %% |
| 113 | |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 114 | start: |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 115 | PE_START_EVENTS start_events |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 116 | | |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 117 | PE_START_TERMS start_terms |
| 118 | |
| 119 | start_events: groups |
| 120 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 121 | struct parse_events_state *parse_state = _parse_state; |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 122 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 123 | parse_events_update_lists($1, &parse_state->list); |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | groups: |
| 127 | groups ',' group |
| 128 | { |
| 129 | struct list_head *list = $1; |
| 130 | struct list_head *group = $3; |
| 131 | |
| 132 | parse_events_update_lists(group, list); |
| 133 | $$ = list; |
| 134 | } |
| 135 | | |
| 136 | groups ',' event |
| 137 | { |
| 138 | struct list_head *list = $1; |
| 139 | struct list_head *event = $3; |
| 140 | |
| 141 | parse_events_update_lists(event, list); |
| 142 | $$ = list; |
| 143 | } |
| 144 | | |
| 145 | group |
| 146 | | |
| 147 | event |
| 148 | |
| 149 | group: |
| 150 | group_def ':' PE_MODIFIER_EVENT |
| 151 | { |
| 152 | struct list_head *list = $1; |
| 153 | |
| 154 | ABORT_ON(parse_events__modifier_group(list, $3)); |
| 155 | $$ = list; |
| 156 | } |
| 157 | | |
| 158 | group_def |
| 159 | |
| 160 | group_def: |
| 161 | PE_NAME '{' events '}' |
| 162 | { |
| 163 | struct list_head *list = $3; |
| 164 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 165 | inc_group_count(list, _parse_state); |
Kan Liang | 3cdc5c2 | 2018-05-07 14:13:43 -0700 | [diff] [blame] | 166 | parse_events__set_leader($1, list, _parse_state); |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 167 | $$ = list; |
| 168 | } |
| 169 | | |
| 170 | '{' events '}' |
| 171 | { |
| 172 | struct list_head *list = $2; |
| 173 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 174 | inc_group_count(list, _parse_state); |
Kan Liang | 3cdc5c2 | 2018-05-07 14:13:43 -0700 | [diff] [blame] | 175 | parse_events__set_leader(NULL, list, _parse_state); |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 176 | $$ = list; |
| 177 | } |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 178 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 179 | events: |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 180 | events ',' event |
| 181 | { |
| 182 | struct list_head *event = $3; |
| 183 | struct list_head *list = $1; |
| 184 | |
| 185 | parse_events_update_lists(event, list); |
| 186 | $$ = list; |
| 187 | } |
| 188 | | |
| 189 | event |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 190 | |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 191 | event: event_mod |
| 192 | |
| 193 | event_mod: |
| 194 | event_name PE_MODIFIER_EVENT |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 195 | { |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 196 | struct list_head *list = $1; |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame] | 197 | |
Jiri Olsa | 5d7be90 | 2012-03-20 19:15:40 +0100 | [diff] [blame] | 198 | /* |
| 199 | * Apply modifier on all events added by single event definition |
| 200 | * (there could be more events added for multiple tracepoint |
| 201 | * definitions via '*?'. |
| 202 | */ |
Jiri Olsa | f5b1135 | 2012-08-08 12:21:54 +0200 | [diff] [blame] | 203 | ABORT_ON(parse_events__modifier_event(list, $2, false)); |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 204 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 205 | } |
| 206 | | |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 207 | event_name |
| 208 | |
| 209 | event_name: |
| 210 | PE_EVENT_NAME event_def |
| 211 | { |
| 212 | ABORT_ON(parse_events_name($2, $1)); |
| 213 | free($1); |
| 214 | $$ = $2; |
| 215 | } |
| 216 | | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 217 | event_def |
| 218 | |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 219 | event_def: event_pmu | |
| 220 | event_legacy_symbol | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 221 | event_legacy_cache sep_dc | |
| 222 | event_legacy_mem | |
| 223 | event_legacy_tracepoint sep_dc | |
| 224 | event_legacy_numeric sep_dc | |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 225 | event_legacy_raw sep_dc | |
| 226 | event_bpf_file |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 227 | |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 228 | event_pmu: |
Jiri Olsa | ceac7b7 | 2018-06-05 14:14:16 +0200 | [diff] [blame] | 229 | PE_NAME opt_pmu_config |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 230 | { |
Jiri Olsa | f7fa827 | 2018-06-07 00:15:05 +0200 | [diff] [blame] | 231 | struct parse_events_state *parse_state = _parse_state; |
| 232 | struct parse_events_error *error = parse_state->error; |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 233 | struct list_head *list, *orig_terms, *terms; |
| 234 | |
Arnaldo Carvalho de Melo | 4a35a90 | 2018-05-07 15:27:01 -0300 | [diff] [blame] | 235 | if (parse_events_copy_term_list($2, &orig_terms)) |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 236 | YYABORT; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 237 | |
Jiri Olsa | f7fa827 | 2018-06-07 00:15:05 +0200 | [diff] [blame] | 238 | if (error) |
| 239 | error->idx = @1.first_column; |
| 240 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 241 | ALLOC_LIST(list); |
Kan Liang | 3cdc5c2 | 2018-05-07 14:13:43 -0700 | [diff] [blame] | 242 | if (parse_events_add_pmu(_parse_state, list, $1, $2, false, false)) { |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 243 | struct perf_pmu *pmu = NULL; |
| 244 | int ok = 0; |
Agustin Vega-Frias | b2b9d3a | 2018-03-06 09:04:42 -0500 | [diff] [blame] | 245 | char *pattern; |
| 246 | |
| 247 | if (asprintf(&pattern, "%s*", $1) < 0) |
| 248 | YYABORT; |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 249 | |
| 250 | while ((pmu = perf_pmu__scan(pmu)) != NULL) { |
| 251 | char *name = pmu->name; |
| 252 | |
Andi Kleen | a820e33 | 2017-03-20 13:17:04 -0700 | [diff] [blame] | 253 | if (!strncmp(name, "uncore_", 7) && |
| 254 | strncmp($1, "uncore_", 7)) |
| 255 | name += 7; |
Agustin Vega-Frias | b2b9d3a | 2018-03-06 09:04:42 -0500 | [diff] [blame] | 256 | if (!fnmatch(pattern, name, 0)) { |
| 257 | if (parse_events_copy_term_list(orig_terms, &terms)) { |
| 258 | free(pattern); |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 259 | YYABORT; |
Agustin Vega-Frias | b2b9d3a | 2018-03-06 09:04:42 -0500 | [diff] [blame] | 260 | } |
Kan Liang | 3cdc5c2 | 2018-05-07 14:13:43 -0700 | [diff] [blame] | 261 | if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, true, false)) |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 262 | ok++; |
| 263 | parse_events_terms__delete(terms); |
| 264 | } |
| 265 | } |
Agustin Vega-Frias | b2b9d3a | 2018-03-06 09:04:42 -0500 | [diff] [blame] | 266 | |
| 267 | free(pattern); |
| 268 | |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 269 | if (!ok) |
| 270 | YYABORT; |
| 271 | } |
Arnaldo Carvalho de Melo | 4a35a90 | 2018-05-07 15:27:01 -0300 | [diff] [blame] | 272 | parse_events_terms__delete($2); |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 273 | parse_events_terms__delete(orig_terms); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 274 | $$ = list; |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 275 | } |
Adrian Hunter | ad96227 | 2014-08-15 22:08:40 +0300 | [diff] [blame] | 276 | | |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 277 | PE_KERNEL_PMU_EVENT sep_dc |
| 278 | { |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 279 | struct list_head *list; |
| 280 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 281 | if (parse_events_multi_pmu_add(_parse_state, $1, &list) < 0) |
Andi Kleen | 231bb2a | 2017-01-27 18:03:39 -0800 | [diff] [blame] | 282 | YYABORT; |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 283 | $$ = list; |
| 284 | } |
| 285 | | |
| 286 | PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc |
| 287 | { |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 288 | struct list_head *list; |
| 289 | char pmu_name[128]; |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 290 | |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 291 | snprintf(&pmu_name, 128, "%s-%s", $1, $3); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 292 | if (parse_events_multi_pmu_add(_parse_state, pmu_name, &list) < 0) |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 293 | YYABORT; |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 294 | $$ = list; |
| 295 | } |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 296 | |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 297 | value_sym: |
| 298 | PE_VALUE_SYM_HW |
| 299 | | |
| 300 | PE_VALUE_SYM_SW |
| 301 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 302 | event_legacy_symbol: |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 303 | value_sym '/' event_config '/' |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 304 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 305 | struct list_head *list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 306 | int type = $1 >> 16; |
| 307 | int config = $1 & 255; |
| 308 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 309 | ALLOC_LIST(list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 310 | ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, $3)); |
Arnaldo Carvalho de Melo | 2146afc | 2016-02-12 17:09:17 -0300 | [diff] [blame] | 311 | parse_events_terms__delete($3); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 312 | $$ = list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 313 | } |
| 314 | | |
Jiri Olsa | 714a92d | 2019-02-13 13:32:40 +0100 | [diff] [blame] | 315 | value_sym sep_slash_slash_dc |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 316 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 317 | struct list_head *list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 318 | int type = $1 >> 16; |
| 319 | int config = $1 & 255; |
| 320 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 321 | ALLOC_LIST(list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 322 | ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 323 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 324 | } |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 325 | | |
| 326 | PE_VALUE_SYM_TOOL sep_slash_slash_dc |
| 327 | { |
| 328 | struct list_head *list; |
| 329 | |
| 330 | ALLOC_LIST(list); |
| 331 | ABORT_ON(parse_events_add_tool(_parse_state, list, $1)); |
| 332 | $$ = list; |
| 333 | } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 334 | |
| 335 | event_legacy_cache: |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 336 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 337 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 338 | struct parse_events_state *parse_state = _parse_state; |
| 339 | struct parse_events_error *error = parse_state->error; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 340 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 341 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 342 | ALLOC_LIST(list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 343 | ABORT_ON(parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6)); |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 344 | parse_events_terms__delete($6); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 345 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 346 | } |
| 347 | | |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 348 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 349 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 350 | struct parse_events_state *parse_state = _parse_state; |
| 351 | struct parse_events_error *error = parse_state->error; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 352 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 353 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 354 | ALLOC_LIST(list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 355 | ABORT_ON(parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4)); |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 356 | parse_events_terms__delete($4); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 357 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 358 | } |
| 359 | | |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 360 | PE_NAME_CACHE_TYPE opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 361 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 362 | struct parse_events_state *parse_state = _parse_state; |
| 363 | struct parse_events_error *error = parse_state->error; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 364 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 365 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 366 | ALLOC_LIST(list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 367 | ABORT_ON(parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2)); |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 368 | parse_events_terms__delete($2); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 369 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | event_legacy_mem: |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 373 | PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc |
| 374 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 375 | struct parse_events_state *parse_state = _parse_state; |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 376 | struct list_head *list; |
| 377 | |
| 378 | ALLOC_LIST(list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 379 | ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx, |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 380 | (void *) $2, $6, $4)); |
| 381 | $$ = list; |
| 382 | } |
| 383 | | |
| 384 | PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc |
| 385 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 386 | struct parse_events_state *parse_state = _parse_state; |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 387 | struct list_head *list; |
| 388 | |
| 389 | ALLOC_LIST(list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 390 | ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx, |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 391 | (void *) $2, NULL, $4)); |
| 392 | $$ = list; |
| 393 | } |
| 394 | | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 395 | PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc |
| 396 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 397 | struct parse_events_state *parse_state = _parse_state; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 398 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 399 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 400 | ALLOC_LIST(list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 401 | ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx, |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 402 | (void *) $2, $4, 0)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 403 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 404 | } |
| 405 | | |
| 406 | PE_PREFIX_MEM PE_VALUE sep_dc |
| 407 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 408 | struct parse_events_state *parse_state = _parse_state; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 409 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 410 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 411 | ALLOC_LIST(list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 412 | ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx, |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 413 | (void *) $2, NULL, 0)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 414 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | event_legacy_tracepoint: |
Arnaldo Carvalho de Melo | 1d55e8e | 2016-02-19 18:45:12 -0300 | [diff] [blame] | 418 | tracepoint_name opt_event_config |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 419 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 420 | struct parse_events_state *parse_state = _parse_state; |
| 421 | struct parse_events_error *error = parse_state->error; |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 422 | struct list_head *list; |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 423 | |
| 424 | ALLOC_LIST(list); |
He Kuang | e637d17 | 2015-09-28 03:52:16 +0000 | [diff] [blame] | 425 | if (error) |
| 426 | error->idx = @1.first_column; |
| 427 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 428 | if (parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event, |
Arnaldo Carvalho de Melo | 1d55e8e | 2016-02-19 18:45:12 -0300 | [diff] [blame] | 429 | error, $2)) |
He Kuang | e637d17 | 2015-09-28 03:52:16 +0000 | [diff] [blame] | 430 | return -1; |
| 431 | |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 432 | $$ = list; |
| 433 | } |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 434 | |
| 435 | tracepoint_name: |
| 436 | PE_NAME '-' PE_NAME ':' PE_NAME |
| 437 | { |
| 438 | char sys_name[128]; |
| 439 | struct tracepoint_name tracepoint; |
| 440 | |
| 441 | snprintf(&sys_name, 128, "%s-%s", $1, $3); |
| 442 | tracepoint.sys = &sys_name; |
| 443 | tracepoint.event = $5; |
| 444 | |
| 445 | $$ = tracepoint; |
| 446 | } |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 447 | | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 448 | PE_NAME ':' PE_NAME |
| 449 | { |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 450 | struct tracepoint_name tracepoint = {$1, $3}; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 451 | |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 452 | $$ = tracepoint; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | event_legacy_numeric: |
Wang Nan | 10bf358 | 2016-02-19 11:44:00 +0000 | [diff] [blame] | 456 | PE_VALUE ':' PE_VALUE opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 457 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 458 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 459 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 460 | ALLOC_LIST(list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 461 | ABORT_ON(parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4)); |
Wang Nan | 10bf358 | 2016-02-19 11:44:00 +0000 | [diff] [blame] | 462 | parse_events_terms__delete($4); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 463 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | event_legacy_raw: |
Wang Nan | 10bf358 | 2016-02-19 11:44:00 +0000 | [diff] [blame] | 467 | PE_RAW opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 468 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 469 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 470 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 471 | ALLOC_LIST(list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 472 | ABORT_ON(parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, $1, $2)); |
Wang Nan | 10bf358 | 2016-02-19 11:44:00 +0000 | [diff] [blame] | 473 | parse_events_terms__delete($2); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 474 | $$ = list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 475 | } |
| 476 | |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 477 | event_bpf_file: |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 478 | PE_BPF_OBJECT opt_event_config |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 479 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 480 | struct parse_events_state *parse_state = _parse_state; |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 481 | struct list_head *list; |
| 482 | |
| 483 | ALLOC_LIST(list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 484 | ABORT_ON(parse_events_load_bpf(parse_state, list, $1, false, $2)); |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 485 | parse_events_terms__delete($2); |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 486 | $$ = list; |
| 487 | } |
| 488 | | |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 489 | PE_BPF_SOURCE opt_event_config |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 490 | { |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 491 | struct list_head *list; |
| 492 | |
| 493 | ALLOC_LIST(list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 494 | ABORT_ON(parse_events_load_bpf(_parse_state, list, $1, true, $2)); |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 495 | parse_events_terms__delete($2); |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 496 | $$ = list; |
| 497 | } |
| 498 | |
Arnaldo Carvalho de Melo | 1d55e8e | 2016-02-19 18:45:12 -0300 | [diff] [blame] | 499 | opt_event_config: |
| 500 | '/' event_config '/' |
| 501 | { |
| 502 | $$ = $2; |
| 503 | } |
| 504 | | |
| 505 | '/' '/' |
| 506 | { |
| 507 | $$ = NULL; |
| 508 | } |
| 509 | | |
| 510 | { |
| 511 | $$ = NULL; |
| 512 | } |
| 513 | |
Jiri Olsa | ceac7b7 | 2018-06-05 14:14:16 +0200 | [diff] [blame] | 514 | opt_pmu_config: |
| 515 | '/' event_config '/' |
| 516 | { |
| 517 | $$ = $2; |
| 518 | } |
| 519 | | |
| 520 | '/' '/' |
| 521 | { |
| 522 | $$ = NULL; |
| 523 | } |
| 524 | |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 525 | start_terms: event_config |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 526 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 527 | struct parse_events_state *parse_state = _parse_state; |
| 528 | parse_state->terms = $1; |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 529 | } |
| 530 | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 531 | event_config: |
| 532 | event_config ',' event_term |
| 533 | { |
| 534 | struct list_head *head = $1; |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 535 | struct parse_events_term *term = $3; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 536 | |
| 537 | ABORT_ON(!head); |
| 538 | list_add_tail(&term->list, head); |
| 539 | $$ = $1; |
| 540 | } |
| 541 | | |
| 542 | event_term |
| 543 | { |
| 544 | struct list_head *head = malloc(sizeof(*head)); |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 545 | struct parse_events_term *term = $1; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 546 | |
| 547 | ABORT_ON(!head); |
| 548 | INIT_LIST_HEAD(head); |
| 549 | list_add_tail(&term->list, head); |
| 550 | $$ = head; |
| 551 | } |
| 552 | |
| 553 | event_term: |
| 554 | PE_NAME '=' PE_NAME |
| 555 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 556 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 557 | |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 558 | ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, |
Jiri Olsa | cecf3a2e | 2015-04-22 21:10:20 +0200 | [diff] [blame] | 559 | $1, $3, &@1, &@3)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 560 | $$ = term; |
| 561 | } |
| 562 | | |
| 563 | PE_NAME '=' PE_VALUE |
| 564 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 565 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 566 | |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 567 | ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
Jiri Olsa | 99e7138 | 2017-02-17 15:00:56 +0100 | [diff] [blame] | 568 | $1, $3, false, &@1, &@3)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 569 | $$ = term; |
| 570 | } |
| 571 | | |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 572 | PE_NAME '=' PE_VALUE_SYM_HW |
| 573 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 574 | struct parse_events_term *term; |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 575 | int config = $3 & 255; |
| 576 | |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 577 | ABORT_ON(parse_events_term__sym_hw(&term, $1, config)); |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 578 | $$ = term; |
| 579 | } |
| 580 | | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 581 | PE_NAME |
| 582 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 583 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 584 | |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 585 | ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
Jiri Olsa | 99e7138 | 2017-02-17 15:00:56 +0100 | [diff] [blame] | 586 | $1, 1, true, &@1, NULL)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 587 | $$ = term; |
| 588 | } |
| 589 | | |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 590 | PE_VALUE_SYM_HW |
| 591 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 592 | struct parse_events_term *term; |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 593 | int config = $1 & 255; |
| 594 | |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 595 | ABORT_ON(parse_events_term__sym_hw(&term, NULL, config)); |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 596 | $$ = term; |
| 597 | } |
| 598 | | |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 599 | PE_TERM '=' PE_NAME |
| 600 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 601 | struct parse_events_term *term; |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 602 | |
Jiri Olsa | cecf3a2e | 2015-04-22 21:10:20 +0200 | [diff] [blame] | 603 | ABORT_ON(parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3)); |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 604 | $$ = term; |
| 605 | } |
| 606 | | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 607 | PE_TERM '=' PE_VALUE |
| 608 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 609 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 610 | |
Jiri Olsa | 99e7138 | 2017-02-17 15:00:56 +0100 | [diff] [blame] | 611 | ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, false, &@1, &@3)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 612 | $$ = term; |
| 613 | } |
| 614 | | |
| 615 | PE_TERM |
| 616 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 617 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 618 | |
Jiri Olsa | 99e7138 | 2017-02-17 15:00:56 +0100 | [diff] [blame] | 619 | ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, true, &@1, NULL)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 620 | $$ = term; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 621 | } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 622 | | |
| 623 | PE_NAME array '=' PE_NAME |
| 624 | { |
| 625 | struct parse_events_term *term; |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 626 | |
| 627 | ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 628 | $1, $4, &@1, &@4)); |
| 629 | |
| 630 | term->array = $2; |
| 631 | $$ = term; |
| 632 | } |
| 633 | | |
| 634 | PE_NAME array '=' PE_VALUE |
| 635 | { |
| 636 | struct parse_events_term *term; |
| 637 | |
| 638 | ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
Jiri Olsa | 99e7138 | 2017-02-17 15:00:56 +0100 | [diff] [blame] | 639 | $1, $4, false, &@1, &@4)); |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 640 | term->array = $2; |
| 641 | $$ = term; |
| 642 | } |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 643 | | |
| 644 | PE_DRV_CFG_TERM |
| 645 | { |
| 646 | struct parse_events_term *term; |
| 647 | |
| 648 | ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG, |
| 649 | $1, $1, &@1, NULL)); |
| 650 | $$ = term; |
| 651 | } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 652 | |
| 653 | array: |
| 654 | '[' array_terms ']' |
| 655 | { |
| 656 | $$ = $2; |
| 657 | } |
| 658 | | |
| 659 | PE_ARRAY_ALL |
| 660 | { |
| 661 | $$.nr_ranges = 0; |
| 662 | $$.ranges = NULL; |
| 663 | } |
| 664 | |
| 665 | array_terms: |
| 666 | array_terms ',' array_term |
| 667 | { |
| 668 | struct parse_events_array new_array; |
| 669 | |
| 670 | new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges; |
| 671 | new_array.ranges = malloc(sizeof(new_array.ranges[0]) * |
| 672 | new_array.nr_ranges); |
| 673 | ABORT_ON(!new_array.ranges); |
| 674 | memcpy(&new_array.ranges[0], $1.ranges, |
| 675 | $1.nr_ranges * sizeof(new_array.ranges[0])); |
| 676 | memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges, |
| 677 | $3.nr_ranges * sizeof(new_array.ranges[0])); |
| 678 | free($1.ranges); |
| 679 | free($3.ranges); |
| 680 | $$ = new_array; |
| 681 | } |
| 682 | | |
| 683 | array_term |
| 684 | |
| 685 | array_term: |
| 686 | PE_VALUE |
| 687 | { |
| 688 | struct parse_events_array array; |
| 689 | |
| 690 | array.nr_ranges = 1; |
| 691 | array.ranges = malloc(sizeof(array.ranges[0])); |
| 692 | ABORT_ON(!array.ranges); |
| 693 | array.ranges[0].start = $1; |
| 694 | array.ranges[0].length = 1; |
| 695 | $$ = array; |
| 696 | } |
| 697 | | |
| 698 | PE_VALUE PE_ARRAY_RANGE PE_VALUE |
| 699 | { |
| 700 | struct parse_events_array array; |
| 701 | |
| 702 | ABORT_ON($3 < $1); |
| 703 | array.nr_ranges = 1; |
| 704 | array.ranges = malloc(sizeof(array.ranges[0])); |
| 705 | ABORT_ON(!array.ranges); |
| 706 | array.ranges[0].start = $1; |
| 707 | array.ranges[0].length = $3 - $1 + 1; |
| 708 | $$ = array; |
| 709 | } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 710 | |
| 711 | sep_dc: ':' | |
| 712 | |
Jiri Olsa | 714a92d | 2019-02-13 13:32:40 +0100 | [diff] [blame] | 713 | sep_slash_slash_dc: '/' '/' | ':' | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 714 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 715 | %% |
| 716 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 717 | void parse_events_error(YYLTYPE *loc, void *parse_state, |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 718 | void *scanner __maybe_unused, |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 719 | char const *msg __maybe_unused) |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 720 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 721 | parse_events_evlist_error(parse_state, loc->last_column, "parser error"); |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 722 | } |