Merge branch 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.git] / tools / perf / util / parse-events.y
CommitLineData
ac20de6f 1%pure-parser
89812fc8 2%name-prefix "parse_events_"
46010ab2 3%parse-param {void *_data}
ac20de6f
ZY
4%parse-param {void *scanner}
5%lex-param {void* scanner}
89812fc8
JO
6
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"
ac20de6f 16#include "parse-events-bison.h"
89812fc8 17
ac20de6f 18extern int parse_events_lex (YYSTYPE* lvalp, void* scanner);
89812fc8
JO
19
20#define ABORT_ON(val) \
21do { \
22 if (val) \
23 YYABORT; \
24} while (0)
25
26%}
27
90e2b22d 28%token PE_START_EVENTS PE_START_TERMS
cf3506dc 29%token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM
89812fc8
JO
30%token PE_NAME
31%token PE_MODIFIER_EVENT PE_MODIFIER_BP
32%token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
33%token PE_PREFIX_MEM PE_PREFIX_RAW
34%token PE_ERROR
35%type <num> PE_VALUE
cf3506dc
JO
36%type <num> PE_VALUE_SYM_HW
37%type <num> PE_VALUE_SYM_SW
89812fc8 38%type <num> PE_RAW
8f707d84 39%type <num> PE_TERM
89812fc8
JO
40%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
cf3506dc 45%type <num> value_sym
8f707d84
JO
46%type <head> event_config
47%type <term> event_term
b847cbdc
JO
48%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
89812fc8
JO
56
57%union
58{
59 char *str;
60 unsigned long num;
8f707d84
JO
61 struct list_head *head;
62 struct parse_events__term *term;
89812fc8
JO
63}
64%%
65
90e2b22d
JO
66start:
67PE_START_EVENTS events
68|
69PE_START_TERMS terms
70
89812fc8
JO
71events:
72events ',' event | event
73
74event:
75event_def PE_MODIFIER_EVENT
76{
46010ab2
JO
77 struct parse_events_data__events *data = _data;
78
5d7be90e
JO
79 /*
80 * Apply modifier on all events added by single event definition
81 * (there could be more events added for multiple tracepoint
82 * definitions via '*?'.
83 */
b847cbdc 84 ABORT_ON(parse_events_modifier($1, $2));
46010ab2 85 parse_events_update_lists($1, &data->list);
89812fc8
JO
86}
87|
88event_def
5d7be90e 89{
46010ab2
JO
90 struct parse_events_data__events *data = _data;
91
92 parse_events_update_lists($1, &data->list);
5d7be90e 93}
89812fc8 94
5f537a26
JO
95event_def: event_pmu |
96 event_legacy_symbol |
89812fc8
JO
97 event_legacy_cache sep_dc |
98 event_legacy_mem |
99 event_legacy_tracepoint sep_dc |
100 event_legacy_numeric sep_dc |
101 event_legacy_raw sep_dc
102
5f537a26
JO
103event_pmu:
104PE_NAME '/' event_config '/'
105{
46010ab2 106 struct parse_events_data__events *data = _data;
b847cbdc
JO
107 struct list_head *list = NULL;
108
46010ab2 109 ABORT_ON(parse_events_add_pmu(&list, &data->idx, $1, $3));
5f537a26 110 parse_events__free_terms($3);
b847cbdc 111 $$ = list;
5f537a26
JO
112}
113
cf3506dc
JO
114value_sym:
115PE_VALUE_SYM_HW
116|
117PE_VALUE_SYM_SW
118
89812fc8 119event_legacy_symbol:
cf3506dc 120value_sym '/' event_config '/'
89812fc8 121{
46010ab2 122 struct parse_events_data__events *data = _data;
b847cbdc 123 struct list_head *list = NULL;
89812fc8
JO
124 int type = $1 >> 16;
125 int config = $1 & 255;
126
46010ab2
JO
127 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
128 type, config, $3));
8f707d84 129 parse_events__free_terms($3);
b847cbdc 130 $$ = list;
8f707d84
JO
131}
132|
cf3506dc 133value_sym sep_slash_dc
8f707d84 134{
46010ab2 135 struct parse_events_data__events *data = _data;
b847cbdc 136 struct list_head *list = NULL;
8f707d84
JO
137 int type = $1 >> 16;
138 int config = $1 & 255;
139
46010ab2
JO
140 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
141 type, config, NULL));
b847cbdc 142 $$ = list;
89812fc8
JO
143}
144
145event_legacy_cache:
146PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
147{
46010ab2 148 struct parse_events_data__events *data = _data;
b847cbdc
JO
149 struct list_head *list = NULL;
150
46010ab2 151 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, $5));
b847cbdc 152 $$ = list;
89812fc8
JO
153}
154|
155PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
156{
46010ab2 157 struct parse_events_data__events *data = _data;
b847cbdc
JO
158 struct list_head *list = NULL;
159
46010ab2 160 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, NULL));
b847cbdc 161 $$ = list;
89812fc8
JO
162}
163|
164PE_NAME_CACHE_TYPE
165{
46010ab2 166 struct parse_events_data__events *data = _data;
b847cbdc
JO
167 struct list_head *list = NULL;
168
46010ab2 169 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, NULL, NULL));
b847cbdc 170 $$ = list;
89812fc8
JO
171}
172
173event_legacy_mem:
174PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
175{
46010ab2 176 struct parse_events_data__events *data = _data;
b847cbdc
JO
177 struct list_head *list = NULL;
178
46010ab2
JO
179 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
180 (void *) $2, $4));
b847cbdc 181 $$ = list;
89812fc8
JO
182}
183|
184PE_PREFIX_MEM PE_VALUE sep_dc
185{
46010ab2 186 struct parse_events_data__events *data = _data;
b847cbdc
JO
187 struct list_head *list = NULL;
188
46010ab2
JO
189 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
190 (void *) $2, NULL));
b847cbdc 191 $$ = list;
89812fc8
JO
192}
193
194event_legacy_tracepoint:
195PE_NAME ':' PE_NAME
196{
46010ab2 197 struct parse_events_data__events *data = _data;
b847cbdc
JO
198 struct list_head *list = NULL;
199
46010ab2 200 ABORT_ON(parse_events_add_tracepoint(&list, &data->idx, $1, $3));
b847cbdc 201 $$ = list;
89812fc8
JO
202}
203
204event_legacy_numeric:
205PE_VALUE ':' PE_VALUE
206{
46010ab2 207 struct parse_events_data__events *data = _data;
b847cbdc
JO
208 struct list_head *list = NULL;
209
46010ab2 210 ABORT_ON(parse_events_add_numeric(&list, &data->idx, $1, $3, NULL));
b847cbdc 211 $$ = list;
89812fc8
JO
212}
213
214event_legacy_raw:
215PE_RAW
216{
46010ab2 217 struct parse_events_data__events *data = _data;
b847cbdc
JO
218 struct list_head *list = NULL;
219
46010ab2
JO
220 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
221 PERF_TYPE_RAW, $1, NULL));
b847cbdc 222 $$ = list;
8f707d84
JO
223}
224
90e2b22d
JO
225terms: event_config
226{
227 struct parse_events_data__terms *data = _data;
228 data->terms = $1;
229}
230
8f707d84
JO
231event_config:
232event_config ',' event_term
233{
234 struct list_head *head = $1;
235 struct parse_events__term *term = $3;
236
237 ABORT_ON(!head);
238 list_add_tail(&term->list, head);
239 $$ = $1;
240}
241|
242event_term
243{
244 struct list_head *head = malloc(sizeof(*head));
245 struct parse_events__term *term = $1;
246
247 ABORT_ON(!head);
248 INIT_LIST_HEAD(head);
249 list_add_tail(&term->list, head);
250 $$ = head;
251}
252
253event_term:
254PE_NAME '=' PE_NAME
255{
256 struct parse_events__term *term;
257
16fa7e82
JO
258 ABORT_ON(parse_events__term_str(&term, PARSE_EVENTS__TERM_TYPE_USER,
259 $1, $3));
8f707d84
JO
260 $$ = term;
261}
262|
263PE_NAME '=' PE_VALUE
264{
265 struct parse_events__term *term;
266
16fa7e82
JO
267 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
268 $1, $3));
8f707d84
JO
269 $$ = term;
270}
271|
272PE_NAME
273{
274 struct parse_events__term *term;
275
16fa7e82
JO
276 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
277 $1, 1));
8f707d84
JO
278 $$ = term;
279}
280|
6b5fc39b
JO
281PE_TERM '=' PE_NAME
282{
283 struct parse_events__term *term;
284
285 ABORT_ON(parse_events__term_str(&term, $1, NULL, $3));
286 $$ = term;
287}
288|
8f707d84
JO
289PE_TERM '=' PE_VALUE
290{
291 struct parse_events__term *term;
292
16fa7e82 293 ABORT_ON(parse_events__term_num(&term, $1, NULL, $3));
8f707d84
JO
294 $$ = term;
295}
296|
297PE_TERM
298{
299 struct parse_events__term *term;
300
16fa7e82 301 ABORT_ON(parse_events__term_num(&term, $1, NULL, 1));
8f707d84 302 $$ = term;
89812fc8
JO
303}
304
305sep_dc: ':' |
306
8f707d84
JO
307sep_slash_dc: '/' | ':' |
308
89812fc8
JO
309%%
310
ac20de6f 311void parse_events_error(void *data __used, void *scanner __used,
89812fc8
JO
312 char const *msg __used)
313{
314}
This page took 0.05186 seconds and 5 git commands to generate.