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