Jiri Olsa | fc8c0a9 | 2020-01-12 20:22:59 +0100 | [diff] [blame] | 1 | %define api.pure full |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 2 | %parse-param {void *_parse_state} |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 3 | %parse-param {void *scanner} |
| 4 | %lex-param {void* scanner} |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 5 | %locations |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 6 | |
| 7 | %{ |
| 8 | |
| 9 | #define YYDEBUG 1 |
| 10 | |
Agustin Vega-Frias | b2b9d3a | 2018-03-06 09:04:42 -0500 | [diff] [blame] | 11 | #include <fnmatch.h> |
Arnaldo Carvalho de Melo | bd70462 | 2019-09-24 15:45:21 -0300 | [diff] [blame] | 12 | #include <stdio.h> |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 13 | #include <linux/compiler.h> |
Borislav Petkov | d944c4e | 2014-04-25 21:31:02 +0200 | [diff] [blame] | 14 | #include <linux/types.h> |
Ian Rogers | f2a8ecd | 2019-10-30 15:34:44 -0700 | [diff] [blame] | 15 | #include <linux/zalloc.h> |
Andi Kleen | 231bb2a | 2017-01-27 18:03:39 -0800 | [diff] [blame] | 16 | #include "pmu.h" |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 17 | #include "evsel.h" |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 18 | #include "parse-events.h" |
Zheng Yan | ac20de6f | 2012-06-15 14:31:39 +0800 | [diff] [blame] | 19 | #include "parse-events-bison.h" |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 20 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 21 | void parse_events_error(YYLTYPE *loc, void *parse_state, void *scanner, char const *msg); |
Arnaldo Carvalho de Melo | 34a0548 | 2017-02-15 10:09:11 -0300 | [diff] [blame] | 22 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 23 | #define ABORT_ON(val) \ |
| 24 | do { \ |
| 25 | if (val) \ |
| 26 | YYABORT; \ |
| 27 | } while (0) |
| 28 | |
Ian Rogers | ffaecd7 | 2020-06-08 22:36:10 -0700 | [diff] [blame] | 29 | static struct list_head* alloc_list(void) |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 30 | { |
| 31 | struct list_head *list; |
| 32 | |
| 33 | list = malloc(sizeof(*list)); |
| 34 | if (!list) |
| 35 | return NULL; |
| 36 | |
| 37 | INIT_LIST_HEAD(list); |
| 38 | return list; |
| 39 | } |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 40 | |
Ian Rogers | f2a8ecd | 2019-10-30 15:34:44 -0700 | [diff] [blame] | 41 | static void free_list_evsel(struct list_head* list_evsel) |
| 42 | { |
| 43 | struct evsel *evsel, *tmp; |
| 44 | |
| 45 | list_for_each_entry_safe(evsel, tmp, list_evsel, core.node) { |
| 46 | list_del_init(&evsel->core.node); |
Ian Rogers | 672f707 | 2020-03-18 19:31:00 -0700 | [diff] [blame] | 47 | evsel__delete(evsel); |
Ian Rogers | f2a8ecd | 2019-10-30 15:34:44 -0700 | [diff] [blame] | 48 | } |
| 49 | free(list_evsel); |
| 50 | } |
| 51 | |
Colin Ian King | 07ef757 | 2016-03-07 16:44:37 -0300 | [diff] [blame] | 52 | static void inc_group_count(struct list_head *list, |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 53 | struct parse_events_state *parse_state) |
Namhyung Kim | 97f63e4 | 2013-01-22 18:09:29 +0900 | [diff] [blame] | 54 | { |
| 55 | /* Count groups only have more than 1 members */ |
| 56 | if (!list_is_last(list->next, list)) |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 57 | parse_state->nr_groups++; |
Namhyung Kim | 97f63e4 | 2013-01-22 18:09:29 +0900 | [diff] [blame] | 58 | } |
| 59 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 60 | %} |
| 61 | |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 62 | %token PE_START_EVENTS PE_START_TERMS |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 63 | %token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 64 | %token PE_VALUE_SYM_TOOL |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 65 | %token PE_EVENT_NAME |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 66 | %token PE_NAME |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 67 | %token PE_BPF_OBJECT PE_BPF_SOURCE |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 68 | %token PE_MODIFIER_EVENT PE_MODIFIER_BP |
| 69 | %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 70 | %token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 71 | %token PE_ERROR |
Jiri Olsa | 387ad33 | 2020-06-02 23:47:29 +0200 | [diff] [blame] | 72 | %token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 73 | %token PE_ARRAY_ALL PE_ARRAY_RANGE |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 74 | %token PE_DRV_CFG_TERM |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 75 | %type <num> PE_VALUE |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 76 | %type <num> PE_VALUE_SYM_HW |
| 77 | %type <num> PE_VALUE_SYM_SW |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 78 | %type <num> PE_VALUE_SYM_TOOL |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 79 | %type <num> PE_RAW |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 80 | %type <num> PE_TERM |
Ian Rogers | f2a8ecd | 2019-10-30 15:34:44 -0700 | [diff] [blame] | 81 | %type <num> value_sym |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 82 | %type <str> PE_NAME |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 83 | %type <str> PE_BPF_OBJECT |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 84 | %type <str> PE_BPF_SOURCE |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 85 | %type <str> PE_NAME_CACHE_TYPE |
| 86 | %type <str> PE_NAME_CACHE_OP_RESULT |
| 87 | %type <str> PE_MODIFIER_EVENT |
| 88 | %type <str> PE_MODIFIER_BP |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 89 | %type <str> PE_EVENT_NAME |
Jiri Olsa | 387ad33 | 2020-06-02 23:47:29 +0200 | [diff] [blame] | 90 | %type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 91 | %type <str> PE_DRV_CFG_TERM |
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 | |
Ian Rogers | c2412fa | 2020-06-08 22:36:09 -0700 | [diff] [blame] | 352 | snprintf(pmu_name, sizeof(pmu_name), "%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 | 387ad33 | 2020-06-02 23:47:29 +0200 | [diff] [blame] | 359 | | |
| 360 | PE_PMU_EVENT_FAKE sep_dc |
| 361 | { |
| 362 | struct list_head *list; |
| 363 | int err; |
| 364 | |
| 365 | list = alloc_list(); |
| 366 | if (!list) |
| 367 | YYABORT; |
| 368 | |
| 369 | err = parse_events_add_pmu(_parse_state, list, $1, NULL, false, false); |
| 370 | free($1); |
| 371 | if (err < 0) { |
| 372 | free(list); |
| 373 | YYABORT; |
| 374 | } |
| 375 | $$ = list; |
| 376 | } |
| 377 | | |
| 378 | PE_PMU_EVENT_FAKE opt_pmu_config |
| 379 | { |
| 380 | struct list_head *list; |
| 381 | int err; |
| 382 | |
| 383 | list = alloc_list(); |
| 384 | if (!list) |
| 385 | YYABORT; |
| 386 | |
| 387 | err = parse_events_add_pmu(_parse_state, list, $1, $2, false, false); |
| 388 | free($1); |
| 389 | parse_events_terms__delete($2); |
| 390 | if (err < 0) { |
| 391 | free(list); |
| 392 | YYABORT; |
| 393 | } |
| 394 | $$ = list; |
| 395 | } |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 396 | |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 397 | value_sym: |
| 398 | PE_VALUE_SYM_HW |
| 399 | | |
| 400 | PE_VALUE_SYM_SW |
| 401 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 402 | event_legacy_symbol: |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 403 | value_sym '/' event_config '/' |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 404 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 405 | struct list_head *list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 406 | int type = $1 >> 16; |
| 407 | int config = $1 & 255; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 408 | int err; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 409 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 410 | list = alloc_list(); |
| 411 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 412 | 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] | 413 | parse_events_terms__delete($3); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 414 | if (err) { |
| 415 | free_list_evsel(list); |
| 416 | YYABORT; |
| 417 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 418 | $$ = list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 419 | } |
| 420 | | |
Jiri Olsa | 714a92d | 2019-02-13 13:32:40 +0100 | [diff] [blame] | 421 | value_sym sep_slash_slash_dc |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 422 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 423 | struct list_head *list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 424 | int type = $1 >> 16; |
| 425 | int config = $1 & 255; |
| 426 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 427 | list = alloc_list(); |
| 428 | ABORT_ON(!list); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 429 | ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 430 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 431 | } |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 432 | | |
| 433 | PE_VALUE_SYM_TOOL sep_slash_slash_dc |
| 434 | { |
| 435 | struct list_head *list; |
| 436 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 437 | list = alloc_list(); |
| 438 | ABORT_ON(!list); |
Andi Kleen | f0fbb11 | 2019-03-26 15:18:21 -0700 | [diff] [blame] | 439 | ABORT_ON(parse_events_add_tool(_parse_state, list, $1)); |
| 440 | $$ = list; |
| 441 | } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 442 | |
| 443 | event_legacy_cache: |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 444 | 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] | 445 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 446 | struct parse_events_state *parse_state = _parse_state; |
| 447 | struct parse_events_error *error = parse_state->error; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 448 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 449 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 450 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 451 | list = alloc_list(); |
| 452 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 453 | 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] | 454 | parse_events_terms__delete($6); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 455 | free($1); |
| 456 | free($3); |
| 457 | free($5); |
| 458 | if (err) { |
| 459 | free_list_evsel(list); |
| 460 | YYABORT; |
| 461 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 462 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 463 | } |
| 464 | | |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 465 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 466 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 467 | struct parse_events_state *parse_state = _parse_state; |
| 468 | struct parse_events_error *error = parse_state->error; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 469 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 470 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 471 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 472 | list = alloc_list(); |
| 473 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 474 | 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] | 475 | parse_events_terms__delete($4); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 476 | free($1); |
| 477 | free($3); |
| 478 | if (err) { |
| 479 | free_list_evsel(list); |
| 480 | YYABORT; |
| 481 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 482 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 483 | } |
| 484 | | |
Wang Nan | 43d0b97 | 2016-02-19 11:44:01 +0000 | [diff] [blame] | 485 | PE_NAME_CACHE_TYPE opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 486 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 487 | struct parse_events_state *parse_state = _parse_state; |
| 488 | struct parse_events_error *error = parse_state->error; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 489 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 490 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 491 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 492 | list = alloc_list(); |
| 493 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 494 | 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] | 495 | parse_events_terms__delete($2); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 496 | free($1); |
| 497 | if (err) { |
| 498 | free_list_evsel(list); |
| 499 | YYABORT; |
| 500 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 501 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 502 | } |
| 503 | |
| 504 | event_legacy_mem: |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 505 | PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc |
| 506 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 507 | struct parse_events_state *parse_state = _parse_state; |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 508 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 509 | int err; |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 510 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 511 | list = alloc_list(); |
| 512 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 513 | err = parse_events_add_breakpoint(list, &parse_state->idx, |
Ian Rogers | aa98d84 | 2020-09-24 17:39:03 -0700 | [diff] [blame^] | 514 | $2, $6, $4); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 515 | free($6); |
| 516 | if (err) { |
| 517 | free(list); |
| 518 | YYABORT; |
| 519 | } |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 520 | $$ = list; |
| 521 | } |
| 522 | | |
| 523 | PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc |
| 524 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 525 | struct parse_events_state *parse_state = _parse_state; |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 526 | struct list_head *list; |
| 527 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 528 | list = alloc_list(); |
| 529 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 530 | if (parse_events_add_breakpoint(list, &parse_state->idx, |
Ian Rogers | aa98d84 | 2020-09-24 17:39:03 -0700 | [diff] [blame^] | 531 | $2, NULL, $4)) { |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 532 | free(list); |
| 533 | YYABORT; |
| 534 | } |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 535 | $$ = list; |
| 536 | } |
| 537 | | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 538 | PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc |
| 539 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 540 | struct parse_events_state *parse_state = _parse_state; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 541 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 542 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 543 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 544 | list = alloc_list(); |
| 545 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 546 | err = parse_events_add_breakpoint(list, &parse_state->idx, |
Ian Rogers | aa98d84 | 2020-09-24 17:39:03 -0700 | [diff] [blame^] | 547 | $2, $4, 0); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 548 | free($4); |
| 549 | if (err) { |
| 550 | free(list); |
| 551 | YYABORT; |
| 552 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 553 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 554 | } |
| 555 | | |
| 556 | PE_PREFIX_MEM PE_VALUE sep_dc |
| 557 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 558 | struct parse_events_state *parse_state = _parse_state; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 559 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 560 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 561 | list = alloc_list(); |
| 562 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 563 | if (parse_events_add_breakpoint(list, &parse_state->idx, |
Ian Rogers | aa98d84 | 2020-09-24 17:39:03 -0700 | [diff] [blame^] | 564 | $2, NULL, 0)) { |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 565 | free(list); |
| 566 | YYABORT; |
| 567 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 568 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | event_legacy_tracepoint: |
Arnaldo Carvalho de Melo | 1d55e8e | 2016-02-19 18:45:12 -0300 | [diff] [blame] | 572 | tracepoint_name opt_event_config |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 573 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 574 | struct parse_events_state *parse_state = _parse_state; |
| 575 | struct parse_events_error *error = parse_state->error; |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 576 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 577 | int err; |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 578 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 579 | list = alloc_list(); |
| 580 | ABORT_ON(!list); |
He Kuang | e637d17 | 2015-09-28 03:52:16 +0000 | [diff] [blame] | 581 | if (error) |
| 582 | error->idx = @1.first_column; |
| 583 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 584 | err = parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event, |
| 585 | error, $2); |
He Kuang | e637d17 | 2015-09-28 03:52:16 +0000 | [diff] [blame] | 586 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 587 | parse_events_terms__delete($2); |
| 588 | free($1.sys); |
| 589 | free($1.event); |
| 590 | if (err) { |
| 591 | free(list); |
Ian Rogers | e1e9b78 | 2019-11-08 23:58:40 -0800 | [diff] [blame] | 592 | YYABORT; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 593 | } |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 594 | $$ = list; |
| 595 | } |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 596 | |
| 597 | tracepoint_name: |
| 598 | PE_NAME '-' PE_NAME ':' PE_NAME |
| 599 | { |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 600 | struct tracepoint_name tracepoint; |
| 601 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 602 | ABORT_ON(asprintf(&tracepoint.sys, "%s-%s", $1, $3) < 0); |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 603 | tracepoint.event = $5; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 604 | free($1); |
| 605 | free($3); |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 606 | $$ = tracepoint; |
| 607 | } |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 608 | | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 609 | PE_NAME ':' PE_NAME |
| 610 | { |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 611 | struct tracepoint_name tracepoint = {$1, $3}; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 612 | |
He Kuang | 865582c | 2015-09-28 03:52:15 +0000 | [diff] [blame] | 613 | $$ = tracepoint; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | event_legacy_numeric: |
Wang Nan | 10bf358 | 2016-02-19 11:44:00 +0000 | [diff] [blame] | 617 | PE_VALUE ':' PE_VALUE opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 618 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 619 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 620 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 621 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 622 | list = alloc_list(); |
| 623 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 624 | err = parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4); |
Wang Nan | 10bf358 | 2016-02-19 11:44:00 +0000 | [diff] [blame] | 625 | parse_events_terms__delete($4); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 626 | if (err) { |
| 627 | free(list); |
| 628 | YYABORT; |
| 629 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 630 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | event_legacy_raw: |
Wang Nan | 10bf358 | 2016-02-19 11:44:00 +0000 | [diff] [blame] | 634 | PE_RAW opt_event_config |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 635 | { |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 636 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 637 | int err; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 638 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 639 | list = alloc_list(); |
| 640 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 641 | 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] | 642 | parse_events_terms__delete($2); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 643 | if (err) { |
| 644 | free(list); |
| 645 | YYABORT; |
| 646 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 647 | $$ = list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 648 | } |
| 649 | |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 650 | event_bpf_file: |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 651 | PE_BPF_OBJECT opt_event_config |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 652 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 653 | struct parse_events_state *parse_state = _parse_state; |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 654 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 655 | int err; |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 656 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 657 | list = alloc_list(); |
| 658 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 659 | err = parse_events_load_bpf(parse_state, list, $1, false, $2); |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 660 | parse_events_terms__delete($2); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 661 | free($1); |
| 662 | if (err) { |
| 663 | free(list); |
| 664 | YYABORT; |
| 665 | } |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 666 | $$ = list; |
| 667 | } |
| 668 | | |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 669 | PE_BPF_SOURCE opt_event_config |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 670 | { |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 671 | struct list_head *list; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 672 | int err; |
Wang Nan | d509db0 | 2015-10-14 12:41:20 +0000 | [diff] [blame] | 673 | |
Ian Rogers | a26e471 | 2019-10-22 17:53:32 -0700 | [diff] [blame] | 674 | list = alloc_list(); |
| 675 | ABORT_ON(!list); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 676 | err = parse_events_load_bpf(_parse_state, list, $1, true, $2); |
Wang Nan | a34f3be | 2016-02-22 09:10:31 +0000 | [diff] [blame] | 677 | parse_events_terms__delete($2); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 678 | if (err) { |
| 679 | free(list); |
| 680 | YYABORT; |
| 681 | } |
Wang Nan | 84c86ca | 2015-10-14 12:41:14 +0000 | [diff] [blame] | 682 | $$ = list; |
| 683 | } |
| 684 | |
Arnaldo Carvalho de Melo | 1d55e8e | 2016-02-19 18:45:12 -0300 | [diff] [blame] | 685 | opt_event_config: |
| 686 | '/' event_config '/' |
| 687 | { |
| 688 | $$ = $2; |
| 689 | } |
| 690 | | |
| 691 | '/' '/' |
| 692 | { |
| 693 | $$ = NULL; |
| 694 | } |
| 695 | | |
| 696 | { |
| 697 | $$ = NULL; |
| 698 | } |
| 699 | |
Jiri Olsa | ceac7b7 | 2018-06-05 14:14:16 +0200 | [diff] [blame] | 700 | opt_pmu_config: |
| 701 | '/' event_config '/' |
| 702 | { |
| 703 | $$ = $2; |
| 704 | } |
| 705 | | |
| 706 | '/' '/' |
| 707 | { |
| 708 | $$ = NULL; |
| 709 | } |
| 710 | |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 711 | start_terms: event_config |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 712 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 713 | struct parse_events_state *parse_state = _parse_state; |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 714 | if (parse_state->terms) { |
| 715 | parse_events_terms__delete ($1); |
| 716 | YYABORT; |
| 717 | } |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 718 | parse_state->terms = $1; |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 719 | } |
| 720 | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 721 | event_config: |
| 722 | event_config ',' event_term |
| 723 | { |
| 724 | struct list_head *head = $1; |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 725 | struct parse_events_term *term = $3; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 726 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 727 | if (!head) { |
Ian Rogers | 1dc9255 | 2019-10-30 15:34:47 -0700 | [diff] [blame] | 728 | parse_events_term__delete(term); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 729 | YYABORT; |
| 730 | } |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 731 | list_add_tail(&term->list, head); |
| 732 | $$ = $1; |
| 733 | } |
| 734 | | |
| 735 | event_term |
| 736 | { |
| 737 | struct list_head *head = malloc(sizeof(*head)); |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 738 | struct parse_events_term *term = $1; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 739 | |
| 740 | ABORT_ON(!head); |
| 741 | INIT_LIST_HEAD(head); |
| 742 | list_add_tail(&term->list, head); |
| 743 | $$ = head; |
| 744 | } |
| 745 | |
| 746 | event_term: |
Jiri Olsa | 3a6c51e | 2020-04-17 00:14:05 +0200 | [diff] [blame] | 747 | PE_RAW |
| 748 | { |
| 749 | struct parse_events_term *term; |
| 750 | |
| 751 | ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_CONFIG, |
| 752 | NULL, $1, false, &@1, NULL)); |
| 753 | $$ = term; |
| 754 | } |
| 755 | | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 756 | PE_NAME '=' 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__str(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 761 | $1, $3, &@1, &@3)) { |
| 762 | free($1); |
| 763 | free($3); |
| 764 | YYABORT; |
| 765 | } |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 766 | $$ = term; |
| 767 | } |
| 768 | | |
| 769 | PE_NAME '=' PE_VALUE |
| 770 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 771 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 772 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 773 | if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 774 | $1, $3, false, &@1, &@3)) { |
| 775 | free($1); |
| 776 | YYABORT; |
| 777 | } |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 778 | $$ = term; |
| 779 | } |
| 780 | | |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 781 | PE_NAME '=' PE_VALUE_SYM_HW |
| 782 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 783 | struct parse_events_term *term; |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 784 | int config = $3 & 255; |
| 785 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 786 | if (parse_events_term__sym_hw(&term, $1, config)) { |
| 787 | free($1); |
| 788 | YYABORT; |
| 789 | } |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 790 | $$ = term; |
| 791 | } |
| 792 | | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 793 | PE_NAME |
| 794 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 795 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 796 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 797 | if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 798 | $1, 1, true, &@1, NULL)) { |
| 799 | free($1); |
| 800 | YYABORT; |
| 801 | } |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 802 | $$ = term; |
| 803 | } |
| 804 | | |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 805 | PE_VALUE_SYM_HW |
| 806 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 807 | struct parse_events_term *term; |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 808 | int config = $1 & 255; |
| 809 | |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 810 | ABORT_ON(parse_events_term__sym_hw(&term, NULL, config)); |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 811 | $$ = term; |
| 812 | } |
| 813 | | |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 814 | PE_TERM '=' PE_NAME |
| 815 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 816 | struct parse_events_term *term; |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 817 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 818 | if (parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3)) { |
| 819 | free($3); |
| 820 | YYABORT; |
| 821 | } |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 822 | $$ = term; |
| 823 | } |
| 824 | | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 825 | PE_TERM '=' PE_VALUE |
| 826 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 827 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 828 | |
Jiri Olsa | 99e7138 | 2017-02-17 15:00:56 +0100 | [diff] [blame] | 829 | 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] | 830 | $$ = term; |
| 831 | } |
| 832 | | |
| 833 | PE_TERM |
| 834 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 835 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 836 | |
Jiri Olsa | 99e7138 | 2017-02-17 15:00:56 +0100 | [diff] [blame] | 837 | ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, true, &@1, NULL)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 838 | $$ = term; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 839 | } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 840 | | |
| 841 | PE_NAME array '=' PE_NAME |
| 842 | { |
| 843 | struct parse_events_term *term; |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 844 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 845 | if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 846 | $1, $4, &@1, &@4)) { |
| 847 | free($1); |
| 848 | free($4); |
| 849 | free($2.ranges); |
| 850 | YYABORT; |
| 851 | } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 852 | term->array = $2; |
| 853 | $$ = term; |
| 854 | } |
| 855 | | |
| 856 | PE_NAME array '=' PE_VALUE |
| 857 | { |
| 858 | struct parse_events_term *term; |
| 859 | |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 860 | if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 861 | $1, $4, false, &@1, &@4)) { |
| 862 | free($1); |
| 863 | free($2.ranges); |
| 864 | YYABORT; |
| 865 | } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 866 | term->array = $2; |
| 867 | $$ = term; |
| 868 | } |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 869 | | |
| 870 | PE_DRV_CFG_TERM |
| 871 | { |
| 872 | struct parse_events_term *term; |
Ian Rogers | b6645a7 | 2019-10-30 15:34:43 -0700 | [diff] [blame] | 873 | char *config = strdup($1); |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 874 | |
Ian Rogers | b6645a7 | 2019-10-30 15:34:43 -0700 | [diff] [blame] | 875 | ABORT_ON(!config); |
Ian Rogers | cabbf26 | 2019-10-30 15:34:45 -0700 | [diff] [blame] | 876 | if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG, |
| 877 | config, $1, &@1, NULL)) { |
| 878 | free($1); |
| 879 | free(config); |
| 880 | YYABORT; |
| 881 | } |
Mathieu Poirier | dd60fba | 2016-09-06 10:37:15 -0600 | [diff] [blame] | 882 | $$ = term; |
| 883 | } |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 884 | |
| 885 | array: |
| 886 | '[' array_terms ']' |
| 887 | { |
| 888 | $$ = $2; |
| 889 | } |
| 890 | | |
| 891 | PE_ARRAY_ALL |
| 892 | { |
| 893 | $$.nr_ranges = 0; |
| 894 | $$.ranges = NULL; |
| 895 | } |
| 896 | |
| 897 | array_terms: |
| 898 | array_terms ',' array_term |
| 899 | { |
| 900 | struct parse_events_array new_array; |
| 901 | |
| 902 | new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges; |
Ian Rogers | 826100a | 2019-10-22 17:53:33 -0700 | [diff] [blame] | 903 | new_array.ranges = realloc($1.ranges, |
| 904 | sizeof(new_array.ranges[0]) * |
| 905 | new_array.nr_ranges); |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 906 | ABORT_ON(!new_array.ranges); |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 907 | memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges, |
| 908 | $3.nr_ranges * sizeof(new_array.ranges[0])); |
Wang Nan | e571e02 | 2016-02-22 09:10:35 +0000 | [diff] [blame] | 909 | free($3.ranges); |
| 910 | $$ = new_array; |
| 911 | } |
| 912 | | |
| 913 | array_term |
| 914 | |
| 915 | array_term: |
| 916 | PE_VALUE |
| 917 | { |
| 918 | struct parse_events_array array; |
| 919 | |
| 920 | array.nr_ranges = 1; |
| 921 | array.ranges = malloc(sizeof(array.ranges[0])); |
| 922 | ABORT_ON(!array.ranges); |
| 923 | array.ranges[0].start = $1; |
| 924 | array.ranges[0].length = 1; |
| 925 | $$ = array; |
| 926 | } |
| 927 | | |
| 928 | PE_VALUE PE_ARRAY_RANGE PE_VALUE |
| 929 | { |
| 930 | struct parse_events_array array; |
| 931 | |
| 932 | ABORT_ON($3 < $1); |
| 933 | array.nr_ranges = 1; |
| 934 | array.ranges = malloc(sizeof(array.ranges[0])); |
| 935 | ABORT_ON(!array.ranges); |
| 936 | array.ranges[0].start = $1; |
| 937 | array.ranges[0].length = $3 - $1 + 1; |
| 938 | $$ = array; |
| 939 | } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 940 | |
| 941 | sep_dc: ':' | |
| 942 | |
Jiri Olsa | 714a92d | 2019-02-13 13:32:40 +0100 | [diff] [blame] | 943 | sep_slash_slash_dc: '/' '/' | ':' | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 944 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 945 | %% |
| 946 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 947 | void parse_events_error(YYLTYPE *loc, void *parse_state, |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 948 | void *scanner __maybe_unused, |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 949 | char const *msg __maybe_unused) |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 950 | { |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 951 | parse_events_evlist_error(parse_state, loc->last_column, "parser error"); |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 952 | } |