Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 1 | |
| 2 | %name-prefix "parse_events_" |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 3 | %parse-param {void *_data} |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 4 | |
| 5 | %{ |
| 6 | |
| 7 | #define YYDEBUG 1 |
| 8 | |
| 9 | #include <linux/compiler.h> |
| 10 | #include <linux/list.h> |
| 11 | #include "types.h" |
| 12 | #include "util.h" |
| 13 | #include "parse-events.h" |
| 14 | |
| 15 | extern int parse_events_lex (void); |
| 16 | |
| 17 | #define ABORT_ON(val) \ |
| 18 | do { \ |
| 19 | if (val) \ |
| 20 | YYABORT; \ |
| 21 | } while (0) |
| 22 | |
| 23 | %} |
| 24 | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 25 | %token PE_VALUE PE_VALUE_SYM PE_RAW PE_TERM |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 26 | %token PE_NAME |
| 27 | %token PE_MODIFIER_EVENT PE_MODIFIER_BP |
| 28 | %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT |
| 29 | %token PE_PREFIX_MEM PE_PREFIX_RAW |
| 30 | %token PE_ERROR |
| 31 | %type <num> PE_VALUE |
| 32 | %type <num> PE_VALUE_SYM |
| 33 | %type <num> PE_RAW |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 34 | %type <num> PE_TERM |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 35 | %type <str> PE_NAME |
| 36 | %type <str> PE_NAME_CACHE_TYPE |
| 37 | %type <str> PE_NAME_CACHE_OP_RESULT |
| 38 | %type <str> PE_MODIFIER_EVENT |
| 39 | %type <str> PE_MODIFIER_BP |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 40 | %type <head> event_config |
| 41 | %type <term> event_term |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 42 | %type <head> event_pmu |
| 43 | %type <head> event_legacy_symbol |
| 44 | %type <head> event_legacy_cache |
| 45 | %type <head> event_legacy_mem |
| 46 | %type <head> event_legacy_tracepoint |
| 47 | %type <head> event_legacy_numeric |
| 48 | %type <head> event_legacy_raw |
| 49 | %type <head> event_def |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 50 | |
| 51 | %union |
| 52 | { |
| 53 | char *str; |
| 54 | unsigned long num; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 55 | struct list_head *head; |
| 56 | struct parse_events__term *term; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 57 | } |
| 58 | %% |
| 59 | |
| 60 | events: |
| 61 | events ',' event | event |
| 62 | |
| 63 | event: |
| 64 | event_def PE_MODIFIER_EVENT |
| 65 | { |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 66 | struct parse_events_data__events *data = _data; |
| 67 | |
Jiri Olsa | 5d7be90 | 2012-03-20 19:15:40 +0100 | [diff] [blame] | 68 | /* |
| 69 | * Apply modifier on all events added by single event definition |
| 70 | * (there could be more events added for multiple tracepoint |
| 71 | * definitions via '*?'. |
| 72 | */ |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 73 | ABORT_ON(parse_events_modifier($1, $2)); |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 74 | parse_events_update_lists($1, &data->list); |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 75 | } |
| 76 | | |
| 77 | event_def |
Jiri Olsa | 5d7be90 | 2012-03-20 19:15:40 +0100 | [diff] [blame] | 78 | { |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 79 | struct parse_events_data__events *data = _data; |
| 80 | |
| 81 | parse_events_update_lists($1, &data->list); |
Jiri Olsa | 5d7be90 | 2012-03-20 19:15:40 +0100 | [diff] [blame] | 82 | } |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 83 | |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 84 | event_def: event_pmu | |
| 85 | event_legacy_symbol | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 86 | event_legacy_cache sep_dc | |
| 87 | event_legacy_mem | |
| 88 | event_legacy_tracepoint sep_dc | |
| 89 | event_legacy_numeric sep_dc | |
| 90 | event_legacy_raw sep_dc |
| 91 | |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 92 | event_pmu: |
| 93 | PE_NAME '/' event_config '/' |
| 94 | { |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 95 | struct parse_events_data__events *data = _data; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 96 | struct list_head *list = NULL; |
| 97 | |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 98 | ABORT_ON(parse_events_add_pmu(&list, &data->idx, $1, $3)); |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 99 | parse_events__free_terms($3); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 100 | $$ = list; |
Jiri Olsa | 5f537a2 | 2012-03-15 20:09:18 +0100 | [diff] [blame] | 101 | } |
| 102 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 103 | event_legacy_symbol: |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 104 | PE_VALUE_SYM '/' event_config '/' |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 105 | { |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 106 | struct parse_events_data__events *data = _data; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 107 | struct list_head *list = NULL; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 108 | int type = $1 >> 16; |
| 109 | int config = $1 & 255; |
| 110 | |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 111 | ABORT_ON(parse_events_add_numeric(&list, &data->idx, |
| 112 | type, config, $3)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 113 | parse_events__free_terms($3); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 114 | $$ = list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 115 | } |
| 116 | | |
| 117 | PE_VALUE_SYM sep_slash_dc |
| 118 | { |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 119 | struct parse_events_data__events *data = _data; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 120 | struct list_head *list = NULL; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 121 | int type = $1 >> 16; |
| 122 | int config = $1 & 255; |
| 123 | |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 124 | ABORT_ON(parse_events_add_numeric(&list, &data->idx, |
| 125 | type, config, NULL)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 126 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | event_legacy_cache: |
| 130 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT |
| 131 | { |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 132 | struct parse_events_data__events *data = _data; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 133 | struct list_head *list = NULL; |
| 134 | |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 135 | ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, $5)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 136 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 137 | } |
| 138 | | |
| 139 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT |
| 140 | { |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 141 | struct parse_events_data__events *data = _data; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 142 | struct list_head *list = NULL; |
| 143 | |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 144 | ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, NULL)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 145 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 146 | } |
| 147 | | |
| 148 | PE_NAME_CACHE_TYPE |
| 149 | { |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 150 | struct parse_events_data__events *data = _data; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 151 | struct list_head *list = NULL; |
| 152 | |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 153 | ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, NULL, NULL)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 154 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | event_legacy_mem: |
| 158 | PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc |
| 159 | { |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 160 | struct parse_events_data__events *data = _data; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 161 | struct list_head *list = NULL; |
| 162 | |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 163 | ABORT_ON(parse_events_add_breakpoint(&list, &data->idx, |
| 164 | (void *) $2, $4)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 165 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 166 | } |
| 167 | | |
| 168 | PE_PREFIX_MEM PE_VALUE sep_dc |
| 169 | { |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 170 | struct parse_events_data__events *data = _data; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 171 | struct list_head *list = NULL; |
| 172 | |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 173 | ABORT_ON(parse_events_add_breakpoint(&list, &data->idx, |
| 174 | (void *) $2, NULL)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 175 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | event_legacy_tracepoint: |
| 179 | PE_NAME ':' PE_NAME |
| 180 | { |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 181 | struct parse_events_data__events *data = _data; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 182 | struct list_head *list = NULL; |
| 183 | |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 184 | ABORT_ON(parse_events_add_tracepoint(&list, &data->idx, $1, $3)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 185 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | event_legacy_numeric: |
| 189 | PE_VALUE ':' PE_VALUE |
| 190 | { |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 191 | struct parse_events_data__events *data = _data; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 192 | struct list_head *list = NULL; |
| 193 | |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 194 | ABORT_ON(parse_events_add_numeric(&list, &data->idx, $1, $3, NULL)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 195 | $$ = list; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | event_legacy_raw: |
| 199 | PE_RAW |
| 200 | { |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 201 | struct parse_events_data__events *data = _data; |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 202 | struct list_head *list = NULL; |
| 203 | |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 204 | ABORT_ON(parse_events_add_numeric(&list, &data->idx, |
| 205 | PERF_TYPE_RAW, $1, NULL)); |
Jiri Olsa | b847cbd | 2012-05-21 09:12:51 +0200 | [diff] [blame] | 206 | $$ = list; |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | event_config: |
| 210 | event_config ',' event_term |
| 211 | { |
| 212 | struct list_head *head = $1; |
| 213 | struct parse_events__term *term = $3; |
| 214 | |
| 215 | ABORT_ON(!head); |
| 216 | list_add_tail(&term->list, head); |
| 217 | $$ = $1; |
| 218 | } |
| 219 | | |
| 220 | event_term |
| 221 | { |
| 222 | struct list_head *head = malloc(sizeof(*head)); |
| 223 | struct parse_events__term *term = $1; |
| 224 | |
| 225 | ABORT_ON(!head); |
| 226 | INIT_LIST_HEAD(head); |
| 227 | list_add_tail(&term->list, head); |
| 228 | $$ = head; |
| 229 | } |
| 230 | |
| 231 | event_term: |
| 232 | PE_NAME '=' PE_NAME |
| 233 | { |
| 234 | struct parse_events__term *term; |
| 235 | |
Jiri Olsa | 16fa7e8 | 2012-04-25 18:24:57 +0200 | [diff] [blame] | 236 | ABORT_ON(parse_events__term_str(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 237 | $1, $3)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 238 | $$ = term; |
| 239 | } |
| 240 | | |
| 241 | PE_NAME '=' PE_VALUE |
| 242 | { |
| 243 | struct parse_events__term *term; |
| 244 | |
Jiri Olsa | 16fa7e8 | 2012-04-25 18:24:57 +0200 | [diff] [blame] | 245 | ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 246 | $1, $3)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 247 | $$ = term; |
| 248 | } |
| 249 | | |
| 250 | PE_NAME |
| 251 | { |
| 252 | struct parse_events__term *term; |
| 253 | |
Jiri Olsa | 16fa7e8 | 2012-04-25 18:24:57 +0200 | [diff] [blame] | 254 | ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
| 255 | $1, 1)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 256 | $$ = term; |
| 257 | } |
| 258 | | |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 259 | PE_TERM '=' PE_NAME |
| 260 | { |
| 261 | struct parse_events__term *term; |
| 262 | |
| 263 | ABORT_ON(parse_events__term_str(&term, $1, NULL, $3)); |
| 264 | $$ = term; |
| 265 | } |
| 266 | | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 267 | PE_TERM '=' PE_VALUE |
| 268 | { |
| 269 | struct parse_events__term *term; |
| 270 | |
Jiri Olsa | 16fa7e8 | 2012-04-25 18:24:57 +0200 | [diff] [blame] | 271 | ABORT_ON(parse_events__term_num(&term, $1, NULL, $3)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 272 | $$ = term; |
| 273 | } |
| 274 | | |
| 275 | PE_TERM |
| 276 | { |
| 277 | struct parse_events__term *term; |
| 278 | |
Jiri Olsa | 16fa7e8 | 2012-04-25 18:24:57 +0200 | [diff] [blame] | 279 | ABORT_ON(parse_events__term_num(&term, $1, NULL, 1)); |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 280 | $$ = term; |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | sep_dc: ':' | |
| 284 | |
Jiri Olsa | 8f707d8 | 2012-03-15 20:09:16 +0100 | [diff] [blame] | 285 | sep_slash_dc: '/' | ':' | |
| 286 | |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 287 | %% |
| 288 | |
Jiri Olsa | 46010ab | 2012-06-15 14:31:38 +0800 | [diff] [blame^] | 289 | void parse_events_error(void *data __used, |
Jiri Olsa | 89812fc | 2012-03-15 20:09:15 +0100 | [diff] [blame] | 290 | char const *msg __used) |
| 291 | { |
| 292 | } |