blob: 362cc59332ae78e0774fed92e3f20a2f751fa211 [file] [log] [blame]
Jiri Olsa89812fc2012-03-15 20:09:15 +01001
2%name-prefix "parse_events_"
Jiri Olsa5d7be902012-03-20 19:15:40 +01003%parse-param {struct list_head *list_all}
Jiri Olsa89812fc2012-03-15 20:09:15 +01004%parse-param {int *idx}
5
6%{
7
8#define YYDEBUG 1
9
10#include <linux/compiler.h>
11#include <linux/list.h>
12#include "types.h"
13#include "util.h"
14#include "parse-events.h"
15
16extern int parse_events_lex (void);
17
18#define ABORT_ON(val) \
19do { \
20 if (val) \
21 YYABORT; \
22} while (0)
23
24%}
25
Jiri Olsa8f707d82012-03-15 20:09:16 +010026%token PE_VALUE PE_VALUE_SYM PE_RAW PE_TERM
Jiri Olsa89812fc2012-03-15 20:09:15 +010027%token PE_NAME
28%token PE_MODIFIER_EVENT PE_MODIFIER_BP
29%token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
30%token PE_PREFIX_MEM PE_PREFIX_RAW
31%token PE_ERROR
32%type <num> PE_VALUE
33%type <num> PE_VALUE_SYM
34%type <num> PE_RAW
Jiri Olsa8f707d82012-03-15 20:09:16 +010035%type <num> PE_TERM
Jiri Olsa89812fc2012-03-15 20:09:15 +010036%type <str> PE_NAME
37%type <str> PE_NAME_CACHE_TYPE
38%type <str> PE_NAME_CACHE_OP_RESULT
39%type <str> PE_MODIFIER_EVENT
40%type <str> PE_MODIFIER_BP
Jiri Olsa8f707d82012-03-15 20:09:16 +010041%type <head> event_config
42%type <term> event_term
Jiri Olsab847cbd2012-05-21 09:12:51 +020043%type <head> event_pmu
44%type <head> event_legacy_symbol
45%type <head> event_legacy_cache
46%type <head> event_legacy_mem
47%type <head> event_legacy_tracepoint
48%type <head> event_legacy_numeric
49%type <head> event_legacy_raw
50%type <head> event_def
Jiri Olsa89812fc2012-03-15 20:09:15 +010051
52%union
53{
54 char *str;
55 unsigned long num;
Jiri Olsa8f707d82012-03-15 20:09:16 +010056 struct list_head *head;
57 struct parse_events__term *term;
Jiri Olsa89812fc2012-03-15 20:09:15 +010058}
59%%
60
61events:
62events ',' event | event
63
64event:
65event_def PE_MODIFIER_EVENT
66{
Jiri Olsa5d7be902012-03-20 19:15:40 +010067 /*
68 * Apply modifier on all events added by single event definition
69 * (there could be more events added for multiple tracepoint
70 * definitions via '*?'.
71 */
Jiri Olsab847cbd2012-05-21 09:12:51 +020072 ABORT_ON(parse_events_modifier($1, $2));
73 parse_events_update_lists($1, list_all);
Jiri Olsa89812fc2012-03-15 20:09:15 +010074}
75|
76event_def
Jiri Olsa5d7be902012-03-20 19:15:40 +010077{
Jiri Olsab847cbd2012-05-21 09:12:51 +020078 parse_events_update_lists($1, list_all);
Jiri Olsa5d7be902012-03-20 19:15:40 +010079}
Jiri Olsa89812fc2012-03-15 20:09:15 +010080
Jiri Olsa5f537a22012-03-15 20:09:18 +010081event_def: event_pmu |
82 event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +010083 event_legacy_cache sep_dc |
84 event_legacy_mem |
85 event_legacy_tracepoint sep_dc |
86 event_legacy_numeric sep_dc |
87 event_legacy_raw sep_dc
88
Jiri Olsa5f537a22012-03-15 20:09:18 +010089event_pmu:
90PE_NAME '/' event_config '/'
91{
Jiri Olsab847cbd2012-05-21 09:12:51 +020092 struct list_head *list = NULL;
93
94 ABORT_ON(parse_events_add_pmu(&list, idx, $1, $3));
Jiri Olsa5f537a22012-03-15 20:09:18 +010095 parse_events__free_terms($3);
Jiri Olsab847cbd2012-05-21 09:12:51 +020096 $$ = list;
Jiri Olsa5f537a22012-03-15 20:09:18 +010097}
98
Jiri Olsa89812fc2012-03-15 20:09:15 +010099event_legacy_symbol:
Jiri Olsa8f707d82012-03-15 20:09:16 +0100100PE_VALUE_SYM '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +0100101{
Jiri Olsab847cbd2012-05-21 09:12:51 +0200102 struct list_head *list = NULL;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100103 int type = $1 >> 16;
104 int config = $1 & 255;
105
Jiri Olsab847cbd2012-05-21 09:12:51 +0200106 ABORT_ON(parse_events_add_numeric(&list, idx, type, config, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100107 parse_events__free_terms($3);
Jiri Olsab847cbd2012-05-21 09:12:51 +0200108 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100109}
110|
111PE_VALUE_SYM sep_slash_dc
112{
Jiri Olsab847cbd2012-05-21 09:12:51 +0200113 struct list_head *list = NULL;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100114 int type = $1 >> 16;
115 int config = $1 & 255;
116
Jiri Olsab847cbd2012-05-21 09:12:51 +0200117 ABORT_ON(parse_events_add_numeric(&list, idx, type, config, NULL));
118 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100119}
120
121event_legacy_cache:
122PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
123{
Jiri Olsab847cbd2012-05-21 09:12:51 +0200124 struct list_head *list = NULL;
125
126 ABORT_ON(parse_events_add_cache(&list, idx, $1, $3, $5));
127 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100128}
129|
130PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
131{
Jiri Olsab847cbd2012-05-21 09:12:51 +0200132 struct list_head *list = NULL;
133
134 ABORT_ON(parse_events_add_cache(&list, idx, $1, $3, NULL));
135 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100136}
137|
138PE_NAME_CACHE_TYPE
139{
Jiri Olsab847cbd2012-05-21 09:12:51 +0200140 struct list_head *list = NULL;
141
142 ABORT_ON(parse_events_add_cache(&list, idx, $1, NULL, NULL));
143 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100144}
145
146event_legacy_mem:
147PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
148{
Jiri Olsab847cbd2012-05-21 09:12:51 +0200149 struct list_head *list = NULL;
150
151 ABORT_ON(parse_events_add_breakpoint(&list, idx, (void *) $2, $4));
152 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100153}
154|
155PE_PREFIX_MEM PE_VALUE sep_dc
156{
Jiri Olsab847cbd2012-05-21 09:12:51 +0200157 struct list_head *list = NULL;
158
159 ABORT_ON(parse_events_add_breakpoint(&list, idx, (void *) $2, NULL));
160 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100161}
162
163event_legacy_tracepoint:
164PE_NAME ':' PE_NAME
165{
Jiri Olsab847cbd2012-05-21 09:12:51 +0200166 struct list_head *list = NULL;
167
168 ABORT_ON(parse_events_add_tracepoint(&list, idx, $1, $3));
169 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100170}
171
172event_legacy_numeric:
173PE_VALUE ':' PE_VALUE
174{
Jiri Olsab847cbd2012-05-21 09:12:51 +0200175 struct list_head *list = NULL;
176
177 ABORT_ON(parse_events_add_numeric(&list, idx, $1, $3, NULL));
178 $$ = list;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100179}
180
181event_legacy_raw:
182PE_RAW
183{
Jiri Olsab847cbd2012-05-21 09:12:51 +0200184 struct list_head *list = NULL;
185
186 ABORT_ON(parse_events_add_numeric(&list, idx, PERF_TYPE_RAW, $1, NULL));
187 $$ = list;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100188}
189
190event_config:
191event_config ',' event_term
192{
193 struct list_head *head = $1;
194 struct parse_events__term *term = $3;
195
196 ABORT_ON(!head);
197 list_add_tail(&term->list, head);
198 $$ = $1;
199}
200|
201event_term
202{
203 struct list_head *head = malloc(sizeof(*head));
204 struct parse_events__term *term = $1;
205
206 ABORT_ON(!head);
207 INIT_LIST_HEAD(head);
208 list_add_tail(&term->list, head);
209 $$ = head;
210}
211
212event_term:
213PE_NAME '=' PE_NAME
214{
215 struct parse_events__term *term;
216
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200217 ABORT_ON(parse_events__term_str(&term, PARSE_EVENTS__TERM_TYPE_USER,
218 $1, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100219 $$ = term;
220}
221|
222PE_NAME '=' PE_VALUE
223{
224 struct parse_events__term *term;
225
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200226 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
227 $1, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100228 $$ = term;
229}
230|
231PE_NAME
232{
233 struct parse_events__term *term;
234
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200235 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
236 $1, 1));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100237 $$ = term;
238}
239|
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200240PE_TERM '=' PE_NAME
241{
242 struct parse_events__term *term;
243
244 ABORT_ON(parse_events__term_str(&term, $1, NULL, $3));
245 $$ = term;
246}
247|
Jiri Olsa8f707d82012-03-15 20:09:16 +0100248PE_TERM '=' PE_VALUE
249{
250 struct parse_events__term *term;
251
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200252 ABORT_ON(parse_events__term_num(&term, $1, NULL, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100253 $$ = term;
254}
255|
256PE_TERM
257{
258 struct parse_events__term *term;
259
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200260 ABORT_ON(parse_events__term_num(&term, $1, NULL, 1));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100261 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100262}
263
264sep_dc: ':' |
265
Jiri Olsa8f707d82012-03-15 20:09:16 +0100266sep_slash_dc: '/' | ':' |
267
Jiri Olsa89812fc2012-03-15 20:09:15 +0100268%%
269
Jiri Olsa5d7be902012-03-20 19:15:40 +0100270void parse_events_error(struct list_head *list_all __used,
Jiri Olsa5d7be902012-03-20 19:15:40 +0100271 int *idx __used,
Jiri Olsa89812fc2012-03-15 20:09:15 +0100272 char const *msg __used)
273{
274}