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 | ba08829 | 2020-03-18 19:31:00 -0700 | [diff] [blame^] | 329 | free(pattern); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 330 | free($1); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 331 | $$ = list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 332 | #undef CLEANUP_YYABORT |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 333 | } |
Adrian Hunter | ad96227 | 2014-08-15 22:08:40 +0300 | [diff] [blame] | 334 | | |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 335 | PE_KERNEL_PMU_EVENT sep_dc |
| 336 | { |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 337 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 338 | int err; |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 339 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 340 | err = parse_events_multi_pmu_add(_parse_state, $1, &list); |
| 341 | free($1); |
| 342 | if (err < 0) |
Andi Kleen | 231bb2a | 2017-01-27 18:03:39 -0800 | [diff] [blame] | 343 | YYABORT; |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 344 | $$ = list; |
| 345 | } |
| 346 | | |
| 347 | PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc |
| 348 | { |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 349 | struct list_head *list; |
| 350 | char pmu_name[128]; |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 351 | |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 352 | snprintf(&pmu_name, 128, "%s-%s", $1, $3); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 353 | free($1); |
| 354 | free($3); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 355 | if (parse_events_multi_pmu_add(_parse_state, pmu_name, &list) < 0) |
Andi Kleen | 8255718 | 2017-03-20 13:17:03 -0700 | [diff] [blame] | 356 | YYABORT; |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 357 | $$ = list; |
| 358 | } |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 359 | |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 360 | value_sym: |
| 361 | PE_VALUE_SYM_HW |
| 362 | | |
| 363 | PE_VALUE_SYM_SW |
| 364 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 365 | event_legacy_symbol: |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 366 | value_sym '/' event_config '/' |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 367 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 368 | struct list_head *list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 369 | int type = $1 >> 16; |
| 370 | int config = $1 & 255; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 371 | int err; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 372 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 373 | list = alloc_list(); |
| 374 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 375 | 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] | 376 | parse_events_terms__delete($3); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 377 | if (err) { |
| 378 | free_list_evsel(list); |
| 379 | YYABORT; |
| 380 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 381 | $$ = list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 382 | } |
| 383 | | |
Jiri Olsa | 714a92d | 2019-02-13 13:32:40 +0100 | [diff] [blame] | 384 | value_sym sep_slash_slash_dc |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 385 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 386 | struct list_head *list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 387 | int type = $1 >> 16; |
| 388 | int config = $1 & 255; |
| 389 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 390 | list = alloc_list(); |
| 391 | ABORT_ON(!list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 392 | ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 393 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 394 | } |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 395 | | |
| 396 | PE_VALUE_SYM_TOOL sep_slash_slash_dc |
| 397 | { |
| 398 | struct list_head *list; |
| 399 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 400 | list = alloc_list(); |
| 401 | ABORT_ON(!list); |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 402 | ABORT_ON(parse_events_add_tool(_parse_state, list, $1)); |
| 403 | $$ = list; |
| 404 | } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 405 | |
| 406 | event_legacy_cache: |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 407 | 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] | 408 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 409 | struct parse_events_state *parse_state = _parse_state; |
| 410 | struct parse_events_error *error = parse_state->error; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 411 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 412 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 413 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 414 | list = alloc_list(); |
| 415 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 416 | 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] | 417 | parse_events_terms__delete($6); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 418 | free($1); |
| 419 | free($3); |
| 420 | free($5); |
| 421 | if (err) { |
| 422 | free_list_evsel(list); |
| 423 | YYABORT; |
| 424 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 425 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 426 | } |
| 427 | | |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 428 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 429 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 430 | struct parse_events_state *parse_state = _parse_state; |
| 431 | struct parse_events_error *error = parse_state->error; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 432 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 433 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 434 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 435 | list = alloc_list(); |
| 436 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 437 | 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] | 438 | parse_events_terms__delete($4); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 439 | free($1); |
| 440 | free($3); |
| 441 | if (err) { |
| 442 | free_list_evsel(list); |
| 443 | YYABORT; |
| 444 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 445 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 446 | } |
| 447 | | |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 448 | PE_NAME_CACHE_TYPE opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 449 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 450 | struct parse_events_state *parse_state = _parse_state; |
| 451 | struct parse_events_error *error = parse_state->error; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 452 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 453 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 454 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 455 | list = alloc_list(); |
| 456 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 457 | 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] | 458 | parse_events_terms__delete($2); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 459 | free($1); |
| 460 | if (err) { |
| 461 | free_list_evsel(list); |
| 462 | YYABORT; |
| 463 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 464 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | event_legacy_mem: |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 468 | PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc |
| 469 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 470 | struct parse_events_state *parse_state = _parse_state; |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 471 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 472 | int err; |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 473 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 474 | list = alloc_list(); |
| 475 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 476 | err = parse_events_add_breakpoint(list, &parse_state->idx, |
| 477 | (void *) $2, $6, $4); |
| 478 | free($6); |
| 479 | if (err) { |
| 480 | free(list); |
| 481 | YYABORT; |
| 482 | } |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 483 | $$ = list; |
| 484 | } |
| 485 | | |
| 486 | PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc |
| 487 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 488 | struct parse_events_state *parse_state = _parse_state; |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 489 | struct list_head *list; |
| 490 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 491 | list = alloc_list(); |
| 492 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 493 | if (parse_events_add_breakpoint(list, &parse_state->idx, |
| 494 | (void *) $2, NULL, $4)) { |
| 495 | free(list); |
| 496 | YYABORT; |
| 497 | } |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 498 | $$ = list; |
| 499 | } |
| 500 | | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 501 | PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc |
| 502 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 503 | struct parse_events_state *parse_state = _parse_state; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 504 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 505 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 506 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 507 | list = alloc_list(); |
| 508 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 509 | err = parse_events_add_breakpoint(list, &parse_state->idx, |
| 510 | (void *) $2, $4, 0); |
| 511 | free($4); |
| 512 | if (err) { |
| 513 | free(list); |
| 514 | YYABORT; |
| 515 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 516 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 517 | } |
| 518 | | |
| 519 | PE_PREFIX_MEM PE_VALUE sep_dc |
| 520 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 521 | struct parse_events_state *parse_state = _parse_state; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 522 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 523 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 524 | list = alloc_list(); |
| 525 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 526 | if (parse_events_add_breakpoint(list, &parse_state->idx, |
| 527 | (void *) $2, NULL, 0)) { |
| 528 | free(list); |
| 529 | YYABORT; |
| 530 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 531 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 532 | } |
| 533 | |
| 534 | event_legacy_tracepoint: |
Arnaldo Carvalho de Melo | 1d55e8e | 2016-02-19 18:45:12 -0300 | [diff] [blame] | 535 | tracepoint_name opt_event_config |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 536 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 537 | struct parse_events_state *parse_state = _parse_state; |
| 538 | struct parse_events_error *error = parse_state->error; |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 539 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 540 | int err; |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 541 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 542 | list = alloc_list(); |
| 543 | ABORT_ON(!list); |
He Kuang | e637d17 | 2015-09-28 03:52:16 +0000 | [diff] [blame] | 544 | if (error) |
| 545 | error->idx = @1.first_column; |
| 546 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 547 | err = parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event, |
| 548 | error, $2); |
He Kuang | e637d17 | 2015-09-28 03:52:16 +0000 | [diff] [blame] | 549 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 550 | parse_events_terms__delete($2); |
| 551 | free($1.sys); |
| 552 | free($1.event); |
| 553 | if (err) { |
| 554 | free(list); |
Ian Rogers | e1e9b78 | 2019-11-08 23:58:40 -0800 | [diff] [blame] | 555 | YYABORT; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 556 | } |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 557 | $$ = list; |
| 558 | } |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 559 | |
| 560 | tracepoint_name: |
| 561 | PE_NAME '-' PE_NAME ':' PE_NAME |
| 562 | { |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 563 | struct tracepoint_name tracepoint; |
| 564 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 565 | ABORT_ON(asprintf(&tracepoint.sys, "%s-%s", $1, $3) < 0); |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 566 | tracepoint.event = $5; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 567 | free($1); |
| 568 | free($3); |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 569 | $$ = tracepoint; |
| 570 | } |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 571 | | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 572 | PE_NAME ':' PE_NAME |
| 573 | { |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 574 | struct tracepoint_name tracepoint = {$1, $3}; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 575 | |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 576 | $$ = tracepoint; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | event_legacy_numeric: |
Wang Nan | 10bf358 | 2016-02-19 11:44:00 +0000 | [diff] [blame] | 580 | PE_VALUE ':' PE_VALUE opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 581 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 582 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 583 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 584 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 585 | list = alloc_list(); |
| 586 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 587 | err = parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4); |
Wang Nan | 10bf358 | 2016-02-19 11:44:00 +0000 | [diff] [blame] | 588 | parse_events_terms__delete($4); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 589 | if (err) { |
| 590 | free(list); |
| 591 | YYABORT; |
| 592 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 593 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | event_legacy_raw: |
Wang Nan | 10bf358 | 2016-02-19 11:44:00 +0000 | [diff] [blame] | 597 | PE_RAW opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 598 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 599 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 600 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 601 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 602 | list = alloc_list(); |
| 603 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 604 | 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] | 605 | parse_events_terms__delete($2); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 606 | if (err) { |
| 607 | free(list); |
| 608 | YYABORT; |
| 609 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 610 | $$ = list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 611 | } |
| 612 | |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 613 | event_bpf_file: |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 614 | PE_BPF_OBJECT opt_event_config |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 615 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 616 | struct parse_events_state *parse_state = _parse_state; |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 617 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 618 | int err; |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 619 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 620 | list = alloc_list(); |
| 621 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 622 | err = parse_events_load_bpf(parse_state, list, $1, false, $2); |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 623 | parse_events_terms__delete($2); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 624 | free($1); |
| 625 | if (err) { |
| 626 | free(list); |
| 627 | YYABORT; |
| 628 | } |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 629 | $$ = list; |
| 630 | } |
| 631 | | |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 632 | PE_BPF_SOURCE opt_event_config |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 633 | { |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 634 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 635 | int err; |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 636 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 637 | list = alloc_list(); |
| 638 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 639 | err = parse_events_load_bpf(_parse_state, list, $1, true, $2); |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 640 | parse_events_terms__delete($2); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 641 | if (err) { |
| 642 | free(list); |
| 643 | YYABORT; |
| 644 | } |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 645 | $$ = list; |
| 646 | } |
| 647 | |
Arnaldo Carvalho de Melo | 1d55e8e | 2016-02-19 18:45:12 -0300 | [diff] [blame] | 648 | opt_event_config: |
| 649 | '/' event_config '/' |
| 650 | { |
| 651 | $$ = $2; |
| 652 | } |
| 653 | | |
| 654 | '/' '/' |
| 655 | { |
| 656 | $$ = NULL; |
| 657 | } |
| 658 | | |
| 659 | { |
| 660 | $$ = NULL; |
| 661 | } |
| 662 | |
Jiri Olsa | ceac7b7 | 2018-06-05 14:14:16 +0200 | [diff] [blame] | 663 | opt_pmu_config: |
| 664 | '/' event_config '/' |
| 665 | { |
| 666 | $$ = $2; |
| 667 | } |
| 668 | | |
| 669 | '/' '/' |
| 670 | { |
| 671 | $$ = NULL; |
| 672 | } |
| 673 | |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 674 | start_terms: event_config |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 675 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 676 | struct parse_events_state *parse_state = _parse_state; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 677 | if (parse_state->terms) { |
| 678 | parse_events_terms__delete ($1); |
| 679 | YYABORT; |
| 680 | } |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 681 | parse_state->terms = $1; |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 682 | } |
| 683 | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 684 | event_config: |
| 685 | event_config ',' event_term |
| 686 | { |
| 687 | struct list_head *head = $1; |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 688 | struct parse_events_term *term = $3; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 689 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 690 | if (!head) { |
Ian Rogers | 1dc9255 | 2019-10-30 15:34:47 -0700 | [diff] [blame] | 691 | parse_events_term__delete(term); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 692 | YYABORT; |
| 693 | } |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 694 | list_add_tail(&term->list, head); |
| 695 | $$ = $1; |
| 696 | } |
| 697 | | |
| 698 | event_term |
| 699 | { |
| 700 | struct list_head *head = malloc(sizeof(*head)); |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 701 | struct parse_events_term *term = $1; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 702 | |
| 703 | ABORT_ON(!head); |
| 704 | INIT_LIST_HEAD(head); |
| 705 | list_add_tail(&term->list, head); |
| 706 | $$ = head; |
| 707 | } |
| 708 | |
| 709 | event_term: |
Jiri Olsa | 3a6c51e | 2020-04-17 00:14:05 +0200 | [diff] [blame] | 710 | PE_RAW |
| 711 | { |
| 712 | struct parse_events_term *term; |
| 713 | |
| 714 | ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_CONFIG, |
| 715 | NULL, $1, false, &@1, NULL)); |
| 716 | $$ = term; |
| 717 | } |
| 718 | | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 719 | PE_NAME '=' PE_NAME |
| 720 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 721 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 722 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 723 | if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 724 | $1, $3, &@1, &@3)) { |
| 725 | free($1); |
| 726 | free($3); |
| 727 | YYABORT; |
| 728 | } |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 729 | $$ = term; |
| 730 | } |
| 731 | | |
| 732 | PE_NAME '=' PE_VALUE |
| 733 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 734 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 735 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 736 | if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 737 | $1, $3, false, &@1, &@3)) { |
| 738 | free($1); |
| 739 | YYABORT; |
| 740 | } |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 741 | $$ = term; |
| 742 | } |
| 743 | | |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 744 | PE_NAME '=' PE_VALUE_SYM_HW |
| 745 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 746 | struct parse_events_term *term; |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 747 | int config = $3 & 255; |
| 748 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 749 | if (parse_events_term__sym_hw(&term, $1, config)) { |
| 750 | free($1); |
| 751 | YYABORT; |
| 752 | } |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 753 | $$ = term; |
| 754 | } |
| 755 | | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 756 | PE_NAME |
| 757 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 758 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 759 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 760 | if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 761 | $1, 1, true, &@1, NULL)) { |
| 762 | free($1); |
| 763 | YYABORT; |
| 764 | } |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 765 | $$ = term; |
| 766 | } |
| 767 | | |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 768 | PE_VALUE_SYM_HW |
| 769 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 770 | struct parse_events_term *term; |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 771 | int config = $1 & 255; |
| 772 | |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 773 | ABORT_ON(parse_events_term__sym_hw(&term, NULL, config)); |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 774 | $$ = term; |
| 775 | } |
| 776 | | |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 777 | PE_TERM '=' PE_NAME |
| 778 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 779 | struct parse_events_term *term; |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 780 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 781 | if (parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3)) { |
| 782 | free($3); |
| 783 | YYABORT; |
| 784 | } |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 785 | $$ = term; |
| 786 | } |
| 787 | | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 788 | PE_TERM '=' PE_VALUE |
| 789 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 790 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 791 | |
Jiri Olsa | 99e7138 | 2017-02-17 15:00:56 +0100 | [diff] [blame] | 792 | 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] | 793 | $$ = term; |
| 794 | } |
| 795 | | |
| 796 | PE_TERM |
| 797 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 798 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 799 | |
Jiri Olsa | 99e7138 | 2017-02-17 15:00:56 +0100 | [diff] [blame] | 800 | 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] | 801 | $$ = term; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 802 | } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 803 | | |
| 804 | PE_NAME array '=' PE_NAME |
| 805 | { |
| 806 | struct parse_events_term *term; |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 807 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 808 | if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 809 | $1, $4, &@1, &@4)) { |
| 810 | free($1); |
| 811 | free($4); |
| 812 | free($2.ranges); |
| 813 | YYABORT; |
| 814 | } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 815 | term->array = $2; |
| 816 | $$ = term; |
| 817 | } |
| 818 | | |
| 819 | PE_NAME array '=' PE_VALUE |
| 820 | { |
| 821 | struct parse_events_term *term; |
| 822 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 823 | if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 824 | $1, $4, false, &@1, &@4)) { |
| 825 | free($1); |
| 826 | free($2.ranges); |
| 827 | YYABORT; |
| 828 | } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 829 | term->array = $2; |
| 830 | $$ = term; |
| 831 | } |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 832 | | |
| 833 | PE_DRV_CFG_TERM |
| 834 | { |
| 835 | struct parse_events_term *term; |
Ian Rogers | b6645a7 | 2019-10-30 15:34:43 -0700 | [diff] [blame] | 836 | char *config = strdup($1); |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 837 | |
Ian Rogers | b6645a7 | 2019-10-30 15:34:43 -0700 | [diff] [blame] | 838 | ABORT_ON(!config); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 839 | if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG, |
| 840 | config, $1, &@1, NULL)) { |
| 841 | free($1); |
| 842 | free(config); |
| 843 | YYABORT; |
| 844 | } |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 845 | $$ = term; |
| 846 | } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 847 | |
| 848 | array: |
| 849 | '[' array_terms ']' |
| 850 | { |
| 851 | $$ = $2; |
| 852 | } |
| 853 | | |
| 854 | PE_ARRAY_ALL |
| 855 | { |
| 856 | $$.nr_ranges = 0; |
| 857 | $$.ranges = NULL; |
| 858 | } |
| 859 | |
| 860 | array_terms: |
| 861 | array_terms ',' array_term |
| 862 | { |
| 863 | struct parse_events_array new_array; |
| 864 | |
| 865 | new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges; |
Ian Rogers | 826100a | 2019-10-22 17:53:33 -0700 | [diff] [blame] | 866 | new_array.ranges = realloc($1.ranges, |
| 867 | sizeof(new_array.ranges[0]) * |
| 868 | new_array.nr_ranges); |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 869 | ABORT_ON(!new_array.ranges); |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 870 | memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges, |
| 871 | $3.nr_ranges * sizeof(new_array.ranges[0])); |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 872 | free($3.ranges); |
| 873 | $$ = new_array; |
| 874 | } |
| 875 | | |
| 876 | array_term |
| 877 | |
| 878 | array_term: |
| 879 | PE_VALUE |
| 880 | { |
| 881 | struct parse_events_array array; |
| 882 | |
| 883 | array.nr_ranges = 1; |
| 884 | array.ranges = malloc(sizeof(array.ranges[0])); |
| 885 | ABORT_ON(!array.ranges); |
| 886 | array.ranges[0].start = $1; |
| 887 | array.ranges[0].length = 1; |
| 888 | $$ = array; |
| 889 | } |
| 890 | | |
| 891 | PE_VALUE PE_ARRAY_RANGE PE_VALUE |
| 892 | { |
| 893 | struct parse_events_array array; |
| 894 | |
| 895 | ABORT_ON($3 < $1); |
| 896 | array.nr_ranges = 1; |
| 897 | array.ranges = malloc(sizeof(array.ranges[0])); |
| 898 | ABORT_ON(!array.ranges); |
| 899 | array.ranges[0].start = $1; |
| 900 | array.ranges[0].length = $3 - $1 + 1; |
| 901 | $$ = array; |
| 902 | } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 903 | |
| 904 | sep_dc: ':' | |
| 905 | |
Jiri Olsa | 714a92d | 2019-02-13 13:32:40 +0100 | [diff] [blame] | 906 | sep_slash_slash_dc: '/' '/' | ':' | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 907 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 908 | %% |
| 909 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 910 | void parse_events_error(YYLTYPE *loc, void *parse_state, |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 911 | void *scanner __maybe_unused, |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 912 | char const *msg __maybe_unused) |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 913 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 914 | parse_events_evlist_error(parse_state, loc->last_column, "parser error"); |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 915 | } |