]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - tools/perf/util/parse-events.y
perf tools: Reconstruct sw event with modifiers from perf_event_attr
[mirror_ubuntu-zesty-kernel.git] / tools / perf / util / parse-events.y
CommitLineData
89812fc8
JO
1
2%name-prefix "parse_events_"
5d7be90e 3%parse-param {struct list_head *list_all}
89812fc8
JO
4%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
8f707d84 26%token PE_VALUE PE_VALUE_SYM PE_RAW PE_TERM
89812fc8
JO
27%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
8f707d84 35%type <num> PE_TERM
89812fc8
JO
36%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
8f707d84
JO
41%type <head> event_config
42%type <term> event_term
b847cbdc
JO
43%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
89812fc8
JO
51
52%union
53{
54 char *str;
55 unsigned long num;
8f707d84
JO
56 struct list_head *head;
57 struct parse_events__term *term;
89812fc8
JO
58}
59%%
60
61events:
62events ',' event | event
63
64event:
65event_def PE_MODIFIER_EVENT
66{
5d7be90e
JO
67 /*
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 */
b847cbdc
JO
72 ABORT_ON(parse_events_modifier($1, $2));
73 parse_events_update_lists($1, list_all);
89812fc8
JO
74}
75|
76event_def
5d7be90e 77{
b847cbdc 78 parse_events_update_lists($1, list_all);
5d7be90e 79}
89812fc8 80
5f537a26
JO
81event_def: event_pmu |
82 event_legacy_symbol |
89812fc8
JO
83 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
5f537a26
JO
89event_pmu:
90PE_NAME '/' event_config '/'
91{
b847cbdc
JO
92 struct list_head *list = NULL;
93
94 ABORT_ON(parse_events_add_pmu(&list, idx, $1, $3));
5f537a26 95 parse_events__free_terms($3);
b847cbdc 96 $$ = list;
5f537a26
JO
97}
98
89812fc8 99event_legacy_symbol:
8f707d84 100PE_VALUE_SYM '/' event_config '/'
89812fc8 101{
b847cbdc 102 struct list_head *list = NULL;
89812fc8
JO
103 int type = $1 >> 16;
104 int config = $1 & 255;
105
b847cbdc 106 ABORT_ON(parse_events_add_numeric(&list, idx, type, config, $3));
8f707d84 107 parse_events__free_terms($3);
b847cbdc 108 $$ = list;
8f707d84
JO
109}
110|
111PE_VALUE_SYM sep_slash_dc
112{
b847cbdc 113 struct list_head *list = NULL;
8f707d84
JO
114 int type = $1 >> 16;
115 int config = $1 & 255;
116
b847cbdc
JO
117 ABORT_ON(parse_events_add_numeric(&list, idx, type, config, NULL));
118 $$ = list;
89812fc8
JO
119}
120
121event_legacy_cache:
122PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
123{
b847cbdc
JO
124 struct list_head *list = NULL;
125
126 ABORT_ON(parse_events_add_cache(&list, idx, $1, $3, $5));
127 $$ = list;
89812fc8
JO
128}
129|
130PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
131{
b847cbdc
JO
132 struct list_head *list = NULL;
133
134 ABORT_ON(parse_events_add_cache(&list, idx, $1, $3, NULL));
135 $$ = list;
89812fc8
JO
136}
137|
138PE_NAME_CACHE_TYPE
139{
b847cbdc
JO
140 struct list_head *list = NULL;
141
142 ABORT_ON(parse_events_add_cache(&list, idx, $1, NULL, NULL));
143 $$ = list;
89812fc8
JO
144}
145
146event_legacy_mem:
147PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
148{
b847cbdc
JO
149 struct list_head *list = NULL;
150
151 ABORT_ON(parse_events_add_breakpoint(&list, idx, (void *) $2, $4));
152 $$ = list;
89812fc8
JO
153}
154|
155PE_PREFIX_MEM PE_VALUE sep_dc
156{
b847cbdc
JO
157 struct list_head *list = NULL;
158
159 ABORT_ON(parse_events_add_breakpoint(&list, idx, (void *) $2, NULL));
160 $$ = list;
89812fc8
JO
161}
162
163event_legacy_tracepoint:
164PE_NAME ':' PE_NAME
165{
b847cbdc
JO
166 struct list_head *list = NULL;
167
168 ABORT_ON(parse_events_add_tracepoint(&list, idx, $1, $3));
169 $$ = list;
89812fc8
JO
170}
171
172event_legacy_numeric:
173PE_VALUE ':' PE_VALUE
174{
b847cbdc
JO
175 struct list_head *list = NULL;
176
177 ABORT_ON(parse_events_add_numeric(&list, idx, $1, $3, NULL));
178 $$ = list;
89812fc8
JO
179}
180
181event_legacy_raw:
182PE_RAW
183{
b847cbdc
JO
184 struct list_head *list = NULL;
185
186 ABORT_ON(parse_events_add_numeric(&list, idx, PERF_TYPE_RAW, $1, NULL));
187 $$ = list;
8f707d84
JO
188}
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
16fa7e82
JO
217 ABORT_ON(parse_events__term_str(&term, PARSE_EVENTS__TERM_TYPE_USER,
218 $1, $3));
8f707d84
JO
219 $$ = term;
220}
221|
222PE_NAME '=' PE_VALUE
223{
224 struct parse_events__term *term;
225
16fa7e82
JO
226 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
227 $1, $3));
8f707d84
JO
228 $$ = term;
229}
230|
231PE_NAME
232{
233 struct parse_events__term *term;
234
16fa7e82
JO
235 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
236 $1, 1));
8f707d84
JO
237 $$ = term;
238}
239|
6b5fc39b
JO
240PE_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|
8f707d84
JO
248PE_TERM '=' PE_VALUE
249{
250 struct parse_events__term *term;
251
16fa7e82 252 ABORT_ON(parse_events__term_num(&term, $1, NULL, $3));
8f707d84
JO
253 $$ = term;
254}
255|
256PE_TERM
257{
258 struct parse_events__term *term;
259
16fa7e82 260 ABORT_ON(parse_events__term_num(&term, $1, NULL, 1));
8f707d84 261 $$ = term;
89812fc8
JO
262}
263
264sep_dc: ':' |
265
8f707d84
JO
266sep_slash_dc: '/' | ':' |
267
89812fc8
JO
268%%
269
5d7be90e 270void parse_events_error(struct list_head *list_all __used,
5d7be90e 271 int *idx __used,
89812fc8
JO
272 char const *msg __used)
273{
274}