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