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