]>
Commit | Line | Data |
---|---|---|
ac20de6f | 1 | %pure-parser |
89812fc8 | 2 | %name-prefix "parse_events_" |
46010ab2 | 3 | %parse-param {void *_data} |
ac20de6f ZY |
4 | %parse-param {void *scanner} |
5 | %lex-param {void* scanner} | |
89812fc8 JO |
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" | |
ac20de6f | 16 | #include "parse-events-bison.h" |
89812fc8 | 17 | |
ac20de6f | 18 | extern int parse_events_lex (YYSTYPE* lvalp, void* scanner); |
89812fc8 JO |
19 | |
20 | #define ABORT_ON(val) \ | |
21 | do { \ | |
22 | if (val) \ | |
23 | YYABORT; \ | |
24 | } while (0) | |
25 | ||
26 | %} | |
27 | ||
8f707d84 | 28 | %token PE_VALUE PE_VALUE_SYM PE_RAW PE_TERM |
89812fc8 JO |
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 | |
8f707d84 | 37 | %type <num> PE_TERM |
89812fc8 JO |
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 | |
8f707d84 JO |
43 | %type <head> event_config |
44 | %type <term> event_term | |
b847cbdc JO |
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 | |
89812fc8 JO |
53 | |
54 | %union | |
55 | { | |
56 | char *str; | |
57 | unsigned long num; | |
8f707d84 JO |
58 | struct list_head *head; |
59 | struct parse_events__term *term; | |
89812fc8 JO |
60 | } |
61 | %% | |
62 | ||
63 | events: | |
64 | events ',' event | event | |
65 | ||
66 | event: | |
67 | event_def PE_MODIFIER_EVENT | |
68 | { | |
46010ab2 JO |
69 | struct parse_events_data__events *data = _data; |
70 | ||
5d7be90e JO |
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 | */ | |
b847cbdc | 76 | ABORT_ON(parse_events_modifier($1, $2)); |
46010ab2 | 77 | parse_events_update_lists($1, &data->list); |
89812fc8 JO |
78 | } |
79 | | | |
80 | event_def | |
5d7be90e | 81 | { |
46010ab2 JO |
82 | struct parse_events_data__events *data = _data; |
83 | ||
84 | parse_events_update_lists($1, &data->list); | |
5d7be90e | 85 | } |
89812fc8 | 86 | |
5f537a26 JO |
87 | event_def: event_pmu | |
88 | event_legacy_symbol | | |
89812fc8 JO |
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 | ||
5f537a26 JO |
95 | event_pmu: |
96 | PE_NAME '/' event_config '/' | |
97 | { | |
46010ab2 | 98 | struct parse_events_data__events *data = _data; |
b847cbdc JO |
99 | struct list_head *list = NULL; |
100 | ||
46010ab2 | 101 | ABORT_ON(parse_events_add_pmu(&list, &data->idx, $1, $3)); |
5f537a26 | 102 | parse_events__free_terms($3); |
b847cbdc | 103 | $$ = list; |
5f537a26 JO |
104 | } |
105 | ||
89812fc8 | 106 | event_legacy_symbol: |
8f707d84 | 107 | PE_VALUE_SYM '/' event_config '/' |
89812fc8 | 108 | { |
46010ab2 | 109 | struct parse_events_data__events *data = _data; |
b847cbdc | 110 | struct list_head *list = NULL; |
89812fc8 JO |
111 | int type = $1 >> 16; |
112 | int config = $1 & 255; | |
113 | ||
46010ab2 JO |
114 | ABORT_ON(parse_events_add_numeric(&list, &data->idx, |
115 | type, config, $3)); | |
8f707d84 | 116 | parse_events__free_terms($3); |
b847cbdc | 117 | $$ = list; |
8f707d84 JO |
118 | } |
119 | | | |
120 | PE_VALUE_SYM sep_slash_dc | |
121 | { | |
46010ab2 | 122 | struct parse_events_data__events *data = _data; |
b847cbdc | 123 | struct list_head *list = NULL; |
8f707d84 JO |
124 | int type = $1 >> 16; |
125 | int config = $1 & 255; | |
126 | ||
46010ab2 JO |
127 | ABORT_ON(parse_events_add_numeric(&list, &data->idx, |
128 | type, config, NULL)); | |
b847cbdc | 129 | $$ = list; |
89812fc8 JO |
130 | } |
131 | ||
132 | event_legacy_cache: | |
133 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT | |
134 | { | |
46010ab2 | 135 | struct parse_events_data__events *data = _data; |
b847cbdc JO |
136 | struct list_head *list = NULL; |
137 | ||
46010ab2 | 138 | ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, $5)); |
b847cbdc | 139 | $$ = list; |
89812fc8 JO |
140 | } |
141 | | | |
142 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT | |
143 | { | |
46010ab2 | 144 | struct parse_events_data__events *data = _data; |
b847cbdc JO |
145 | struct list_head *list = NULL; |
146 | ||
46010ab2 | 147 | ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, NULL)); |
b847cbdc | 148 | $$ = list; |
89812fc8 JO |
149 | } |
150 | | | |
151 | PE_NAME_CACHE_TYPE | |
152 | { | |
46010ab2 | 153 | struct parse_events_data__events *data = _data; |
b847cbdc JO |
154 | struct list_head *list = NULL; |
155 | ||
46010ab2 | 156 | ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, NULL, NULL)); |
b847cbdc | 157 | $$ = list; |
89812fc8 JO |
158 | } |
159 | ||
160 | event_legacy_mem: | |
161 | PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc | |
162 | { | |
46010ab2 | 163 | struct parse_events_data__events *data = _data; |
b847cbdc JO |
164 | struct list_head *list = NULL; |
165 | ||
46010ab2 JO |
166 | ABORT_ON(parse_events_add_breakpoint(&list, &data->idx, |
167 | (void *) $2, $4)); | |
b847cbdc | 168 | $$ = list; |
89812fc8 JO |
169 | } |
170 | | | |
171 | PE_PREFIX_MEM PE_VALUE sep_dc | |
172 | { | |
46010ab2 | 173 | struct parse_events_data__events *data = _data; |
b847cbdc JO |
174 | struct list_head *list = NULL; |
175 | ||
46010ab2 JO |
176 | ABORT_ON(parse_events_add_breakpoint(&list, &data->idx, |
177 | (void *) $2, NULL)); | |
b847cbdc | 178 | $$ = list; |
89812fc8 JO |
179 | } |
180 | ||
181 | event_legacy_tracepoint: | |
182 | PE_NAME ':' PE_NAME | |
183 | { | |
46010ab2 | 184 | struct parse_events_data__events *data = _data; |
b847cbdc JO |
185 | struct list_head *list = NULL; |
186 | ||
46010ab2 | 187 | ABORT_ON(parse_events_add_tracepoint(&list, &data->idx, $1, $3)); |
b847cbdc | 188 | $$ = list; |
89812fc8 JO |
189 | } |
190 | ||
191 | event_legacy_numeric: | |
192 | PE_VALUE ':' PE_VALUE | |
193 | { | |
46010ab2 | 194 | struct parse_events_data__events *data = _data; |
b847cbdc JO |
195 | struct list_head *list = NULL; |
196 | ||
46010ab2 | 197 | ABORT_ON(parse_events_add_numeric(&list, &data->idx, $1, $3, NULL)); |
b847cbdc | 198 | $$ = list; |
89812fc8 JO |
199 | } |
200 | ||
201 | event_legacy_raw: | |
202 | PE_RAW | |
203 | { | |
46010ab2 | 204 | struct parse_events_data__events *data = _data; |
b847cbdc JO |
205 | struct list_head *list = NULL; |
206 | ||
46010ab2 JO |
207 | ABORT_ON(parse_events_add_numeric(&list, &data->idx, |
208 | PERF_TYPE_RAW, $1, NULL)); | |
b847cbdc | 209 | $$ = list; |
8f707d84 JO |
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 | ||
16fa7e82 JO |
239 | ABORT_ON(parse_events__term_str(&term, PARSE_EVENTS__TERM_TYPE_USER, |
240 | $1, $3)); | |
8f707d84 JO |
241 | $$ = term; |
242 | } | |
243 | | | |
244 | PE_NAME '=' PE_VALUE | |
245 | { | |
246 | struct parse_events__term *term; | |
247 | ||
16fa7e82 JO |
248 | ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
249 | $1, $3)); | |
8f707d84 JO |
250 | $$ = term; |
251 | } | |
252 | | | |
253 | PE_NAME | |
254 | { | |
255 | struct parse_events__term *term; | |
256 | ||
16fa7e82 JO |
257 | ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
258 | $1, 1)); | |
8f707d84 JO |
259 | $$ = term; |
260 | } | |
261 | | | |
6b5fc39b JO |
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 | | | |
8f707d84 JO |
270 | PE_TERM '=' PE_VALUE |
271 | { | |
272 | struct parse_events__term *term; | |
273 | ||
16fa7e82 | 274 | ABORT_ON(parse_events__term_num(&term, $1, NULL, $3)); |
8f707d84 JO |
275 | $$ = term; |
276 | } | |
277 | | | |
278 | PE_TERM | |
279 | { | |
280 | struct parse_events__term *term; | |
281 | ||
16fa7e82 | 282 | ABORT_ON(parse_events__term_num(&term, $1, NULL, 1)); |
8f707d84 | 283 | $$ = term; |
89812fc8 JO |
284 | } |
285 | ||
286 | sep_dc: ':' | | |
287 | ||
8f707d84 JO |
288 | sep_slash_dc: '/' | ':' | |
289 | ||
89812fc8 JO |
290 | %% |
291 | ||
ac20de6f | 292 | void parse_events_error(void *data __used, void *scanner __used, |
89812fc8 JO |
293 | char const *msg __used) |
294 | { | |
295 | } |