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