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" |
| 15 | #include "parse-events.h" |
Zheng Yan | ac20de6f | 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 | |
Namhyung Kim | 97f63e4 | 2013-01-22 18:09:29 +0900 | [diff] [blame] | 31 | static inc_group_count(struct list_head *list, |
| 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 |
| 45 | %token PE_MODIFIER_EVENT PE_MODIFIER_BP |
| 46 | %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 47 | %token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 48 | %token PE_ERROR |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 49 | %token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 50 | %type <num> PE_VALUE |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 51 | %type <num> PE_VALUE_SYM_HW |
| 52 | %type <num> PE_VALUE_SYM_SW |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 53 | %type <num> PE_RAW |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 54 | %type <num> PE_TERM |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 55 | %type <str> PE_NAME |
| 56 | %type <str> PE_NAME_CACHE_TYPE |
| 57 | %type <str> PE_NAME_CACHE_OP_RESULT |
| 58 | %type <str> PE_MODIFIER_EVENT |
| 59 | %type <str> PE_MODIFIER_BP |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 60 | %type <str> PE_EVENT_NAME |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 61 | %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] | 62 | %type <num> value_sym |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 63 | %type <head> event_config |
| 64 | %type <term> event_term |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 65 | %type <head> event_pmu |
| 66 | %type <head> event_legacy_symbol |
| 67 | %type <head> event_legacy_cache |
| 68 | %type <head> event_legacy_mem |
| 69 | %type <head> event_legacy_tracepoint |
| 70 | %type <head> event_legacy_numeric |
| 71 | %type <head> event_legacy_raw |
| 72 | %type <head> event_def |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 73 | %type <head> event_mod |
| 74 | %type <head> event_name |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 75 | %type <head> event |
| 76 | %type <head> events |
| 77 | %type <head> group_def |
| 78 | %type <head> group |
| 79 | %type <head> groups |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 80 | |
| 81 | %union |
| 82 | { |
| 83 | char *str; |
Robert Richter | b527bab | 2012-08-07 19:43:13 +0200 | [diff] [blame] | 84 | u64 num; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 85 | struct list_head *head; |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 86 | struct parse_events_term *term; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 87 | } |
| 88 | %% |
| 89 | |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 90 | start: |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 91 | PE_START_EVENTS start_events |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 92 | | |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 93 | PE_START_TERMS start_terms |
| 94 | |
| 95 | start_events: groups |
| 96 | { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 97 | struct parse_events_evlist *data = _data; |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 98 | |
| 99 | parse_events_update_lists($1, &data->list); |
| 100 | } |
| 101 | |
| 102 | groups: |
| 103 | groups ',' group |
| 104 | { |
| 105 | struct list_head *list = $1; |
| 106 | struct list_head *group = $3; |
| 107 | |
| 108 | parse_events_update_lists(group, list); |
| 109 | $$ = list; |
| 110 | } |
| 111 | | |
| 112 | groups ',' event |
| 113 | { |
| 114 | struct list_head *list = $1; |
| 115 | struct list_head *event = $3; |
| 116 | |
| 117 | parse_events_update_lists(event, list); |
| 118 | $$ = list; |
| 119 | } |
| 120 | | |
| 121 | group |
| 122 | | |
| 123 | event |
| 124 | |
| 125 | group: |
| 126 | group_def ':' PE_MODIFIER_EVENT |
| 127 | { |
| 128 | struct list_head *list = $1; |
| 129 | |
| 130 | ABORT_ON(parse_events__modifier_group(list, $3)); |
| 131 | $$ = list; |
| 132 | } |
| 133 | | |
| 134 | group_def |
| 135 | |
| 136 | group_def: |
| 137 | PE_NAME '{' events '}' |
| 138 | { |
| 139 | struct list_head *list = $3; |
| 140 | |
Namhyung Kim | 97f63e4 | 2013-01-22 18:09:29 +0900 | [diff] [blame] | 141 | inc_group_count(list, _data); |
Arnaldo Carvalho de Melo | 63dab22 | 2012-08-14 16:35:48 -0300 | [diff] [blame] | 142 | parse_events__set_leader($1, list); |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 143 | $$ = list; |
| 144 | } |
| 145 | | |
| 146 | '{' events '}' |
| 147 | { |
| 148 | struct list_head *list = $2; |
| 149 | |
Namhyung Kim | 97f63e4 | 2013-01-22 18:09:29 +0900 | [diff] [blame] | 150 | inc_group_count(list, _data); |
Arnaldo Carvalho de Melo | 63dab22 | 2012-08-14 16:35:48 -0300 | [diff] [blame] | 151 | parse_events__set_leader(NULL, list); |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 152 | $$ = list; |
| 153 | } |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 154 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 155 | events: |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 156 | events ',' event |
| 157 | { |
| 158 | struct list_head *event = $3; |
| 159 | struct list_head *list = $1; |
| 160 | |
| 161 | parse_events_update_lists(event, list); |
| 162 | $$ = list; |
| 163 | } |
| 164 | | |
| 165 | event |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 166 | |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 167 | event: event_mod |
| 168 | |
| 169 | event_mod: |
| 170 | event_name PE_MODIFIER_EVENT |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 171 | { |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 172 | struct list_head *list = $1; |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame] | 173 | |
Jiri Olsa | 5d7be90 | 2012-03-20 19:15:40 +0100 | [diff] [blame] | 174 | /* |
| 175 | * Apply modifier on all events added by single event definition |
| 176 | * (there could be more events added for multiple tracepoint |
| 177 | * definitions via '*?'. |
| 178 | */ |
Jiri Olsa | f5b1135 | 2012-08-08 12:21:54 +0200 | [diff] [blame] | 179 | ABORT_ON(parse_events__modifier_event(list, $2, false)); |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 180 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 181 | } |
| 182 | | |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 183 | event_name |
| 184 | |
| 185 | event_name: |
| 186 | PE_EVENT_NAME event_def |
| 187 | { |
| 188 | ABORT_ON(parse_events_name($2, $1)); |
| 189 | free($1); |
| 190 | $$ = $2; |
| 191 | } |
| 192 | | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 193 | event_def |
| 194 | |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 195 | event_def: event_pmu | |
| 196 | event_legacy_symbol | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 197 | event_legacy_cache sep_dc | |
| 198 | event_legacy_mem | |
| 199 | event_legacy_tracepoint sep_dc | |
| 200 | event_legacy_numeric sep_dc | |
| 201 | event_legacy_raw sep_dc |
| 202 | |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 203 | event_pmu: |
| 204 | PE_NAME '/' event_config '/' |
| 205 | { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 206 | struct parse_events_evlist *data = _data; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 207 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 208 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 209 | ALLOC_LIST(list); |
Jiri Olsa | 36adec8 | 2015-04-22 21:10:19 +0200 | [diff] [blame] | 210 | ABORT_ON(parse_events_add_pmu(data, list, $1, $3)); |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 211 | parse_events__free_terms($3); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 212 | $$ = list; |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 213 | } |
Adrian Hunter | ad96227 | 2014-08-15 22:08:40 +0300 | [diff] [blame] | 214 | | |
| 215 | PE_NAME '/' '/' |
| 216 | { |
| 217 | struct parse_events_evlist *data = _data; |
| 218 | struct list_head *list; |
| 219 | |
| 220 | ALLOC_LIST(list); |
Jiri Olsa | 36adec8 | 2015-04-22 21:10:19 +0200 | [diff] [blame] | 221 | ABORT_ON(parse_events_add_pmu(data, list, $1, NULL)); |
Adrian Hunter | ad96227 | 2014-08-15 22:08:40 +0300 | [diff] [blame] | 222 | $$ = list; |
| 223 | } |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 224 | | |
| 225 | PE_KERNEL_PMU_EVENT sep_dc |
| 226 | { |
| 227 | struct parse_events_evlist *data = _data; |
| 228 | struct list_head *head; |
| 229 | struct parse_events_term *term; |
| 230 | struct list_head *list; |
| 231 | |
| 232 | ALLOC_LIST(head); |
| 233 | ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
Jiri Olsa | cecf3a2e | 2015-04-22 21:10:20 +0200 | [diff] [blame] | 234 | $1, 1, &@1, NULL)); |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 235 | list_add_tail(&term->list, head); |
| 236 | |
| 237 | ALLOC_LIST(list); |
Jiri Olsa | 36adec8 | 2015-04-22 21:10:19 +0200 | [diff] [blame] | 238 | ABORT_ON(parse_events_add_pmu(data, list, "cpu", head)); |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 239 | parse_events__free_terms(head); |
| 240 | $$ = list; |
| 241 | } |
| 242 | | |
| 243 | PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc |
| 244 | { |
| 245 | struct parse_events_evlist *data = _data; |
| 246 | struct list_head *head; |
| 247 | struct parse_events_term *term; |
| 248 | struct list_head *list; |
| 249 | char pmu_name[128]; |
| 250 | snprintf(&pmu_name, 128, "%s-%s", $1, $3); |
| 251 | |
| 252 | ALLOC_LIST(head); |
| 253 | ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
Jiri Olsa | cecf3a2e | 2015-04-22 21:10:20 +0200 | [diff] [blame] | 254 | &pmu_name, 1, &@1, NULL)); |
Kan Liang | ba32a45 | 2014-10-07 11:08:51 -0400 | [diff] [blame] | 255 | list_add_tail(&term->list, head); |
| 256 | |
| 257 | ALLOC_LIST(list); |
| 258 | ABORT_ON(parse_events_add_pmu(list, &data->idx, "cpu", head)); |
| 259 | parse_events__free_terms(head); |
| 260 | $$ = list; |
| 261 | } |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 262 | |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 263 | value_sym: |
| 264 | PE_VALUE_SYM_HW |
| 265 | | |
| 266 | PE_VALUE_SYM_SW |
| 267 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 268 | event_legacy_symbol: |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 269 | value_sym '/' event_config '/' |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 270 | { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 271 | struct parse_events_evlist *data = _data; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 272 | struct list_head *list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 273 | int type = $1 >> 16; |
| 274 | int config = $1 & 255; |
| 275 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 276 | ALLOC_LIST(list); |
Jiri Olsa | 87d650b | 2015-04-22 21:10:24 +0200 | [diff] [blame^] | 277 | ABORT_ON(parse_events_add_numeric(data, list, type, config, $3)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 278 | parse_events__free_terms($3); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 279 | $$ = list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 280 | } |
| 281 | | |
Jiri Olsa | cf3506d | 2012-07-04 00:00:43 +0200 | [diff] [blame] | 282 | value_sym sep_slash_dc |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 283 | { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 284 | struct parse_events_evlist *data = _data; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 285 | struct list_head *list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 286 | int type = $1 >> 16; |
| 287 | int config = $1 & 255; |
| 288 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 289 | ALLOC_LIST(list); |
Jiri Olsa | 87d650b | 2015-04-22 21:10:24 +0200 | [diff] [blame^] | 290 | ABORT_ON(parse_events_add_numeric(data, list, type, config, NULL)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 291 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | event_legacy_cache: |
| 295 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT |
| 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 | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 299 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 300 | ALLOC_LIST(list); |
| 301 | ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, $5)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 302 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 303 | } |
| 304 | | |
| 305 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT |
| 306 | { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 307 | struct parse_events_evlist *data = _data; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 308 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 309 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 310 | ALLOC_LIST(list); |
| 311 | ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, NULL)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 312 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 313 | } |
| 314 | | |
| 315 | PE_NAME_CACHE_TYPE |
| 316 | { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 317 | struct parse_events_evlist *data = _data; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 318 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 319 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 320 | ALLOC_LIST(list); |
| 321 | ABORT_ON(parse_events_add_cache(list, &data->idx, $1, NULL, NULL)); |
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 | |
| 325 | event_legacy_mem: |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 326 | PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc |
| 327 | { |
| 328 | struct parse_events_evlist *data = _data; |
| 329 | struct list_head *list; |
| 330 | |
| 331 | ALLOC_LIST(list); |
| 332 | ABORT_ON(parse_events_add_breakpoint(list, &data->idx, |
| 333 | (void *) $2, $6, $4)); |
| 334 | $$ = list; |
| 335 | } |
| 336 | | |
| 337 | PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc |
| 338 | { |
| 339 | struct parse_events_evlist *data = _data; |
| 340 | struct list_head *list; |
| 341 | |
| 342 | ALLOC_LIST(list); |
| 343 | ABORT_ON(parse_events_add_breakpoint(list, &data->idx, |
| 344 | (void *) $2, NULL, $4)); |
| 345 | $$ = list; |
| 346 | } |
| 347 | | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 348 | PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc |
| 349 | { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 350 | struct parse_events_evlist *data = _data; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 351 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 352 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 353 | ALLOC_LIST(list); |
| 354 | ABORT_ON(parse_events_add_breakpoint(list, &data->idx, |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 355 | (void *) $2, $4, 0)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 356 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 357 | } |
| 358 | | |
| 359 | PE_PREFIX_MEM PE_VALUE sep_dc |
| 360 | { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 361 | struct parse_events_evlist *data = _data; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 362 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 363 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 364 | ALLOC_LIST(list); |
| 365 | ABORT_ON(parse_events_add_breakpoint(list, &data->idx, |
Jacob Shin | 3741eb9 | 2014-05-29 17:26:51 +0200 | [diff] [blame] | 366 | (void *) $2, NULL, 0)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 367 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | event_legacy_tracepoint: |
Alexander Yarygin | 2b9032e | 2014-04-25 17:34:05 +0200 | [diff] [blame] | 371 | PE_NAME '-' PE_NAME ':' PE_NAME |
| 372 | { |
| 373 | struct parse_events_evlist *data = _data; |
| 374 | struct list_head *list; |
| 375 | char sys_name[128]; |
| 376 | snprintf(&sys_name, 128, "%s-%s", $1, $3); |
| 377 | |
| 378 | ALLOC_LIST(list); |
| 379 | ABORT_ON(parse_events_add_tracepoint(list, &data->idx, &sys_name, $5)); |
| 380 | $$ = list; |
| 381 | } |
| 382 | | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 383 | PE_NAME ':' PE_NAME |
| 384 | { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 385 | struct parse_events_evlist *data = _data; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 386 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 387 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 388 | ALLOC_LIST(list); |
Jiri Olsa | 492d977 | 2015-04-22 21:10:23 +0200 | [diff] [blame] | 389 | if (parse_events_add_tracepoint(list, &data->idx, $1, $3)) { |
| 390 | struct parse_events_error *error = data->error; |
| 391 | |
| 392 | error->idx = @1.first_column; |
| 393 | error->str = strdup("unknown tracepoint"); |
| 394 | return -1; |
| 395 | } |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 396 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | event_legacy_numeric: |
| 400 | PE_VALUE ':' PE_VALUE |
| 401 | { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 402 | struct parse_events_evlist *data = _data; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 403 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 404 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 405 | ALLOC_LIST(list); |
Jiri Olsa | 87d650b | 2015-04-22 21:10:24 +0200 | [diff] [blame^] | 406 | ABORT_ON(parse_events_add_numeric(data, list, (u32)$1, $3, NULL)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 407 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | event_legacy_raw: |
| 411 | PE_RAW |
| 412 | { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 413 | struct parse_events_evlist *data = _data; |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 414 | struct list_head *list; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 415 | |
David Ahern | c5cd8ac | 2013-07-02 13:27:25 -0600 | [diff] [blame] | 416 | ALLOC_LIST(list); |
Jiri Olsa | 87d650b | 2015-04-22 21:10:24 +0200 | [diff] [blame^] | 417 | ABORT_ON(parse_events_add_numeric(data, list, PERF_TYPE_RAW, $1, NULL)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 418 | $$ = list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 419 | } |
| 420 | |
Jiri Olsa | 89efb02 | 2012-08-08 12:14:14 +0200 | [diff] [blame] | 421 | start_terms: event_config |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 422 | { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 423 | struct parse_events_terms *data = _data; |
Jiri Olsa | 90e2b22 | 2012-06-15 14:31:40 +0800 | [diff] [blame] | 424 | data->terms = $1; |
| 425 | } |
| 426 | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 427 | event_config: |
| 428 | event_config ',' event_term |
| 429 | { |
| 430 | struct list_head *head = $1; |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 431 | struct parse_events_term *term = $3; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 432 | |
| 433 | ABORT_ON(!head); |
| 434 | list_add_tail(&term->list, head); |
| 435 | $$ = $1; |
| 436 | } |
| 437 | | |
| 438 | event_term |
| 439 | { |
| 440 | struct list_head *head = malloc(sizeof(*head)); |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 441 | struct parse_events_term *term = $1; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 442 | |
| 443 | ABORT_ON(!head); |
| 444 | INIT_LIST_HEAD(head); |
| 445 | list_add_tail(&term->list, head); |
| 446 | $$ = head; |
| 447 | } |
| 448 | |
| 449 | event_term: |
| 450 | PE_NAME '=' PE_NAME |
| 451 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 452 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 453 | |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 454 | ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, |
Jiri Olsa | cecf3a2e | 2015-04-22 21:10:20 +0200 | [diff] [blame] | 455 | $1, $3, &@1, &@3)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 456 | $$ = term; |
| 457 | } |
| 458 | | |
| 459 | PE_NAME '=' PE_VALUE |
| 460 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 461 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 462 | |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 463 | ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
Jiri Olsa | cecf3a2e | 2015-04-22 21:10:20 +0200 | [diff] [blame] | 464 | $1, $3, &@1, &@3)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 465 | $$ = term; |
| 466 | } |
| 467 | | |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 468 | PE_NAME '=' PE_VALUE_SYM_HW |
| 469 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 470 | struct parse_events_term *term; |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 471 | int config = $3 & 255; |
| 472 | |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 473 | ABORT_ON(parse_events_term__sym_hw(&term, $1, config)); |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 474 | $$ = term; |
| 475 | } |
| 476 | | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 477 | PE_NAME |
| 478 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 479 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 480 | |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 481 | ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
Jiri Olsa | cecf3a2e | 2015-04-22 21:10:20 +0200 | [diff] [blame] | 482 | $1, 1, &@1, NULL)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 483 | $$ = term; |
| 484 | } |
| 485 | | |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 486 | PE_VALUE_SYM_HW |
| 487 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 488 | struct parse_events_term *term; |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 489 | int config = $1 & 255; |
| 490 | |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 491 | ABORT_ON(parse_events_term__sym_hw(&term, NULL, config)); |
Jiri Olsa | 1d33d6d | 2012-10-10 14:53:17 +0200 | [diff] [blame] | 492 | $$ = term; |
| 493 | } |
| 494 | | |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 495 | PE_TERM '=' PE_NAME |
| 496 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 497 | struct parse_events_term *term; |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 498 | |
Jiri Olsa | cecf3a2e | 2015-04-22 21:10:20 +0200 | [diff] [blame] | 499 | 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] | 500 | $$ = term; |
| 501 | } |
| 502 | | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 503 | PE_TERM '=' PE_VALUE |
| 504 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 505 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 506 | |
Jiri Olsa | cecf3a2e | 2015-04-22 21:10:20 +0200 | [diff] [blame] | 507 | 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] | 508 | $$ = term; |
| 509 | } |
| 510 | | |
| 511 | PE_TERM |
| 512 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 513 | struct parse_events_term *term; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 514 | |
Jiri Olsa | cecf3a2e | 2015-04-22 21:10:20 +0200 | [diff] [blame] | 515 | 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] | 516 | $$ = term; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | sep_dc: ':' | |
| 520 | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 521 | sep_slash_dc: '/' | ':' | |
| 522 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 523 | %% |
| 524 | |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 525 | void parse_events_error(YYLTYPE *loc, void *data, |
| 526 | void *scanner __maybe_unused, |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 527 | char const *msg __maybe_unused) |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 528 | { |
Jiri Olsa | 6297d42 | 2015-04-22 21:10:17 +0200 | [diff] [blame] | 529 | parse_events_evlist_error(data, loc->last_column, "parser error"); |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 530 | } |