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