blob: 3a530193f5a8065cf4d95bb8e5c659a4693e131d [file] [log] [blame]
Jiri Olsa89812fc2012-03-15 20:09:15 +01001
2%name-prefix "parse_events_"
3%parse-param {struct list_head *list}
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
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 Olsa89812fc2012-03-15 20:09:15 +010043
44%union
45{
46 char *str;
47 unsigned long num;
Jiri Olsa8f707d82012-03-15 20:09:16 +010048 struct list_head *head;
49 struct parse_events__term *term;
Jiri Olsa89812fc2012-03-15 20:09:15 +010050}
51%%
52
53events:
54events ',' event | event
55
56event:
57event_def PE_MODIFIER_EVENT
58{
59 ABORT_ON(parse_events_modifier(list, $2));
60}
61|
62event_def
63
Jiri Olsa5f537a22012-03-15 20:09:18 +010064event_def: event_pmu |
65 event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +010066 event_legacy_cache sep_dc |
67 event_legacy_mem |
68 event_legacy_tracepoint sep_dc |
69 event_legacy_numeric sep_dc |
70 event_legacy_raw sep_dc
71
Jiri Olsa5f537a22012-03-15 20:09:18 +010072event_pmu:
73PE_NAME '/' event_config '/'
74{
75 ABORT_ON(parse_events_add_pmu(list, idx, $1, $3));
76 parse_events__free_terms($3);
77}
78
Jiri Olsa89812fc2012-03-15 20:09:15 +010079event_legacy_symbol:
Jiri Olsa8f707d82012-03-15 20:09:16 +010080PE_VALUE_SYM '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +010081{
82 int type = $1 >> 16;
83 int config = $1 & 255;
84
Jiri Olsa8f707d82012-03-15 20:09:16 +010085 ABORT_ON(parse_events_add_numeric(list, idx, type, config, $3));
86 parse_events__free_terms($3);
87}
88|
89PE_VALUE_SYM sep_slash_dc
90{
91 int type = $1 >> 16;
92 int config = $1 & 255;
93
94 ABORT_ON(parse_events_add_numeric(list, idx, type, config, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +010095}
96
97event_legacy_cache:
98PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
99{
100 ABORT_ON(parse_events_add_cache(list, idx, $1, $3, $5));
101}
102|
103PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
104{
105 ABORT_ON(parse_events_add_cache(list, idx, $1, $3, NULL));
106}
107|
108PE_NAME_CACHE_TYPE
109{
110 ABORT_ON(parse_events_add_cache(list, idx, $1, NULL, NULL));
111}
112
113event_legacy_mem:
114PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
115{
116 ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) $2, $4));
117}
118|
119PE_PREFIX_MEM PE_VALUE sep_dc
120{
121 ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) $2, NULL));
122}
123
124event_legacy_tracepoint:
125PE_NAME ':' PE_NAME
126{
127 ABORT_ON(parse_events_add_tracepoint(list, idx, $1, $3));
128}
129
130event_legacy_numeric:
131PE_VALUE ':' PE_VALUE
132{
Jiri Olsa8f707d82012-03-15 20:09:16 +0100133 ABORT_ON(parse_events_add_numeric(list, idx, $1, $3, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100134}
135
136event_legacy_raw:
137PE_RAW
138{
Jiri Olsa8f707d82012-03-15 20:09:16 +0100139 ABORT_ON(parse_events_add_numeric(list, idx, PERF_TYPE_RAW, $1, NULL));
140}
141
142event_config:
143event_config ',' event_term
144{
145 struct list_head *head = $1;
146 struct parse_events__term *term = $3;
147
148 ABORT_ON(!head);
149 list_add_tail(&term->list, head);
150 $$ = $1;
151}
152|
153event_term
154{
155 struct list_head *head = malloc(sizeof(*head));
156 struct parse_events__term *term = $1;
157
158 ABORT_ON(!head);
159 INIT_LIST_HEAD(head);
160 list_add_tail(&term->list, head);
161 $$ = head;
162}
163
164event_term:
165PE_NAME '=' PE_NAME
166{
167 struct parse_events__term *term;
168
169 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_STR,
170 $1, $3, 0));
171 $$ = term;
172}
173|
174PE_NAME '=' PE_VALUE
175{
176 struct parse_events__term *term;
177
178 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM,
179 $1, NULL, $3));
180 $$ = term;
181}
182|
183PE_NAME
184{
185 struct parse_events__term *term;
186
187 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM,
188 $1, NULL, 1));
189 $$ = term;
190}
191|
192PE_TERM '=' PE_VALUE
193{
194 struct parse_events__term *term;
195
196 ABORT_ON(parse_events__new_term(&term, $1, NULL, NULL, $3));
197 $$ = term;
198}
199|
200PE_TERM
201{
202 struct parse_events__term *term;
203
204 ABORT_ON(parse_events__new_term(&term, $1, NULL, NULL, 1));
205 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100206}
207
208sep_dc: ':' |
209
Jiri Olsa8f707d82012-03-15 20:09:16 +0100210sep_slash_dc: '/' | ':' |
211
Jiri Olsa89812fc2012-03-15 20:09:15 +0100212%%
213
214void parse_events_error(struct list_head *list __used, int *idx __used,
215 char const *msg __used)
216{
217}