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