]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - tools/perf/util/parse-events.y
perf tools: Add empty rule for new line in event syntax parsing
[mirror_ubuntu-bionic-kernel.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
8f707d84 29%token PE_VALUE PE_VALUE_SYM 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
36%type <num> PE_VALUE_SYM
37%type <num> PE_RAW
8f707d84 38%type <num> PE_TERM
89812fc8
JO
39%type <str> PE_NAME
40%type <str> PE_NAME_CACHE_TYPE
41%type <str> PE_NAME_CACHE_OP_RESULT
42%type <str> PE_MODIFIER_EVENT
43%type <str> PE_MODIFIER_BP
8f707d84
JO
44%type <head> event_config
45%type <term> event_term
b847cbdc
JO
46%type <head> event_pmu
47%type <head> event_legacy_symbol
48%type <head> event_legacy_cache
49%type <head> event_legacy_mem
50%type <head> event_legacy_tracepoint
51%type <head> event_legacy_numeric
52%type <head> event_legacy_raw
53%type <head> event_def
89812fc8
JO
54
55%union
56{
57 char *str;
58 unsigned long num;
8f707d84
JO
59 struct list_head *head;
60 struct parse_events__term *term;
89812fc8
JO
61}
62%%
63
90e2b22d
JO
64start:
65PE_START_EVENTS events
66|
67PE_START_TERMS terms
68
89812fc8
JO
69events:
70events ',' event | event
71
72event:
73event_def PE_MODIFIER_EVENT
74{
46010ab2
JO
75 struct parse_events_data__events *data = _data;
76
5d7be90e
JO
77 /*
78 * Apply modifier on all events added by single event definition
79 * (there could be more events added for multiple tracepoint
80 * definitions via '*?'.
81 */
b847cbdc 82 ABORT_ON(parse_events_modifier($1, $2));
46010ab2 83 parse_events_update_lists($1, &data->list);
89812fc8
JO
84}
85|
86event_def
5d7be90e 87{
46010ab2
JO
88 struct parse_events_data__events *data = _data;
89
90 parse_events_update_lists($1, &data->list);
5d7be90e 91}
89812fc8 92
5f537a26
JO
93event_def: event_pmu |
94 event_legacy_symbol |
89812fc8
JO
95 event_legacy_cache sep_dc |
96 event_legacy_mem |
97 event_legacy_tracepoint sep_dc |
98 event_legacy_numeric sep_dc |
99 event_legacy_raw sep_dc
100
5f537a26
JO
101event_pmu:
102PE_NAME '/' event_config '/'
103{
46010ab2 104 struct parse_events_data__events *data = _data;
b847cbdc
JO
105 struct list_head *list = NULL;
106
46010ab2 107 ABORT_ON(parse_events_add_pmu(&list, &data->idx, $1, $3));
5f537a26 108 parse_events__free_terms($3);
b847cbdc 109 $$ = list;
5f537a26
JO
110}
111
89812fc8 112event_legacy_symbol:
8f707d84 113PE_VALUE_SYM '/' event_config '/'
89812fc8 114{
46010ab2 115 struct parse_events_data__events *data = _data;
b847cbdc 116 struct list_head *list = NULL;
89812fc8
JO
117 int type = $1 >> 16;
118 int config = $1 & 255;
119
46010ab2
JO
120 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
121 type, config, $3));
8f707d84 122 parse_events__free_terms($3);
b847cbdc 123 $$ = list;
8f707d84
JO
124}
125|
126PE_VALUE_SYM sep_slash_dc
127{
46010ab2 128 struct parse_events_data__events *data = _data;
b847cbdc 129 struct list_head *list = NULL;
8f707d84
JO
130 int type = $1 >> 16;
131 int config = $1 & 255;
132
46010ab2
JO
133 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
134 type, config, NULL));
b847cbdc 135 $$ = list;
89812fc8
JO
136}
137
138event_legacy_cache:
139PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
140{
46010ab2 141 struct parse_events_data__events *data = _data;
b847cbdc
JO
142 struct list_head *list = NULL;
143
46010ab2 144 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, $5));
b847cbdc 145 $$ = list;
89812fc8
JO
146}
147|
148PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
149{
46010ab2 150 struct parse_events_data__events *data = _data;
b847cbdc
JO
151 struct list_head *list = NULL;
152
46010ab2 153 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, NULL));
b847cbdc 154 $$ = list;
89812fc8
JO
155}
156|
157PE_NAME_CACHE_TYPE
158{
46010ab2 159 struct parse_events_data__events *data = _data;
b847cbdc
JO
160 struct list_head *list = NULL;
161
46010ab2 162 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, NULL, NULL));
b847cbdc 163 $$ = list;
89812fc8
JO
164}
165
166event_legacy_mem:
167PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
168{
46010ab2 169 struct parse_events_data__events *data = _data;
b847cbdc
JO
170 struct list_head *list = NULL;
171
46010ab2
JO
172 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
173 (void *) $2, $4));
b847cbdc 174 $$ = list;
89812fc8
JO
175}
176|
177PE_PREFIX_MEM PE_VALUE sep_dc
178{
46010ab2 179 struct parse_events_data__events *data = _data;
b847cbdc
JO
180 struct list_head *list = NULL;
181
46010ab2
JO
182 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
183 (void *) $2, NULL));
b847cbdc 184 $$ = list;
89812fc8
JO
185}
186
187event_legacy_tracepoint:
188PE_NAME ':' PE_NAME
189{
46010ab2 190 struct parse_events_data__events *data = _data;
b847cbdc
JO
191 struct list_head *list = NULL;
192
46010ab2 193 ABORT_ON(parse_events_add_tracepoint(&list, &data->idx, $1, $3));
b847cbdc 194 $$ = list;
89812fc8
JO
195}
196
197event_legacy_numeric:
198PE_VALUE ':' PE_VALUE
199{
46010ab2 200 struct parse_events_data__events *data = _data;
b847cbdc
JO
201 struct list_head *list = NULL;
202
46010ab2 203 ABORT_ON(parse_events_add_numeric(&list, &data->idx, $1, $3, NULL));
b847cbdc 204 $$ = list;
89812fc8
JO
205}
206
207event_legacy_raw:
208PE_RAW
209{
46010ab2 210 struct parse_events_data__events *data = _data;
b847cbdc
JO
211 struct list_head *list = NULL;
212
46010ab2
JO
213 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
214 PERF_TYPE_RAW, $1, NULL));
b847cbdc 215 $$ = list;
8f707d84
JO
216}
217
90e2b22d
JO
218terms: event_config
219{
220 struct parse_events_data__terms *data = _data;
221 data->terms = $1;
222}
223
8f707d84
JO
224event_config:
225event_config ',' event_term
226{
227 struct list_head *head = $1;
228 struct parse_events__term *term = $3;
229
230 ABORT_ON(!head);
231 list_add_tail(&term->list, head);
232 $$ = $1;
233}
234|
235event_term
236{
237 struct list_head *head = malloc(sizeof(*head));
238 struct parse_events__term *term = $1;
239
240 ABORT_ON(!head);
241 INIT_LIST_HEAD(head);
242 list_add_tail(&term->list, head);
243 $$ = head;
244}
245
246event_term:
247PE_NAME '=' PE_NAME
248{
249 struct parse_events__term *term;
250
16fa7e82
JO
251 ABORT_ON(parse_events__term_str(&term, PARSE_EVENTS__TERM_TYPE_USER,
252 $1, $3));
8f707d84
JO
253 $$ = term;
254}
255|
256PE_NAME '=' PE_VALUE
257{
258 struct parse_events__term *term;
259
16fa7e82
JO
260 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
261 $1, $3));
8f707d84
JO
262 $$ = term;
263}
264|
265PE_NAME
266{
267 struct parse_events__term *term;
268
16fa7e82
JO
269 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
270 $1, 1));
8f707d84
JO
271 $$ = term;
272}
273|
6b5fc39b
JO
274PE_TERM '=' PE_NAME
275{
276 struct parse_events__term *term;
277
278 ABORT_ON(parse_events__term_str(&term, $1, NULL, $3));
279 $$ = term;
280}
281|
8f707d84
JO
282PE_TERM '=' PE_VALUE
283{
284 struct parse_events__term *term;
285
16fa7e82 286 ABORT_ON(parse_events__term_num(&term, $1, NULL, $3));
8f707d84
JO
287 $$ = term;
288}
289|
290PE_TERM
291{
292 struct parse_events__term *term;
293
16fa7e82 294 ABORT_ON(parse_events__term_num(&term, $1, NULL, 1));
8f707d84 295 $$ = term;
89812fc8
JO
296}
297
298sep_dc: ':' |
299
8f707d84
JO
300sep_slash_dc: '/' | ':' |
301
89812fc8
JO
302%%
303
ac20de6f 304void parse_events_error(void *data __used, void *scanner __used,
89812fc8
JO
305 char const *msg __used)
306{
307}