blob: cd88209e3c5876e96f26ef9046d2778554c18b9e [file] [log] [blame]
Zheng Yanac20de6f2012-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 Yanac20de6f2012-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 Yanac20de6f2012-06-15 14:31:39 +080016#include "parse-events-bison.h"
Jiri Olsa89812fc2012-03-15 20:09:15 +010017
Zheng Yanac20de6f2012-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
Robert Richterac2ba9f2012-08-16 21:10:21 +020030%token PE_EVENT_NAME
Jiri Olsa89812fc2012-03-15 20:09:15 +010031%token PE_NAME
32%token PE_MODIFIER_EVENT PE_MODIFIER_BP
33%token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
Jiri Olsa89efb022012-08-08 12:14:14 +020034%token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP
Jiri Olsa89812fc2012-03-15 20:09:15 +010035%token PE_ERROR
36%type <num> PE_VALUE
Jiri Olsacf3506d2012-07-04 00:00:43 +020037%type <num> PE_VALUE_SYM_HW
38%type <num> PE_VALUE_SYM_SW
Jiri Olsa89812fc2012-03-15 20:09:15 +010039%type <num> PE_RAW
Jiri Olsa8f707d82012-03-15 20:09:16 +010040%type <num> PE_TERM
Jiri Olsa89812fc2012-03-15 20:09:15 +010041%type <str> PE_NAME
42%type <str> PE_NAME_CACHE_TYPE
43%type <str> PE_NAME_CACHE_OP_RESULT
44%type <str> PE_MODIFIER_EVENT
45%type <str> PE_MODIFIER_BP
Robert Richterac2ba9f2012-08-16 21:10:21 +020046%type <str> PE_EVENT_NAME
Jiri Olsacf3506d2012-07-04 00:00:43 +020047%type <num> value_sym
Jiri Olsa8f707d82012-03-15 20:09:16 +010048%type <head> event_config
49%type <term> event_term
Jiri Olsab847cbd2012-05-21 09:12:51 +020050%type <head> event_pmu
51%type <head> event_legacy_symbol
52%type <head> event_legacy_cache
53%type <head> event_legacy_mem
54%type <head> event_legacy_tracepoint
55%type <head> event_legacy_numeric
56%type <head> event_legacy_raw
57%type <head> event_def
Robert Richterac2ba9f2012-08-16 21:10:21 +020058%type <head> event_mod
59%type <head> event_name
Jiri Olsa89efb022012-08-08 12:14:14 +020060%type <head> event
61%type <head> events
62%type <head> group_def
63%type <head> group
64%type <head> groups
Jiri Olsa89812fc2012-03-15 20:09:15 +010065
66%union
67{
68 char *str;
Robert Richterb527bab2012-08-07 19:43:13 +020069 u64 num;
Jiri Olsa8f707d82012-03-15 20:09:16 +010070 struct list_head *head;
71 struct parse_events__term *term;
Jiri Olsa89812fc2012-03-15 20:09:15 +010072}
73%%
74
Jiri Olsa90e2b222012-06-15 14:31:40 +080075start:
Jiri Olsa89efb022012-08-08 12:14:14 +020076PE_START_EVENTS start_events
Jiri Olsa90e2b222012-06-15 14:31:40 +080077|
Jiri Olsa89efb022012-08-08 12:14:14 +020078PE_START_TERMS start_terms
79
80start_events: groups
81{
82 struct parse_events_data__events *data = _data;
83
84 parse_events_update_lists($1, &data->list);
85}
86
87groups:
88groups ',' group
89{
90 struct list_head *list = $1;
91 struct list_head *group = $3;
92
93 parse_events_update_lists(group, list);
94 $$ = list;
95}
96|
97groups ',' event
98{
99 struct list_head *list = $1;
100 struct list_head *event = $3;
101
102 parse_events_update_lists(event, list);
103 $$ = list;
104}
105|
106group
107|
108event
109
110group:
111group_def ':' PE_MODIFIER_EVENT
112{
113 struct list_head *list = $1;
114
115 ABORT_ON(parse_events__modifier_group(list, $3));
116 $$ = list;
117}
118|
119group_def
120
121group_def:
122PE_NAME '{' events '}'
123{
124 struct list_head *list = $3;
125
Arnaldo Carvalho de Melo63dab222012-08-14 16:35:48 -0300126 parse_events__set_leader($1, list);
Jiri Olsa89efb022012-08-08 12:14:14 +0200127 $$ = list;
128}
129|
130'{' events '}'
131{
132 struct list_head *list = $2;
133
Arnaldo Carvalho de Melo63dab222012-08-14 16:35:48 -0300134 parse_events__set_leader(NULL, list);
Jiri Olsa89efb022012-08-08 12:14:14 +0200135 $$ = list;
136}
Jiri Olsa90e2b222012-06-15 14:31:40 +0800137
Jiri Olsa89812fc2012-03-15 20:09:15 +0100138events:
Jiri Olsa89efb022012-08-08 12:14:14 +0200139events ',' event
140{
141 struct list_head *event = $3;
142 struct list_head *list = $1;
143
144 parse_events_update_lists(event, list);
145 $$ = list;
146}
147|
148event
Jiri Olsa89812fc2012-03-15 20:09:15 +0100149
Robert Richterac2ba9f2012-08-16 21:10:21 +0200150event: event_mod
151
152event_mod:
153event_name PE_MODIFIER_EVENT
Jiri Olsa89812fc2012-03-15 20:09:15 +0100154{
Jiri Olsa89efb022012-08-08 12:14:14 +0200155 struct list_head *list = $1;
Jiri Olsa46010ab2012-06-15 14:31:38 +0800156
Jiri Olsa5d7be902012-03-20 19:15:40 +0100157 /*
158 * Apply modifier on all events added by single event definition
159 * (there could be more events added for multiple tracepoint
160 * definitions via '*?'.
161 */
Jiri Olsaf5b11352012-08-08 12:21:54 +0200162 ABORT_ON(parse_events__modifier_event(list, $2, false));
Jiri Olsa89efb022012-08-08 12:14:14 +0200163 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100164}
165|
Robert Richterac2ba9f2012-08-16 21:10:21 +0200166event_name
167
168event_name:
169PE_EVENT_NAME event_def
170{
171 ABORT_ON(parse_events_name($2, $1));
172 free($1);
173 $$ = $2;
174}
175|
Jiri Olsa89812fc2012-03-15 20:09:15 +0100176event_def
177
Jiri Olsa5f537a22012-03-15 20:09:18 +0100178event_def: event_pmu |
179 event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +0100180 event_legacy_cache sep_dc |
181 event_legacy_mem |
182 event_legacy_tracepoint sep_dc |
183 event_legacy_numeric sep_dc |
184 event_legacy_raw sep_dc
185
Jiri Olsa5f537a22012-03-15 20:09:18 +0100186event_pmu:
187PE_NAME '/' event_config '/'
188{
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;
191
Jiri Olsa46010ab2012-06-15 14:31:38 +0800192 ABORT_ON(parse_events_add_pmu(&list, &data->idx, $1, $3));
Jiri Olsa5f537a22012-03-15 20:09:18 +0100193 parse_events__free_terms($3);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200194 $$ = list;
Jiri Olsa5f537a22012-03-15 20:09:18 +0100195}
196
Jiri Olsacf3506d2012-07-04 00:00:43 +0200197value_sym:
198PE_VALUE_SYM_HW
199|
200PE_VALUE_SYM_SW
201
Jiri Olsa89812fc2012-03-15 20:09:15 +0100202event_legacy_symbol:
Jiri Olsacf3506d2012-07-04 00:00:43 +0200203value_sym '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +0100204{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800205 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200206 struct list_head *list = NULL;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100207 int type = $1 >> 16;
208 int config = $1 & 255;
209
Jiri Olsa46010ab2012-06-15 14:31:38 +0800210 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
211 type, config, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100212 parse_events__free_terms($3);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200213 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100214}
215|
Jiri Olsacf3506d2012-07-04 00:00:43 +0200216value_sym sep_slash_dc
Jiri Olsa8f707d82012-03-15 20:09:16 +0100217{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800218 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200219 struct list_head *list = NULL;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100220 int type = $1 >> 16;
221 int config = $1 & 255;
222
Jiri Olsa46010ab2012-06-15 14:31:38 +0800223 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
224 type, config, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200225 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100226}
227
228event_legacy_cache:
229PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
230{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800231 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200232 struct list_head *list = NULL;
233
Jiri Olsa46010ab2012-06-15 14:31:38 +0800234 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, $5));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200235 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100236}
237|
238PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
239{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800240 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200241 struct list_head *list = NULL;
242
Jiri Olsa46010ab2012-06-15 14:31:38 +0800243 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200244 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100245}
246|
247PE_NAME_CACHE_TYPE
248{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800249 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200250 struct list_head *list = NULL;
251
Jiri Olsa46010ab2012-06-15 14:31:38 +0800252 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, NULL, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200253 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100254}
255
256event_legacy_mem:
257PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
258{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800259 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200260 struct list_head *list = NULL;
261
Jiri Olsa46010ab2012-06-15 14:31:38 +0800262 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
263 (void *) $2, $4));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200264 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100265}
266|
267PE_PREFIX_MEM PE_VALUE sep_dc
268{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800269 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200270 struct list_head *list = NULL;
271
Jiri Olsa46010ab2012-06-15 14:31:38 +0800272 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
273 (void *) $2, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200274 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100275}
276
277event_legacy_tracepoint:
278PE_NAME ':' PE_NAME
279{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800280 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200281 struct list_head *list = NULL;
282
Jiri Olsa46010ab2012-06-15 14:31:38 +0800283 ABORT_ON(parse_events_add_tracepoint(&list, &data->idx, $1, $3));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200284 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100285}
286
287event_legacy_numeric:
288PE_VALUE ':' PE_VALUE
289{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800290 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200291 struct list_head *list = NULL;
292
Robert Richterb527bab2012-08-07 19:43:13 +0200293 ABORT_ON(parse_events_add_numeric(&list, &data->idx, (u32)$1, $3, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200294 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100295}
296
297event_legacy_raw:
298PE_RAW
299{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800300 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200301 struct list_head *list = NULL;
302
Jiri Olsa46010ab2012-06-15 14:31:38 +0800303 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
304 PERF_TYPE_RAW, $1, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200305 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100306}
307
Jiri Olsa89efb022012-08-08 12:14:14 +0200308start_terms: event_config
Jiri Olsa90e2b222012-06-15 14:31:40 +0800309{
310 struct parse_events_data__terms *data = _data;
311 data->terms = $1;
312}
313
Jiri Olsa8f707d82012-03-15 20:09:16 +0100314event_config:
315event_config ',' event_term
316{
317 struct list_head *head = $1;
318 struct parse_events__term *term = $3;
319
320 ABORT_ON(!head);
321 list_add_tail(&term->list, head);
322 $$ = $1;
323}
324|
325event_term
326{
327 struct list_head *head = malloc(sizeof(*head));
328 struct parse_events__term *term = $1;
329
330 ABORT_ON(!head);
331 INIT_LIST_HEAD(head);
332 list_add_tail(&term->list, head);
333 $$ = head;
334}
335
336event_term:
337PE_NAME '=' PE_NAME
338{
339 struct parse_events__term *term;
340
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200341 ABORT_ON(parse_events__term_str(&term, PARSE_EVENTS__TERM_TYPE_USER,
342 $1, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100343 $$ = term;
344}
345|
346PE_NAME '=' PE_VALUE
347{
348 struct parse_events__term *term;
349
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200350 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
351 $1, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100352 $$ = term;
353}
354|
355PE_NAME
356{
357 struct parse_events__term *term;
358
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200359 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
360 $1, 1));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100361 $$ = term;
362}
363|
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200364PE_TERM '=' PE_NAME
365{
366 struct parse_events__term *term;
367
Robert Richterb527bab2012-08-07 19:43:13 +0200368 ABORT_ON(parse_events__term_str(&term, (int)$1, NULL, $3));
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200369 $$ = term;
370}
371|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100372PE_TERM '=' PE_VALUE
373{
374 struct parse_events__term *term;
375
Robert Richterb527bab2012-08-07 19:43:13 +0200376 ABORT_ON(parse_events__term_num(&term, (int)$1, NULL, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100377 $$ = term;
378}
379|
380PE_TERM
381{
382 struct parse_events__term *term;
383
Robert Richterb527bab2012-08-07 19:43:13 +0200384 ABORT_ON(parse_events__term_num(&term, (int)$1, NULL, 1));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100385 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100386}
387
388sep_dc: ':' |
389
Jiri Olsa8f707d82012-03-15 20:09:16 +0100390sep_slash_dc: '/' | ':' |
391
Jiri Olsa89812fc2012-03-15 20:09:15 +0100392%%
393
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300394void parse_events_error(void *data __maybe_unused, void *scanner __maybe_unused,
395 char const *msg __maybe_unused)
Jiri Olsa89812fc2012-03-15 20:09:15 +0100396{
397}