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