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