blob: 2a93d5c8ccda41719b1d8919c201e663805e19d2 [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 Olsa8f707d82012-03-15 20:09:16 +010028%token PE_VALUE PE_VALUE_SYM PE_RAW PE_TERM
Jiri Olsa89812fc2012-03-15 20:09:15 +010029%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
Jiri Olsa8f707d82012-03-15 20:09:16 +010037%type <num> PE_TERM
Jiri Olsa89812fc2012-03-15 20:09:15 +010038%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
Jiri Olsa8f707d82012-03-15 20:09:16 +010043%type <head> event_config
44%type <term> event_term
Jiri Olsab847cbd2012-05-21 09:12:51 +020045%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
Jiri Olsa89812fc2012-03-15 20:09:15 +010053
54%union
55{
56 char *str;
57 unsigned long num;
Jiri Olsa8f707d82012-03-15 20:09:16 +010058 struct list_head *head;
59 struct parse_events__term *term;
Jiri Olsa89812fc2012-03-15 20:09:15 +010060}
61%%
62
63events:
64events ',' event | event
65
66event:
67event_def PE_MODIFIER_EVENT
68{
Jiri Olsa46010ab2012-06-15 14:31:38 +080069 struct parse_events_data__events *data = _data;
70
Jiri Olsa5d7be902012-03-20 19:15:40 +010071 /*
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 */
Jiri Olsab847cbd2012-05-21 09:12:51 +020076 ABORT_ON(parse_events_modifier($1, $2));
Jiri Olsa46010ab2012-06-15 14:31:38 +080077 parse_events_update_lists($1, &data->list);
Jiri Olsa89812fc2012-03-15 20:09:15 +010078}
79|
80event_def
Jiri Olsa5d7be902012-03-20 19:15:40 +010081{
Jiri Olsa46010ab2012-06-15 14:31:38 +080082 struct parse_events_data__events *data = _data;
83
84 parse_events_update_lists($1, &data->list);
Jiri Olsa5d7be902012-03-20 19:15:40 +010085}
Jiri Olsa89812fc2012-03-15 20:09:15 +010086
Jiri Olsa5f537a22012-03-15 20:09:18 +010087event_def: event_pmu |
88 event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +010089 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
Jiri Olsa5f537a22012-03-15 20:09:18 +010095event_pmu:
96PE_NAME '/' event_config '/'
97{
Jiri Olsa46010ab2012-06-15 14:31:38 +080098 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +020099 struct list_head *list = NULL;
100
Jiri Olsa46010ab2012-06-15 14:31:38 +0800101 ABORT_ON(parse_events_add_pmu(&list, &data->idx, $1, $3));
Jiri Olsa5f537a22012-03-15 20:09:18 +0100102 parse_events__free_terms($3);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200103 $$ = list;
Jiri Olsa5f537a22012-03-15 20:09:18 +0100104}
105
Jiri Olsa89812fc2012-03-15 20:09:15 +0100106event_legacy_symbol:
Jiri Olsa8f707d82012-03-15 20:09:16 +0100107PE_VALUE_SYM '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +0100108{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800109 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200110 struct list_head *list = NULL;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100111 int type = $1 >> 16;
112 int config = $1 & 255;
113
Jiri Olsa46010ab2012-06-15 14:31:38 +0800114 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
115 type, config, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100116 parse_events__free_terms($3);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200117 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100118}
119|
120PE_VALUE_SYM sep_slash_dc
121{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800122 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200123 struct list_head *list = NULL;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100124 int type = $1 >> 16;
125 int config = $1 & 255;
126
Jiri Olsa46010ab2012-06-15 14:31:38 +0800127 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
128 type, config, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200129 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100130}
131
132event_legacy_cache:
133PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
134{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800135 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200136 struct list_head *list = NULL;
137
Jiri Olsa46010ab2012-06-15 14:31:38 +0800138 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, $5));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200139 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100140}
141|
142PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
143{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800144 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200145 struct list_head *list = NULL;
146
Jiri Olsa46010ab2012-06-15 14:31:38 +0800147 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200148 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100149}
150|
151PE_NAME_CACHE_TYPE
152{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800153 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200154 struct list_head *list = NULL;
155
Jiri Olsa46010ab2012-06-15 14:31:38 +0800156 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, NULL, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200157 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100158}
159
160event_legacy_mem:
161PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
162{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800163 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200164 struct list_head *list = NULL;
165
Jiri Olsa46010ab2012-06-15 14:31:38 +0800166 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
167 (void *) $2, $4));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200168 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100169}
170|
171PE_PREFIX_MEM PE_VALUE sep_dc
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_breakpoint(&list, &data->idx,
177 (void *) $2, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200178 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100179}
180
181event_legacy_tracepoint:
182PE_NAME ':' PE_NAME
183{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800184 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200185 struct list_head *list = NULL;
186
Jiri Olsa46010ab2012-06-15 14:31:38 +0800187 ABORT_ON(parse_events_add_tracepoint(&list, &data->idx, $1, $3));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200188 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100189}
190
191event_legacy_numeric:
192PE_VALUE ':' PE_VALUE
193{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800194 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200195 struct list_head *list = NULL;
196
Jiri Olsa46010ab2012-06-15 14:31:38 +0800197 ABORT_ON(parse_events_add_numeric(&list, &data->idx, $1, $3, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200198 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100199}
200
201event_legacy_raw:
202PE_RAW
203{
Jiri Olsa46010ab2012-06-15 14:31:38 +0800204 struct parse_events_data__events *data = _data;
Jiri Olsab847cbd2012-05-21 09:12:51 +0200205 struct list_head *list = NULL;
206
Jiri Olsa46010ab2012-06-15 14:31:38 +0800207 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
208 PERF_TYPE_RAW, $1, NULL));
Jiri Olsab847cbd2012-05-21 09:12:51 +0200209 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100210}
211
212event_config:
213event_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|
223event_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
234event_term:
235PE_NAME '=' PE_NAME
236{
237 struct parse_events__term *term;
238
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200239 ABORT_ON(parse_events__term_str(&term, PARSE_EVENTS__TERM_TYPE_USER,
240 $1, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100241 $$ = term;
242}
243|
244PE_NAME '=' PE_VALUE
245{
246 struct parse_events__term *term;
247
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200248 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
249 $1, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100250 $$ = term;
251}
252|
253PE_NAME
254{
255 struct parse_events__term *term;
256
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200257 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
258 $1, 1));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100259 $$ = term;
260}
261|
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200262PE_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|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100270PE_TERM '=' PE_VALUE
271{
272 struct parse_events__term *term;
273
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200274 ABORT_ON(parse_events__term_num(&term, $1, NULL, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100275 $$ = term;
276}
277|
278PE_TERM
279{
280 struct parse_events__term *term;
281
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200282 ABORT_ON(parse_events__term_num(&term, $1, NULL, 1));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100283 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100284}
285
286sep_dc: ':' |
287
Jiri Olsa8f707d82012-03-15 20:09:16 +0100288sep_slash_dc: '/' | ':' |
289
Jiri Olsa89812fc2012-03-15 20:09:15 +0100290%%
291
Zheng Yanac20de6f2012-06-15 14:31:39 +0800292void parse_events_error(void *data __used, void *scanner __used,
Jiri Olsa89812fc2012-03-15 20:09:15 +0100293 char const *msg __used)
294{
295}