blob: 15e6e97e5b346d20769b8afb8b48f84c82a071ef [file] [log] [blame]
Zheng Yanac20de62012-06-15 14:31:39 +08001%pure-parser
Jiri Olsa89812fc2012-03-15 20:09:15 +01002%name-prefix "parse_events_"
Jiri Olsa46010ab2012-06-15 14:31:38 +08003%parse-param {void *_data}
Zheng Yanac20de62012-06-15 14:31:39 +08004%parse-param {void *scanner}
5%lex-param {void* scanner}
Jiri Olsa89812fc2012-03-15 20:09:15 +01006
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 Yanac20de62012-06-15 14:31:39 +080016#include "parse-events-bison.h"
Jiri Olsa89812fc2012-03-15 20:09:15 +010017
Zheng Yanac20de62012-06-15 14:31:39 +080018extern int parse_events_lex (YYSTYPE* lvalp, void* scanner);
Jiri Olsa89812fc2012-03-15 20:09:15 +010019
20#define ABORT_ON(val) \
21do { \
22 if (val) \
23 YYABORT; \
24} while (0)
25
26%}
27
Jiri Olsa90e2b222012-06-15 14:31:40 +080028%token PE_START_EVENTS PE_START_TERMS
Jiri Olsacf3506d2012-07-04 00:00:43 +020029%token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM
Jiri Olsa89812fc2012-03-15 20:09:15 +010030%token PE_NAME
31%token PE_MODIFIER_EVENT PE_MODIFIER_BP
32%token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
Jiri Olsa89efb022012-08-08 12:14:14 +020033%token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP
Jiri Olsa89812fc2012-03-15 20:09:15 +010034%token PE_ERROR
35%type <num> PE_VALUE
Jiri Olsacf3506d2012-07-04 00:00:43 +020036%type <num> PE_VALUE_SYM_HW
37%type <num> PE_VALUE_SYM_SW
Jiri Olsa89812fc2012-03-15 20:09:15 +010038%type <num> PE_RAW
Jiri Olsa8f707d82012-03-15 20:09:16 +010039%type <num> PE_TERM
Jiri Olsa89812fc2012-03-15 20:09:15 +010040%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 Olsacf3506d2012-07-04 00:00:43 +020045%type <num> value_sym
Jiri Olsa8f707d82012-03-15 20:09:16 +010046%type <head> event_config
47%type <term> event_term
Jiri Olsab847cbd2012-05-21 09:12:51 +020048%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 Olsa89efb022012-08-08 12:14:14 +020056%type <head> event
57%type <head> events
58%type <head> group_def
59%type <head> group
60%type <head> groups
Jiri Olsa89812fc2012-03-15 20:09:15 +010061
62%union
63{
64 char *str;
Robert Richterb527bab2012-08-07 19:43:13 +020065 u64 num;
Jiri Olsa8f707d82012-03-15 20:09:16 +010066 struct list_head *head;
67 struct parse_events__term *term;
Jiri Olsa89812fc2012-03-15 20:09:15 +010068}
69%%
70
Jiri Olsa90e2b222012-06-15 14:31:40 +080071start:
Jiri Olsa89efb022012-08-08 12:14:14 +020072PE_START_EVENTS start_events
Jiri Olsa90e2b222012-06-15 14:31:40 +080073|
Jiri Olsa89efb022012-08-08 12:14:14 +020074PE_START_TERMS start_terms
75
76start_events: groups
77{
78 struct parse_events_data__events *data = _data;
79
80 parse_events_update_lists($1, &data->list);
81}
82
83groups:
84groups ',' group
85{
86 struct list_head *list = $1;
87 struct list_head *group = $3;
88
89 parse_events_update_lists(group, list);
90 $$ = list;
91}
92|
93groups ',' event
94{
95 struct list_head *list = $1;
96 struct list_head *event = $3;
97
98 parse_events_update_lists(event, list);
99 $$ = list;
100}
101|
102group
103|
104event
105
106group:
107group_def ':' PE_MODIFIER_EVENT
108{
109 struct list_head *list = $1;
110
111 ABORT_ON(parse_events__modifier_group(list, $3));
112 $$ = list;
113}
114|
115group_def
116
117group_def:
118PE_NAME '{' events '}'
119{
120 struct list_head *list = $3;
121
122 parse_events__group($1, list);
123 $$ = list;
124}
125|
126'{' events '}'
127{
128 struct list_head *list = $2;
129
130 parse_events__group(NULL, list);
131 $$ = list;
132}
Jiri Olsa90e2b222012-06-15 14:31:40 +0800133
Jiri Olsa89812fc2012-03-15 20:09:15 +0100134events:
Jiri Olsa89efb022012-08-08 12:14:14 +0200135events ',' event
136{
137 struct list_head *event = $3;
138 struct list_head *list = $1;
139
140 parse_events_update_lists(event, list);
141 $$ = list;
142}
143|
144event
Jiri Olsa89812fc2012-03-15 20:09:15 +0100145
146event:
147event_def PE_MODIFIER_EVENT
148{
Jiri Olsa89efb022012-08-08 12:14:14 +0200149 struct list_head *list = $1;
Jiri Olsa46010ab2012-06-15 14:31:38 +0800150
Jiri Olsa5d7be902012-03-20 19:15:40 +0100151 /*
152 * Apply modifier on all events added by single event definition
153 * (there could be more events added for multiple tracepoint
154 * definitions via '*?'.
155 */
Jiri Olsa89efb022012-08-08 12:14:14 +0200156 ABORT_ON(parse_events__modifier_event(list, $2));
157 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100158}
159|
160event_def
161
Jiri Olsa5f537a22012-03-15 20:09:18 +0100162event_def: event_pmu |
163 event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +0100164 event_legacy_cache sep_dc |
165 event_legacy_mem |
166 event_legacy_tracepoint sep_dc |
167 event_legacy_numeric sep_dc |
168 event_legacy_raw sep_dc
169
Jiri Olsa5f537a22012-03-15 20:09:18 +0100170event_pmu:
171PE_NAME '/' event_config '/'
172{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800173 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200174 struct list_head *list = NULL;
175
Jiri Olsa46010ab2012-06-15 14:31:38 +0800176 ABORT_ON(parse_events_add_pmu(&list, &data->idx, $1, $3));
Jiri Olsa5f537a22012-03-15 20:09:18 +0100177 parse_events__free_terms($3);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200178 $$ = list;
Jiri Olsa5f537a22012-03-15 20:09:18 +0100179}
180
Jiri Olsacf3506d2012-07-04 00:00:43 +0200181value_sym:
182PE_VALUE_SYM_HW
183|
184PE_VALUE_SYM_SW
185
Jiri Olsa89812fc2012-03-15 20:09:15 +0100186event_legacy_symbol:
Jiri Olsacf3506d2012-07-04 00:00:43 +0200187value_sym '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +0100188{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800189 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200190 struct list_head *list = NULL;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100191 int type = $1 >> 16;
192 int config = $1 & 255;
193
Jiri Olsa46010ab2012-06-15 14:31:38 +0800194 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
195 type, config, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100196 parse_events__free_terms($3);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200197 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100198}
199|
Jiri Olsacf3506d2012-07-04 00:00:43 +0200200value_sym sep_slash_dc
Jiri Olsa8f707d82012-03-15 20:09:16 +0100201{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800202 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200203 struct list_head *list = NULL;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100204 int type = $1 >> 16;
205 int config = $1 & 255;
206
Jiri Olsa46010ab2012-06-15 14:31:38 +0800207 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
208 type, config, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200209 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100210}
211
212event_legacy_cache:
213PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
214{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800215 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200216 struct list_head *list = NULL;
217
Jiri Olsa46010ab2012-06-15 14:31:38 +0800218 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, $5));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200219 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100220}
221|
222PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
223{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800224 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200225 struct list_head *list = NULL;
226
Jiri Olsa46010ab2012-06-15 14:31:38 +0800227 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200228 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100229}
230|
231PE_NAME_CACHE_TYPE
232{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800233 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200234 struct list_head *list = NULL;
235
Jiri Olsa46010ab2012-06-15 14:31:38 +0800236 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, NULL, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200237 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100238}
239
240event_legacy_mem:
241PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
242{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800243 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200244 struct list_head *list = NULL;
245
Jiri Olsa46010ab2012-06-15 14:31:38 +0800246 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
247 (void *) $2, $4));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200248 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100249}
250|
251PE_PREFIX_MEM PE_VALUE sep_dc
252{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800253 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200254 struct list_head *list = NULL;
255
Jiri Olsa46010ab2012-06-15 14:31:38 +0800256 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
257 (void *) $2, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200258 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100259}
260
261event_legacy_tracepoint:
262PE_NAME ':' PE_NAME
263{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800264 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200265 struct list_head *list = NULL;
266
Jiri Olsa46010ab2012-06-15 14:31:38 +0800267 ABORT_ON(parse_events_add_tracepoint(&list, &data->idx, $1, $3));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200268 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100269}
270
271event_legacy_numeric:
272PE_VALUE ':' PE_VALUE
273{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800274 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200275 struct list_head *list = NULL;
276
Robert Richterb527bab2012-08-07 19:43:13 +0200277 ABORT_ON(parse_events_add_numeric(&list, &data->idx, (u32)$1, $3, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200278 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100279}
280
281event_legacy_raw:
282PE_RAW
283{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800284 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200285 struct list_head *list = NULL;
286
Jiri Olsa46010ab2012-06-15 14:31:38 +0800287 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
288 PERF_TYPE_RAW, $1, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200289 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100290}
291
Jiri Olsa89efb022012-08-08 12:14:14 +0200292start_terms: event_config
Jiri Olsa90e2b222012-06-15 14:31:40 +0800293{
294 struct parse_events_data__terms *data = _data;
295 data->terms = $1;
296}
297
Jiri Olsa8f707d82012-03-15 20:09:16 +0100298event_config:
299event_config ',' event_term
300{
301 struct list_head *head = $1;
302 struct parse_events__term *term = $3;
303
304 ABORT_ON(!head);
305 list_add_tail(&term->list, head);
306 $$ = $1;
307}
308|
309event_term
310{
311 struct list_head *head = malloc(sizeof(*head));
312 struct parse_events__term *term = $1;
313
314 ABORT_ON(!head);
315 INIT_LIST_HEAD(head);
316 list_add_tail(&term->list, head);
317 $$ = head;
318}
319
320event_term:
321PE_NAME '=' PE_NAME
322{
323 struct parse_events__term *term;
324
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200325 ABORT_ON(parse_events__term_str(&term, PARSE_EVENTS__TERM_TYPE_USER,
326 $1, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100327 $$ = term;
328}
329|
330PE_NAME '=' PE_VALUE
331{
332 struct parse_events__term *term;
333
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200334 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
335 $1, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100336 $$ = term;
337}
338|
339PE_NAME
340{
341 struct parse_events__term *term;
342
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200343 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
344 $1, 1));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100345 $$ = term;
346}
347|
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200348PE_TERM '=' PE_NAME
349{
350 struct parse_events__term *term;
351
Robert Richterb527bab2012-08-07 19:43:13 +0200352 ABORT_ON(parse_events__term_str(&term, (int)$1, NULL, $3));
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200353 $$ = term;
354}
355|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100356PE_TERM '=' PE_VALUE
357{
358 struct parse_events__term *term;
359
Robert Richterb527bab2012-08-07 19:43:13 +0200360 ABORT_ON(parse_events__term_num(&term, (int)$1, NULL, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100361 $$ = term;
362}
363|
364PE_TERM
365{
366 struct parse_events__term *term;
367
Robert Richterb527bab2012-08-07 19:43:13 +0200368 ABORT_ON(parse_events__term_num(&term, (int)$1, NULL, 1));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100369 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100370}
371
372sep_dc: ':' |
373
Jiri Olsa8f707d82012-03-15 20:09:16 +0100374sep_slash_dc: '/' | ':' |
375
Jiri Olsa89812fc2012-03-15 20:09:15 +0100376%%
377
Zheng Yanac20de62012-06-15 14:31:39 +0800378void parse_events_error(void *data __used, void *scanner __used,
Jiri Olsa89812fc2012-03-15 20:09:15 +0100379 char const *msg __used)
380{
381}