Jiri Olsa | fc8c0a9 | 2020-01-12 20:22:59 +0100 | [diff] [blame] | 1 | %define api.pure full |
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> |
Ian Rogers | f2a8ecd | 2019-10-30 15:34:44 -0700 | [diff] [blame] | 15 | #include <linux/zalloc.h> |
Andi Kleen | 231bb2a | 2017-01-27 18:03:39 -0800 | [diff] [blame] | 16 | #include "pmu.h" |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 17 | #include "evsel.h" |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 18 | #include "parse-events.h" |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 19 | #include "parse-events-bison.h" |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 20 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 21 | 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] | 22 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 23 | #define ABORT_ON(val) \ |
| 24 | do { \ |
| 25 | if (val) \ |
| 26 | YYABORT; \ |
| 27 | } while (0) |
| 28 | |
Ian Rogers | ffaecd7 | 2020-06-08 22:36:10 -0700 | [diff] [blame] | 29 | static struct list_head* alloc_list(void) |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 30 | { |
| 31 | struct list_head *list; |
| 32 | |
| 33 | list = malloc(sizeof(*list)); |
| 34 | if (!list) |
| 35 | return NULL; |
| 36 | |
| 37 | INIT_LIST_HEAD(list); |
| 38 | return list; |
| 39 | } |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 40 | |
Ian Rogers | f2a8ecd | 2019-10-30 15:34:44 -0700 | [diff] [blame] | 41 | static void free_list_evsel(struct list_head* list_evsel) |
| 42 | { |
| 43 | struct evsel *evsel, *tmp; |
| 44 | |
| 45 | list_for_each_entry_safe(evsel, tmp, list_evsel, core.node) { |
| 46 | list_del_init(&evsel->core.node); |
Ian Rogers | 672f707 | 2020-03-18 19:31:00 -0700 | [diff] [blame] | 47 | evsel__delete(evsel); |
Ian Rogers | f2a8ecd | 2019-10-30 15:34:44 -0700 | [diff] [blame] | 48 | } |
| 49 | free(list_evsel); |
| 50 | } |
| 51 | |
Colin Ian King | 07ef757 | 2016-03-07 16:44:37 -0300 | [diff] [blame] | 52 | static void inc_group_count(struct list_head *list, |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 53 | struct parse_events_state *parse_state) |
Namhyung Kim | 97f63e4 | 2013-01-22 18:09:29 +0900 | [diff] [blame] | 54 | { |
| 55 | /* Count groups only have more than 1 members */ |
| 56 | if (!list_is_last(list->next, list)) |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 57 | parse_state->nr_groups++; |
Namhyung Kim | 97f63e4 | 2013-01-22 18:09:29 +0900 | [diff] [blame] | 58 | } |
| 59 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 60 | %} |
| 61 | |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 62 | %token PE_START_EVENTS PE_START_TERMS |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 63 | %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] | 64 | %token PE_VALUE_SYM_TOOL |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 65 | %token PE_EVENT_NAME |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 66 | %token PE_NAME |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 67 | %token PE_BPF_OBJECT PE_BPF_SOURCE |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 68 | %token PE_MODIFIER_EVENT PE_MODIFIER_BP |
| 69 | %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 70 | %token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 71 | %token PE_ERROR |
Jiri Olsa | 387ad33 | 2020-06-02 23:47:29 +0200 | [diff] [blame] | 72 | %token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 73 | %token PE_ARRAY_ALL PE_ARRAY_RANGE |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 74 | %token PE_DRV_CFG_TERM |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 75 | %type <num> PE_VALUE |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 76 | %type <num> PE_VALUE_SYM_HW |
| 77 | %type <num> PE_VALUE_SYM_SW |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 78 | %type <num> PE_VALUE_SYM_TOOL |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 79 | %type <num> PE_RAW |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 80 | %type <num> PE_TERM |
Ian Rogers | f2a8ecd | 2019-10-30 15:34:44 -0700 | [diff] [blame] | 81 | %type <num> value_sym |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 82 | %type <str> PE_NAME |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 83 | %type <str> PE_BPF_OBJECT |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 84 | %type <str> PE_BPF_SOURCE |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 85 | %type <str> PE_NAME_CACHE_TYPE |
| 86 | %type <str> PE_NAME_CACHE_OP_RESULT |
| 87 | %type <str> PE_MODIFIER_EVENT |
| 88 | %type <str> PE_MODIFIER_BP |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 89 | %type <str> PE_EVENT_NAME |
Jiri Olsa | 387ad33 | 2020-06-02 23:47:29 +0200 | [diff] [blame] | 90 | %type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 91 | %type <str> PE_DRV_CFG_TERM |
Jiri Olsa | 84ea603 | 2021-03-01 13:23:15 +0100 | [diff] [blame] | 92 | %type <str> event_pmu_name |
Ian Rogers | f2a8ecd | 2019-10-30 15:34:44 -0700 | [diff] [blame] | 93 | %destructor { free ($$); } <str> |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 94 | %type <term> event_term |
Ian Rogers | 1dc9255 | 2019-10-30 15:34:47 -0700 | [diff] [blame] | 95 | %destructor { parse_events_term__delete ($$); } <term> |
Ian Rogers | f2a8ecd | 2019-10-30 15:34:44 -0700 | [diff] [blame] | 96 | %type <list_terms> event_config |
| 97 | %type <list_terms> opt_event_config |
| 98 | %type <list_terms> opt_pmu_config |
| 99 | %destructor { parse_events_terms__delete ($$); } <list_terms> |
| 100 | %type <list_evsel> event_pmu |
| 101 | %type <list_evsel> event_legacy_symbol |
| 102 | %type <list_evsel> event_legacy_cache |
| 103 | %type <list_evsel> event_legacy_mem |
| 104 | %type <list_evsel> event_legacy_tracepoint |
| 105 | %type <list_evsel> event_legacy_numeric |
| 106 | %type <list_evsel> event_legacy_raw |
| 107 | %type <list_evsel> event_bpf_file |
| 108 | %type <list_evsel> event_def |
| 109 | %type <list_evsel> event_mod |
| 110 | %type <list_evsel> event_name |
| 111 | %type <list_evsel> event |
| 112 | %type <list_evsel> events |
| 113 | %type <list_evsel> group_def |
| 114 | %type <list_evsel> group |
| 115 | %type <list_evsel> groups |
| 116 | %destructor { free_list_evsel ($$); } <list_evsel> |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 117 | %type <tracepoint_name> tracepoint_name |
Ian Rogers | f2a8ecd | 2019-10-30 15:34:44 -0700 | [diff] [blame] | 118 | %destructor { free ($$.sys); free ($$.event); } <tracepoint_name> |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 119 | %type <array> array |
| 120 | %type <array> array_term |
| 121 | %type <array> array_terms |
Ian Rogers | f2a8ecd | 2019-10-30 15:34:44 -0700 | [diff] [blame] | 122 | %destructor { free ($$.ranges); } <array> |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 123 | |
| 124 | %union |
| 125 | { |
| 126 | char *str; |
Robert Richter | b527bab | 2012-08-07 19:43:13 +0200 | [diff] [blame] | 127 | u64 num; |
Ian Rogers | f2a8ecd | 2019-10-30 15:34:44 -0700 | [diff] [blame] | 128 | struct list_head *list_evsel; |
| 129 | struct list_head *list_terms; |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 130 | struct parse_events_term *term; |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 131 | struct tracepoint_name { |
| 132 | char *sys; |
| 133 | char *event; |
| 134 | } tracepoint_name; |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 135 | struct parse_events_array array; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 136 | } |
| 137 | %% |
| 138 | |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 139 | start: |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 140 | PE_START_EVENTS start_events |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 141 | | |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 142 | PE_START_TERMS start_terms |
| 143 | |
| 144 | start_events: groups |
| 145 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 146 | struct parse_events_state *parse_state = _parse_state; |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 147 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 148 | /* frees $1 */ |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 149 | parse_events_update_lists($1, &parse_state->list); |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | groups: |
| 153 | groups ',' group |
| 154 | { |
| 155 | struct list_head *list = $1; |
| 156 | struct list_head *group = $3; |
| 157 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 158 | /* frees $3 */ |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 159 | parse_events_update_lists(group, list); |
| 160 | $$ = list; |
| 161 | } |
| 162 | | |
| 163 | groups ',' event |
| 164 | { |
| 165 | struct list_head *list = $1; |
| 166 | struct list_head *event = $3; |
| 167 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 168 | /* frees $3 */ |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 169 | parse_events_update_lists(event, list); |
| 170 | $$ = list; |
| 171 | } |
| 172 | | |
| 173 | group |
| 174 | | |
| 175 | event |
| 176 | |
| 177 | group: |
| 178 | group_def ':' PE_MODIFIER_EVENT |
| 179 | { |
| 180 | struct list_head *list = $1; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 181 | int err; |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 182 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 183 | err = parse_events__modifier_group(list, $3); |
| 184 | free($3); |
| 185 | if (err) { |
| 186 | free_list_evsel(list); |
| 187 | YYABORT; |
| 188 | } |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 189 | $$ = list; |
| 190 | } |
| 191 | | |
| 192 | group_def |
| 193 | |
| 194 | group_def: |
| 195 | PE_NAME '{' events '}' |
| 196 | { |
| 197 | struct list_head *list = $3; |
| 198 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 199 | inc_group_count(list, _parse_state); |
Kan Liang | 3cdc5c2 | 2018-05-07 14:13:43 -0700 | [diff] [blame] | 200 | parse_events__set_leader($1, list, _parse_state); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 201 | free($1); |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 202 | $$ = list; |
| 203 | } |
| 204 | | |
| 205 | '{' events '}' |
| 206 | { |
| 207 | struct list_head *list = $2; |
| 208 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 209 | inc_group_count(list, _parse_state); |
Kan Liang | 3cdc5c2 | 2018-05-07 14:13:43 -0700 | [diff] [blame] | 210 | parse_events__set_leader(NULL, list, _parse_state); |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 211 | $$ = list; |
| 212 | } |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 213 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 214 | events: |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 215 | events ',' event |
| 216 | { |
| 217 | struct list_head *event = $3; |
| 218 | struct list_head *list = $1; |
| 219 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 220 | /* frees $3 */ |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 221 | parse_events_update_lists(event, list); |
| 222 | $$ = list; |
| 223 | } |
| 224 | | |
| 225 | event |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 226 | |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 227 | event: event_mod |
| 228 | |
| 229 | event_mod: |
| 230 | event_name PE_MODIFIER_EVENT |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 231 | { |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 232 | struct list_head *list = $1; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 233 | int err; |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame] | 234 | |
Jiri Olsa | 5d7be90 | 2012-03-20 19:15:40 +0100 | [diff] [blame] | 235 | /* |
| 236 | * Apply modifier on all events added by single event definition |
| 237 | * (there could be more events added for multiple tracepoint |
| 238 | * definitions via '*?'. |
| 239 | */ |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 240 | err = parse_events__modifier_event(list, $2, false); |
| 241 | free($2); |
| 242 | if (err) { |
| 243 | free_list_evsel(list); |
| 244 | YYABORT; |
| 245 | } |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 246 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 247 | } |
| 248 | | |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 249 | event_name |
| 250 | |
| 251 | event_name: |
| 252 | PE_EVENT_NAME event_def |
| 253 | { |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 254 | int err; |
| 255 | |
| 256 | err = parse_events_name($2, $1); |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 257 | free($1); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 258 | if (err) { |
| 259 | free_list_evsel($2); |
| 260 | YYABORT; |
| 261 | } |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 262 | $$ = $2; |
| 263 | } |
| 264 | | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 265 | event_def |
| 266 | |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 267 | event_def: event_pmu | |
| 268 | event_legacy_symbol | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 269 | event_legacy_cache sep_dc | |
| 270 | event_legacy_mem | |
| 271 | event_legacy_tracepoint sep_dc | |
| 272 | event_legacy_numeric sep_dc | |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 273 | event_legacy_raw sep_dc | |
| 274 | event_bpf_file |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 275 | |
Jiri Olsa | 84ea603 | 2021-03-01 13:23:15 +0100 | [diff] [blame] | 276 | event_pmu_name: |
| 277 | PE_NAME | PE_PMU_EVENT_PRE |
| 278 | |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 279 | event_pmu: |
Jiri Olsa | 84ea603 | 2021-03-01 13:23:15 +0100 | [diff] [blame] | 280 | event_pmu_name opt_pmu_config |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 281 | { |
Jiri Olsa | f7fa827 | 2018-06-07 00:15:05 +0200 | [diff] [blame] | 282 | struct parse_events_state *parse_state = _parse_state; |
| 283 | struct parse_events_error *error = parse_state->error; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 284 | struct list_head *list = NULL, *orig_terms = NULL, *terms= NULL; |
| 285 | char *pattern = NULL; |
| 286 | |
| 287 | #define CLEANUP_YYABORT \ |
| 288 | do { \ |
| 289 | parse_events_terms__delete($2); \ |
| 290 | parse_events_terms__delete(orig_terms); \ |
Ian Rogers | e1e9b78 | 2019-11-08 23:58:40 -0800 | [diff] [blame] | 291 | free(list); \ |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 292 | free($1); \ |
| 293 | free(pattern); \ |
| 294 | YYABORT; \ |
| 295 | } while(0) |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 296 | |
Arnaldo Carvalho de Melo | 4a35a90 | 2018-05-07 15:27:01 -0300 | [diff] [blame] | 297 | if (parse_events_copy_term_list($2, &orig_terms)) |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 298 | CLEANUP_YYABORT; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 299 | |
Jiri Olsa | f7fa827 | 2018-06-07 00:15:05 +0200 | [diff] [blame] | 300 | if (error) |
| 301 | error->idx = @1.first_column; |
| 302 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 303 | list = alloc_list(); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 304 | if (!list) |
| 305 | CLEANUP_YYABORT; |
Kan Liang | 3cdc5c2 | 2018-05-07 14:13:43 -0700 | [diff] [blame] | 306 | if (parse_events_add_pmu(_parse_state, list, $1, $2, false, false)) { |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 307 | struct perf_pmu *pmu = NULL; |
| 308 | int ok = 0; |
Agustin Vega-Frias | b2b9d3a | 2018-03-06 09:04:42 -0500 | [diff] [blame] | 309 | |
| 310 | if (asprintf(&pattern, "%s*", $1) < 0) |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 311 | CLEANUP_YYABORT; |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 312 | |
| 313 | while ((pmu = perf_pmu__scan(pmu)) != NULL) { |
| 314 | char *name = pmu->name; |
| 315 | |
Andi Kleen | a820e33 | 2017-03-20 13:17:04 -0700 | [diff] [blame] | 316 | if (!strncmp(name, "uncore_", 7) && |
| 317 | strncmp($1, "uncore_", 7)) |
| 318 | name += 7; |
Kan Liang | 13d60ba | 2021-09-02 14:59:54 +0800 | [diff] [blame^] | 319 | if (!perf_pmu__match(pattern, name, $1) || |
| 320 | !perf_pmu__match(pattern, pmu->alias_name, $1)) { |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 321 | if (parse_events_copy_term_list(orig_terms, &terms)) |
| 322 | CLEANUP_YYABORT; |
Kan Liang | 3cdc5c2 | 2018-05-07 14:13:43 -0700 | [diff] [blame] | 323 | 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] | 324 | ok++; |
| 325 | parse_events_terms__delete(terms); |
| 326 | } |
| 327 | } |
Agustin Vega-Frias | b2b9d3a | 2018-03-06 09:04:42 -0500 | [diff] [blame] | 328 | |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 329 | if (!ok) |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 330 | CLEANUP_YYABORT; |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 331 | } |
Arnaldo Carvalho de Melo | 4a35a90 | 2018-05-07 15:27:01 -0300 | [diff] [blame] | 332 | parse_events_terms__delete($2); |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 333 | parse_events_terms__delete(orig_terms); |
Ian Rogers | ba08829 | 2020-03-18 19:31:00 -0700 | [diff] [blame] | 334 | free(pattern); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 335 | free($1); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 336 | $$ = list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 337 | #undef CLEANUP_YYABORT |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 338 | } |
Adrian Hunter | ad96227 | 2014-08-15 22:08:40 +0300 | [diff] [blame] | 339 | | |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 340 | PE_KERNEL_PMU_EVENT sep_dc |
| 341 | { |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 342 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 343 | int err; |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 344 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 345 | err = parse_events_multi_pmu_add(_parse_state, $1, &list); |
| 346 | free($1); |
| 347 | if (err < 0) |
Andi Kleen | 231bb2a | 2017-01-27 18:03:39 -0800 | [diff] [blame] | 348 | YYABORT; |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 349 | $$ = list; |
| 350 | } |
| 351 | | |
| 352 | PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc |
| 353 | { |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 354 | struct list_head *list; |
| 355 | char pmu_name[128]; |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 356 | |
Ian Rogers | c2412fa | 2020-06-08 22:36:09 -0700 | [diff] [blame] | 357 | snprintf(pmu_name, sizeof(pmu_name), "%s-%s", $1, $3); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 358 | free($1); |
| 359 | free($3); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 360 | if (parse_events_multi_pmu_add(_parse_state, pmu_name, &list) < 0) |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 361 | YYABORT; |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 362 | $$ = list; |
| 363 | } |
Jiri Olsa | 387ad33 | 2020-06-02 23:47:29 +0200 | [diff] [blame] | 364 | | |
| 365 | PE_PMU_EVENT_FAKE sep_dc |
| 366 | { |
| 367 | struct list_head *list; |
| 368 | int err; |
| 369 | |
| 370 | list = alloc_list(); |
| 371 | if (!list) |
| 372 | YYABORT; |
| 373 | |
| 374 | err = parse_events_add_pmu(_parse_state, list, $1, NULL, false, false); |
| 375 | free($1); |
| 376 | if (err < 0) { |
| 377 | free(list); |
| 378 | YYABORT; |
| 379 | } |
| 380 | $$ = list; |
| 381 | } |
| 382 | | |
| 383 | PE_PMU_EVENT_FAKE opt_pmu_config |
| 384 | { |
| 385 | struct list_head *list; |
| 386 | int err; |
| 387 | |
| 388 | list = alloc_list(); |
| 389 | if (!list) |
| 390 | YYABORT; |
| 391 | |
| 392 | err = parse_events_add_pmu(_parse_state, list, $1, $2, false, false); |
| 393 | free($1); |
| 394 | parse_events_terms__delete($2); |
| 395 | if (err < 0) { |
| 396 | free(list); |
| 397 | YYABORT; |
| 398 | } |
| 399 | $$ = list; |
| 400 | } |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 401 | |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 402 | value_sym: |
| 403 | PE_VALUE_SYM_HW |
| 404 | | |
| 405 | PE_VALUE_SYM_SW |
| 406 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 407 | event_legacy_symbol: |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 408 | value_sym '/' event_config '/' |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 409 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 410 | struct list_head *list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 411 | int type = $1 >> 16; |
| 412 | int config = $1 & 255; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 413 | int err; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 414 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 415 | list = alloc_list(); |
| 416 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 417 | err = parse_events_add_numeric(_parse_state, list, type, config, $3); |
Arnaldo Carvalho de Melo | 2146afc | 2016-02-12 17:09:17 -0300 | [diff] [blame] | 418 | parse_events_terms__delete($3); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 419 | if (err) { |
| 420 | free_list_evsel(list); |
| 421 | YYABORT; |
| 422 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 423 | $$ = list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 424 | } |
| 425 | | |
Jiri Olsa | 714a92d | 2019-02-13 13:32:40 +0100 | [diff] [blame] | 426 | value_sym sep_slash_slash_dc |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 427 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 428 | struct list_head *list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 429 | int type = $1 >> 16; |
| 430 | int config = $1 & 255; |
| 431 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 432 | list = alloc_list(); |
| 433 | ABORT_ON(!list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 434 | ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 435 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 436 | } |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 437 | | |
| 438 | PE_VALUE_SYM_TOOL sep_slash_slash_dc |
| 439 | { |
| 440 | struct list_head *list; |
| 441 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 442 | list = alloc_list(); |
| 443 | ABORT_ON(!list); |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 444 | ABORT_ON(parse_events_add_tool(_parse_state, list, $1)); |
| 445 | $$ = list; |
| 446 | } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 447 | |
| 448 | event_legacy_cache: |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 449 | 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] | 450 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 451 | struct parse_events_state *parse_state = _parse_state; |
| 452 | struct parse_events_error *error = parse_state->error; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 453 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 454 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 455 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 456 | list = alloc_list(); |
| 457 | ABORT_ON(!list); |
Jin Yao | c93afad | 2021-04-27 15:01:24 +0800 | [diff] [blame] | 458 | err = parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6, |
| 459 | parse_state); |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 460 | parse_events_terms__delete($6); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 461 | free($1); |
| 462 | free($3); |
| 463 | free($5); |
| 464 | if (err) { |
| 465 | free_list_evsel(list); |
| 466 | YYABORT; |
| 467 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 468 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 469 | } |
| 470 | | |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 471 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 472 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 473 | struct parse_events_state *parse_state = _parse_state; |
| 474 | struct parse_events_error *error = parse_state->error; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 475 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 476 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 477 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 478 | list = alloc_list(); |
| 479 | ABORT_ON(!list); |
Jin Yao | c93afad | 2021-04-27 15:01:24 +0800 | [diff] [blame] | 480 | err = parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4, |
| 481 | parse_state); |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 482 | parse_events_terms__delete($4); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 483 | free($1); |
| 484 | free($3); |
| 485 | if (err) { |
| 486 | free_list_evsel(list); |
| 487 | YYABORT; |
| 488 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 489 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 490 | } |
| 491 | | |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 492 | PE_NAME_CACHE_TYPE opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 493 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 494 | struct parse_events_state *parse_state = _parse_state; |
| 495 | struct parse_events_error *error = parse_state->error; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 496 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 497 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 498 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 499 | list = alloc_list(); |
| 500 | ABORT_ON(!list); |
Jin Yao | c93afad | 2021-04-27 15:01:24 +0800 | [diff] [blame] | 501 | err = parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2, |
| 502 | parse_state); |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 503 | parse_events_terms__delete($2); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 504 | free($1); |
| 505 | if (err) { |
| 506 | free_list_evsel(list); |
| 507 | YYABORT; |
| 508 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 509 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | event_legacy_mem: |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 513 | PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc |
| 514 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 515 | struct parse_events_state *parse_state = _parse_state; |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 516 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 517 | int err; |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 518 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 519 | list = alloc_list(); |
| 520 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 521 | err = parse_events_add_breakpoint(list, &parse_state->idx, |
Ian Rogers | aa98d84 | 2020-09-24 17:39:03 -0700 | [diff] [blame] | 522 | $2, $6, $4); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 523 | free($6); |
| 524 | if (err) { |
| 525 | free(list); |
| 526 | YYABORT; |
| 527 | } |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 528 | $$ = list; |
| 529 | } |
| 530 | | |
| 531 | PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc |
| 532 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 533 | struct parse_events_state *parse_state = _parse_state; |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 534 | struct list_head *list; |
| 535 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 536 | list = alloc_list(); |
| 537 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 538 | if (parse_events_add_breakpoint(list, &parse_state->idx, |
Ian Rogers | aa98d84 | 2020-09-24 17:39:03 -0700 | [diff] [blame] | 539 | $2, NULL, $4)) { |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 540 | free(list); |
| 541 | YYABORT; |
| 542 | } |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 543 | $$ = list; |
| 544 | } |
| 545 | | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 546 | PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc |
| 547 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 548 | struct parse_events_state *parse_state = _parse_state; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 549 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 550 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 551 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 552 | list = alloc_list(); |
| 553 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 554 | err = parse_events_add_breakpoint(list, &parse_state->idx, |
Ian Rogers | aa98d84 | 2020-09-24 17:39:03 -0700 | [diff] [blame] | 555 | $2, $4, 0); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 556 | free($4); |
| 557 | if (err) { |
| 558 | free(list); |
| 559 | YYABORT; |
| 560 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 561 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 562 | } |
| 563 | | |
| 564 | PE_PREFIX_MEM PE_VALUE sep_dc |
| 565 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 566 | struct parse_events_state *parse_state = _parse_state; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 567 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 568 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 569 | list = alloc_list(); |
| 570 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 571 | if (parse_events_add_breakpoint(list, &parse_state->idx, |
Ian Rogers | aa98d84 | 2020-09-24 17:39:03 -0700 | [diff] [blame] | 572 | $2, NULL, 0)) { |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 573 | free(list); |
| 574 | YYABORT; |
| 575 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 576 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | event_legacy_tracepoint: |
Arnaldo Carvalho de Melo | 1d55e8e | 2016-02-19 18:45:12 -0300 | [diff] [blame] | 580 | tracepoint_name opt_event_config |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 581 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 582 | struct parse_events_state *parse_state = _parse_state; |
| 583 | struct parse_events_error *error = parse_state->error; |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 584 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 585 | int err; |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 586 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 587 | list = alloc_list(); |
| 588 | ABORT_ON(!list); |
He Kuang | e637d17 | 2015-09-28 03:52:16 +0000 | [diff] [blame] | 589 | if (error) |
| 590 | error->idx = @1.first_column; |
| 591 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 592 | err = parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event, |
| 593 | error, $2); |
He Kuang | e637d17 | 2015-09-28 03:52:16 +0000 | [diff] [blame] | 594 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 595 | parse_events_terms__delete($2); |
| 596 | free($1.sys); |
| 597 | free($1.event); |
| 598 | if (err) { |
| 599 | free(list); |
Ian Rogers | e1e9b78 | 2019-11-08 23:58:40 -0800 | [diff] [blame] | 600 | YYABORT; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 601 | } |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 602 | $$ = list; |
| 603 | } |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 604 | |
| 605 | tracepoint_name: |
| 606 | PE_NAME '-' PE_NAME ':' PE_NAME |
| 607 | { |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 608 | struct tracepoint_name tracepoint; |
| 609 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 610 | ABORT_ON(asprintf(&tracepoint.sys, "%s-%s", $1, $3) < 0); |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 611 | tracepoint.event = $5; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 612 | free($1); |
| 613 | free($3); |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 614 | $$ = tracepoint; |
| 615 | } |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 616 | | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 617 | PE_NAME ':' PE_NAME |
| 618 | { |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 619 | struct tracepoint_name tracepoint = {$1, $3}; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 620 | |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 621 | $$ = tracepoint; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | event_legacy_numeric: |
Wang Nan | 10bf358 | 2016-02-19 11:44:00 +0000 | [diff] [blame] | 625 | PE_VALUE ':' PE_VALUE opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 626 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 627 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 628 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 629 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 630 | list = alloc_list(); |
| 631 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 632 | err = parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4); |
Wang Nan | 10bf358 | 2016-02-19 11:44:00 +0000 | [diff] [blame] | 633 | parse_events_terms__delete($4); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 634 | if (err) { |
| 635 | free(list); |
| 636 | YYABORT; |
| 637 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 638 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | event_legacy_raw: |
Wang Nan | 10bf358 | 2016-02-19 11:44:00 +0000 | [diff] [blame] | 642 | PE_RAW opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 643 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 644 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 645 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 646 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 647 | list = alloc_list(); |
| 648 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 649 | err = parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, $1, $2); |
Wang Nan | 10bf358 | 2016-02-19 11:44:00 +0000 | [diff] [blame] | 650 | parse_events_terms__delete($2); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 651 | if (err) { |
| 652 | free(list); |
| 653 | YYABORT; |
| 654 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 655 | $$ = list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 656 | } |
| 657 | |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 658 | event_bpf_file: |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 659 | PE_BPF_OBJECT opt_event_config |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 660 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 661 | struct parse_events_state *parse_state = _parse_state; |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 662 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 663 | int err; |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 664 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 665 | list = alloc_list(); |
| 666 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 667 | err = parse_events_load_bpf(parse_state, list, $1, false, $2); |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 668 | parse_events_terms__delete($2); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 669 | free($1); |
| 670 | if (err) { |
| 671 | free(list); |
| 672 | YYABORT; |
| 673 | } |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 674 | $$ = list; |
| 675 | } |
| 676 | | |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 677 | PE_BPF_SOURCE opt_event_config |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 678 | { |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 679 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 680 | int err; |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 681 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 682 | list = alloc_list(); |
| 683 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 684 | err = parse_events_load_bpf(_parse_state, list, $1, true, $2); |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 685 | parse_events_terms__delete($2); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 686 | if (err) { |
| 687 | free(list); |
| 688 | YYABORT; |
| 689 | } |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 690 | $$ = list; |
| 691 | } |
| 692 | |
Arnaldo Carvalho de Melo | 1d55e8e | 2016-02-19 18:45:12 -0300 | [diff] [blame] | 693 | opt_event_config: |
| 694 | '/' event_config '/' |
| 695 | { |
| 696 | $$ = $2; |
| 697 | } |
| 698 | | |
| 699 | '/' '/' |
| 700 | { |
| 701 | $$ = NULL; |
| 702 | } |
| 703 | | |
| 704 | { |
| 705 | $$ = NULL; |
| 706 | } |
| 707 | |
Jiri Olsa | ceac7b7 | 2018-06-05 14:14:16 +0200 | [diff] [blame] | 708 | opt_pmu_config: |
| 709 | '/' event_config '/' |
| 710 | { |
| 711 | $$ = $2; |
| 712 | } |
| 713 | | |
| 714 | '/' '/' |
| 715 | { |
| 716 | $$ = NULL; |
| 717 | } |
| 718 | |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 719 | start_terms: event_config |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 720 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 721 | struct parse_events_state *parse_state = _parse_state; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 722 | if (parse_state->terms) { |
| 723 | parse_events_terms__delete ($1); |
| 724 | YYABORT; |
| 725 | } |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 726 | parse_state->terms = $1; |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 727 | } |
| 728 | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 729 | event_config: |
| 730 | event_config ',' event_term |
| 731 | { |
| 732 | struct list_head *head = $1; |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 733 | struct parse_events_term *term = $3; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 734 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 735 | if (!head) { |
Ian Rogers | 1dc9255 | 2019-10-30 15:34:47 -0700 | [diff] [blame] | 736 | parse_events_term__delete(term); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 737 | YYABORT; |
| 738 | } |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 739 | list_add_tail(&term->list, head); |
| 740 | $$ = $1; |
| 741 | } |
| 742 | | |
| 743 | event_term |
| 744 | { |
| 745 | struct list_head *head = malloc(sizeof(*head)); |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 746 | struct parse_events_term *term = $1; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 747 | |
| 748 | ABORT_ON(!head); |
| 749 | INIT_LIST_HEAD(head); |
| 750 | list_add_tail(&term->list, head); |
| 751 | $$ = head; |
| 752 | } |
| 753 | |
| 754 | event_term: |
Jiri Olsa | 3a6c51e | 2020-04-17 00:14:05 +0200 | [diff] [blame] | 755 | PE_RAW |
| 756 | { |
| 757 | struct parse_events_term *term; |
| 758 | |
| 759 | ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_CONFIG, |
| 760 | NULL, $1, false, &@1, NULL)); |
| 761 | $$ = term; |
| 762 | } |
| 763 | | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 764 | PE_NAME '=' PE_NAME |
| 765 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 766 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 767 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 768 | if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 769 | $1, $3, &@1, &@3)) { |
| 770 | free($1); |
| 771 | free($3); |
| 772 | YYABORT; |
| 773 | } |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 774 | $$ = term; |
| 775 | } |
| 776 | | |
| 777 | PE_NAME '=' PE_VALUE |
| 778 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 779 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 780 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 781 | if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 782 | $1, $3, false, &@1, &@3)) { |
| 783 | free($1); |
| 784 | YYABORT; |
| 785 | } |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 786 | $$ = term; |
| 787 | } |
| 788 | | |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 789 | PE_NAME '=' PE_VALUE_SYM_HW |
| 790 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 791 | struct parse_events_term *term; |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 792 | int config = $3 & 255; |
| 793 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 794 | if (parse_events_term__sym_hw(&term, $1, config)) { |
| 795 | free($1); |
| 796 | YYABORT; |
| 797 | } |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 798 | $$ = term; |
| 799 | } |
| 800 | | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 801 | PE_NAME |
| 802 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 803 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 804 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 805 | if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 806 | $1, 1, true, &@1, NULL)) { |
| 807 | free($1); |
| 808 | YYABORT; |
| 809 | } |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 810 | $$ = term; |
| 811 | } |
| 812 | | |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 813 | PE_VALUE_SYM_HW |
| 814 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 815 | struct parse_events_term *term; |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 816 | int config = $1 & 255; |
| 817 | |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 818 | ABORT_ON(parse_events_term__sym_hw(&term, NULL, config)); |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 819 | $$ = term; |
| 820 | } |
| 821 | | |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 822 | PE_TERM '=' PE_NAME |
| 823 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 824 | struct parse_events_term *term; |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 825 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 826 | if (parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3)) { |
| 827 | free($3); |
| 828 | YYABORT; |
| 829 | } |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 830 | $$ = term; |
| 831 | } |
| 832 | | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 833 | PE_TERM '=' PE_VALUE |
| 834 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 835 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 836 | |
Jiri Olsa | 99e7138 | 2017-02-17 15:00:56 +0100 | [diff] [blame] | 837 | 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] | 838 | $$ = term; |
| 839 | } |
| 840 | | |
| 841 | PE_TERM |
| 842 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 843 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 844 | |
Jiri Olsa | 99e7138 | 2017-02-17 15:00:56 +0100 | [diff] [blame] | 845 | 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] | 846 | $$ = term; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 847 | } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 848 | | |
| 849 | PE_NAME array '=' PE_NAME |
| 850 | { |
| 851 | struct parse_events_term *term; |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 852 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 853 | if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 854 | $1, $4, &@1, &@4)) { |
| 855 | free($1); |
| 856 | free($4); |
| 857 | free($2.ranges); |
| 858 | YYABORT; |
| 859 | } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 860 | term->array = $2; |
| 861 | $$ = term; |
| 862 | } |
| 863 | | |
| 864 | PE_NAME array '=' PE_VALUE |
| 865 | { |
| 866 | struct parse_events_term *term; |
| 867 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 868 | if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 869 | $1, $4, false, &@1, &@4)) { |
| 870 | free($1); |
| 871 | free($2.ranges); |
| 872 | YYABORT; |
| 873 | } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 874 | term->array = $2; |
| 875 | $$ = term; |
| 876 | } |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 877 | | |
| 878 | PE_DRV_CFG_TERM |
| 879 | { |
| 880 | struct parse_events_term *term; |
Ian Rogers | b6645a7 | 2019-10-30 15:34:43 -0700 | [diff] [blame] | 881 | char *config = strdup($1); |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 882 | |
Ian Rogers | b6645a7 | 2019-10-30 15:34:43 -0700 | [diff] [blame] | 883 | ABORT_ON(!config); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 884 | if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG, |
| 885 | config, $1, &@1, NULL)) { |
| 886 | free($1); |
| 887 | free(config); |
| 888 | YYABORT; |
| 889 | } |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 890 | $$ = term; |
| 891 | } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 892 | |
| 893 | array: |
| 894 | '[' array_terms ']' |
| 895 | { |
| 896 | $$ = $2; |
| 897 | } |
| 898 | | |
| 899 | PE_ARRAY_ALL |
| 900 | { |
| 901 | $$.nr_ranges = 0; |
| 902 | $$.ranges = NULL; |
| 903 | } |
| 904 | |
| 905 | array_terms: |
| 906 | array_terms ',' array_term |
| 907 | { |
| 908 | struct parse_events_array new_array; |
| 909 | |
| 910 | new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges; |
Ian Rogers | 826100a | 2019-10-22 17:53:33 -0700 | [diff] [blame] | 911 | new_array.ranges = realloc($1.ranges, |
| 912 | sizeof(new_array.ranges[0]) * |
| 913 | new_array.nr_ranges); |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 914 | ABORT_ON(!new_array.ranges); |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 915 | memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges, |
| 916 | $3.nr_ranges * sizeof(new_array.ranges[0])); |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 917 | free($3.ranges); |
| 918 | $$ = new_array; |
| 919 | } |
| 920 | | |
| 921 | array_term |
| 922 | |
| 923 | array_term: |
| 924 | PE_VALUE |
| 925 | { |
| 926 | struct parse_events_array array; |
| 927 | |
| 928 | array.nr_ranges = 1; |
| 929 | array.ranges = malloc(sizeof(array.ranges[0])); |
| 930 | ABORT_ON(!array.ranges); |
| 931 | array.ranges[0].start = $1; |
| 932 | array.ranges[0].length = 1; |
| 933 | $$ = array; |
| 934 | } |
| 935 | | |
| 936 | PE_VALUE PE_ARRAY_RANGE PE_VALUE |
| 937 | { |
| 938 | struct parse_events_array array; |
| 939 | |
| 940 | ABORT_ON($3 < $1); |
| 941 | array.nr_ranges = 1; |
| 942 | array.ranges = malloc(sizeof(array.ranges[0])); |
| 943 | ABORT_ON(!array.ranges); |
| 944 | array.ranges[0].start = $1; |
| 945 | array.ranges[0].length = $3 - $1 + 1; |
| 946 | $$ = array; |
| 947 | } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 948 | |
| 949 | sep_dc: ':' | |
| 950 | |
Jiri Olsa | 714a92d | 2019-02-13 13:32:40 +0100 | [diff] [blame] | 951 | sep_slash_slash_dc: '/' '/' | ':' | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 952 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 953 | %% |
| 954 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 955 | void parse_events_error(YYLTYPE *loc, void *parse_state, |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 956 | void *scanner __maybe_unused, |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 957 | char const *msg __maybe_unused) |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 958 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 959 | parse_events_evlist_error(parse_state, loc->last_column, "parser error"); |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 960 | } |