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