blob: e533bf72ba9cacc755078567268f6882c1713d28 [file] [log] [blame]
Jiri Olsa89812fc2012-03-15 20:09:15 +01001
2%name-prefix "parse_events_"
Jiri Olsa46010ab2012-06-15 14:31:38 +08003%parse-param {void *_data}
Jiri Olsa89812fc2012-03-15 20:09:15 +01004
5%{
6
7#define YYDEBUG 1
8
9#include <linux/compiler.h>
10#include <linux/list.h>
11#include "types.h"
12#include "util.h"
13#include "parse-events.h"
14
15extern int parse_events_lex (void);
16
17#define ABORT_ON(val) \
18do { \
19 if (val) \
20 YYABORT; \
21} while (0)
22
23%}
24
Jiri Olsa8f707d82012-03-15 20:09:16 +010025%token PE_VALUE PE_VALUE_SYM PE_RAW PE_TERM
Jiri Olsa89812fc2012-03-15 20:09:15 +010026%token PE_NAME
27%token PE_MODIFIER_EVENT PE_MODIFIER_BP
28%token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
29%token PE_PREFIX_MEM PE_PREFIX_RAW
30%token PE_ERROR
31%type <num> PE_VALUE
32%type <num> PE_VALUE_SYM
33%type <num> PE_RAW
Jiri Olsa8f707d82012-03-15 20:09:16 +010034%type <num> PE_TERM
Jiri Olsa89812fc2012-03-15 20:09:15 +010035%type <str> PE_NAME
36%type <str> PE_NAME_CACHE_TYPE
37%type <str> PE_NAME_CACHE_OP_RESULT
38%type <str> PE_MODIFIER_EVENT
39%type <str> PE_MODIFIER_BP
Jiri Olsa8f707d82012-03-15 20:09:16 +010040%type <head> event_config
41%type <term> event_term
Jiri Olsab847cbd2012-05-21 09:12:51 +020042%type <head> event_pmu
43%type <head> event_legacy_symbol
44%type <head> event_legacy_cache
45%type <head> event_legacy_mem
46%type <head> event_legacy_tracepoint
47%type <head> event_legacy_numeric
48%type <head> event_legacy_raw
49%type <head> event_def
Jiri Olsa89812fc2012-03-15 20:09:15 +010050
51%union
52{
53 char *str;
54 unsigned long num;
Jiri Olsa8f707d82012-03-15 20:09:16 +010055 struct list_head *head;
56 struct parse_events__term *term;
Jiri Olsa89812fc2012-03-15 20:09:15 +010057}
58%%
59
60events:
61events ',' event | event
62
63event:
64event_def PE_MODIFIER_EVENT
65{
Jiri Olsa46010ab2012-06-15 14:31:38 +080066 struct parse_events_data__events *data = _data;
67
Jiri Olsa5d7be902012-03-20 19:15:40 +010068 /*
69 * Apply modifier on all events added by single event definition
70 * (there could be more events added for multiple tracepoint
71 * definitions via '*?'.
72 */
Jiri Olsab847cbd2012-05-21 09:12:51 +020073 ABORT_ON(parse_events_modifier($1, $2));
Jiri Olsa46010ab2012-06-15 14:31:38 +080074 parse_events_update_lists($1, &data->list);
Jiri Olsa89812fc2012-03-15 20:09:15 +010075}
76|
77event_def
Jiri Olsa5d7be902012-03-20 19:15:40 +010078{
Jiri Olsa46010ab2012-06-15 14:31:38 +080079 struct parse_events_data__events *data = _data;
80
81 parse_events_update_lists($1, &data->list);
Jiri Olsa5d7be902012-03-20 19:15:40 +010082}
Jiri Olsa89812fc2012-03-15 20:09:15 +010083
Jiri Olsa5f537a22012-03-15 20:09:18 +010084event_def: event_pmu |
85 event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +010086 event_legacy_cache sep_dc |
87 event_legacy_mem |
88 event_legacy_tracepoint sep_dc |
89 event_legacy_numeric sep_dc |
90 event_legacy_raw sep_dc
91
Jiri Olsa5f537a22012-03-15 20:09:18 +010092event_pmu:
93PE_NAME '/' event_config '/'
94{
Jiri Olsa46010ab2012-06-15 14:31:38 +080095 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +020096 struct list_head *list = NULL;
97
Jiri Olsa46010ab2012-06-15 14:31:38 +080098 ABORT_ON(parse_events_add_pmu(&list, &data->idx, $1, $3));
Jiri Olsa5f537a22012-03-15 20:09:18 +010099 parse_events__free_terms($3);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200100 $$ = list;
Jiri Olsa5f537a22012-03-15 20:09:18 +0100101}
102
Jiri Olsa89812fc2012-03-15 20:09:15 +0100103event_legacy_symbol:
Jiri Olsa8f707d82012-03-15 20:09:16 +0100104PE_VALUE_SYM '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +0100105{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800106 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200107 struct list_head *list = NULL;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100108 int type = $1 >> 16;
109 int config = $1 & 255;
110
Jiri Olsa46010ab2012-06-15 14:31:38 +0800111 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
112 type, config, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100113 parse_events__free_terms($3);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200114 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100115}
116|
117PE_VALUE_SYM sep_slash_dc
118{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800119 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200120 struct list_head *list = NULL;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100121 int type = $1 >> 16;
122 int config = $1 & 255;
123
Jiri Olsa46010ab2012-06-15 14:31:38 +0800124 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
125 type, config, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200126 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100127}
128
129event_legacy_cache:
130PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
131{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800132 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200133 struct list_head *list = NULL;
134
Jiri Olsa46010ab2012-06-15 14:31:38 +0800135 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, $5));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200136 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100137}
138|
139PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
140{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800141 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200142 struct list_head *list = NULL;
143
Jiri Olsa46010ab2012-06-15 14:31:38 +0800144 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200145 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100146}
147|
148PE_NAME_CACHE_TYPE
149{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800150 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200151 struct list_head *list = NULL;
152
Jiri Olsa46010ab2012-06-15 14:31:38 +0800153 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, NULL, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200154 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100155}
156
157event_legacy_mem:
158PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
159{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800160 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200161 struct list_head *list = NULL;
162
Jiri Olsa46010ab2012-06-15 14:31:38 +0800163 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
164 (void *) $2, $4));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200165 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100166}
167|
168PE_PREFIX_MEM PE_VALUE sep_dc
169{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800170 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200171 struct list_head *list = NULL;
172
Jiri Olsa46010ab2012-06-15 14:31:38 +0800173 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
174 (void *) $2, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200175 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100176}
177
178event_legacy_tracepoint:
179PE_NAME ':' PE_NAME
180{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800181 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200182 struct list_head *list = NULL;
183
Jiri Olsa46010ab2012-06-15 14:31:38 +0800184 ABORT_ON(parse_events_add_tracepoint(&list, &data->idx, $1, $3));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200185 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100186}
187
188event_legacy_numeric:
189PE_VALUE ':' PE_VALUE
190{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800191 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200192 struct list_head *list = NULL;
193
Jiri Olsa46010ab2012-06-15 14:31:38 +0800194 ABORT_ON(parse_events_add_numeric(&list, &data->idx, $1, $3, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200195 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100196}
197
198event_legacy_raw:
199PE_RAW
200{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800201 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200202 struct list_head *list = NULL;
203
Jiri Olsa46010ab2012-06-15 14:31:38 +0800204 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
205 PERF_TYPE_RAW, $1, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200206 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100207}
208
209event_config:
210event_config ',' event_term
211{
212 struct list_head *head = $1;
213 struct parse_events__term *term = $3;
214
215 ABORT_ON(!head);
216 list_add_tail(&term->list, head);
217 $$ = $1;
218}
219|
220event_term
221{
222 struct list_head *head = malloc(sizeof(*head));
223 struct parse_events__term *term = $1;
224
225 ABORT_ON(!head);
226 INIT_LIST_HEAD(head);
227 list_add_tail(&term->list, head);
228 $$ = head;
229}
230
231event_term:
232PE_NAME '=' PE_NAME
233{
234 struct parse_events__term *term;
235
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200236 ABORT_ON(parse_events__term_str(&term, PARSE_EVENTS__TERM_TYPE_USER,
237 $1, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100238 $$ = term;
239}
240|
241PE_NAME '=' PE_VALUE
242{
243 struct parse_events__term *term;
244
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200245 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
246 $1, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100247 $$ = term;
248}
249|
250PE_NAME
251{
252 struct parse_events__term *term;
253
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200254 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
255 $1, 1));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100256 $$ = term;
257}
258|
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200259PE_TERM '=' PE_NAME
260{
261 struct parse_events__term *term;
262
263 ABORT_ON(parse_events__term_str(&term, $1, NULL, $3));
264 $$ = term;
265}
266|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100267PE_TERM '=' PE_VALUE
268{
269 struct parse_events__term *term;
270
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200271 ABORT_ON(parse_events__term_num(&term, $1, NULL, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100272 $$ = term;
273}
274|
275PE_TERM
276{
277 struct parse_events__term *term;
278
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200279 ABORT_ON(parse_events__term_num(&term, $1, NULL, 1));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100280 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100281}
282
283sep_dc: ':' |
284
Jiri Olsa8f707d82012-03-15 20:09:16 +0100285sep_slash_dc: '/' | ':' |
286
Jiri Olsa89812fc2012-03-15 20:09:15 +0100287%%
288
Jiri Olsa46010ab2012-06-15 14:31:38 +0800289void parse_events_error(void *data __used,
Jiri Olsa89812fc2012-03-15 20:09:15 +0100290 char const *msg __used)
291{
292}