blob: 3f35ea3f5047d71e01933666b16606e3554aa66a [file] [log] [blame]
Jiri Olsa89812fc2012-03-15 20:09:15 +01001
Jiri Olsa5d7be902012-03-20 19:15:40 +01002%parse-param {struct list_head *list_all}
3%parse-param {struct list_head *list_event}
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 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{
Jiri Olsa5d7be902012-03-20 19:15:40 +010059 /*
60 * Apply modifier on all events added by single event definition
61 * (there could be more events added for multiple tracepoint
62 * definitions via '*?'.
63 */
64 ABORT_ON(parse_events_modifier(list_event, $2));
65 parse_events_update_lists(list_event, list_all);
Jiri Olsa89812fc2012-03-15 20:09:15 +010066}
67|
68event_def
Jiri Olsa5d7be902012-03-20 19:15:40 +010069{
70 parse_events_update_lists(list_event, list_all);
71}
Jiri Olsa89812fc2012-03-15 20:09:15 +010072
Jiri Olsa5f537a22012-03-15 20:09:18 +010073event_def: event_pmu |
74 event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +010075 event_legacy_cache sep_dc |
76 event_legacy_mem |
77 event_legacy_tracepoint sep_dc |
78 event_legacy_numeric sep_dc |
79 event_legacy_raw sep_dc
80
Jiri Olsa5f537a22012-03-15 20:09:18 +010081event_pmu:
82PE_NAME '/' event_config '/'
83{
Jiri Olsa5d7be902012-03-20 19:15:40 +010084 ABORT_ON(parse_events_add_pmu(list_event, idx, $1, $3));
Jiri Olsa5f537a22012-03-15 20:09:18 +010085 parse_events__free_terms($3);
86}
87
Jiri Olsa89812fc2012-03-15 20:09:15 +010088event_legacy_symbol:
Jiri Olsa8f707d82012-03-15 20:09:16 +010089PE_VALUE_SYM '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +010090{
91 int type = $1 >> 16;
92 int config = $1 & 255;
93
Jiri Olsa5d7be902012-03-20 19:15:40 +010094 ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +010095 parse_events__free_terms($3);
96}
97|
98PE_VALUE_SYM sep_slash_dc
99{
100 int type = $1 >> 16;
101 int config = $1 & 255;
102
Jiri Olsa5d7be902012-03-20 19:15:40 +0100103 ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100104}
105
106event_legacy_cache:
107PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
108{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100109 ABORT_ON(parse_events_add_cache(list_event, idx, $1, $3, $5));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100110}
111|
112PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
113{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100114 ABORT_ON(parse_events_add_cache(list_event, idx, $1, $3, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100115}
116|
117PE_NAME_CACHE_TYPE
118{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100119 ABORT_ON(parse_events_add_cache(list_event, idx, $1, NULL, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100120}
121
122event_legacy_mem:
123PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
124{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100125 ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) $2, $4));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100126}
127|
128PE_PREFIX_MEM PE_VALUE sep_dc
129{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100130 ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) $2, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100131}
132
133event_legacy_tracepoint:
134PE_NAME ':' PE_NAME
135{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100136 ABORT_ON(parse_events_add_tracepoint(list_event, idx, $1, $3));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100137}
138
139event_legacy_numeric:
140PE_VALUE ':' PE_VALUE
141{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100142 ABORT_ON(parse_events_add_numeric(list_event, idx, $1, $3, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100143}
144
145event_legacy_raw:
146PE_RAW
147{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100148 ABORT_ON(parse_events_add_numeric(list_event, idx, PERF_TYPE_RAW, $1, NULL));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100149}
150
151event_config:
152event_config ',' event_term
153{
154 struct list_head *head = $1;
155 struct parse_events__term *term = $3;
156
157 ABORT_ON(!head);
158 list_add_tail(&term->list, head);
159 $$ = $1;
160}
161|
162event_term
163{
164 struct list_head *head = malloc(sizeof(*head));
165 struct parse_events__term *term = $1;
166
167 ABORT_ON(!head);
168 INIT_LIST_HEAD(head);
169 list_add_tail(&term->list, head);
170 $$ = head;
171}
172
173event_term:
174PE_NAME '=' PE_NAME
175{
176 struct parse_events__term *term;
177
178 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_STR,
179 $1, $3, 0));
180 $$ = term;
181}
182|
183PE_NAME '=' PE_VALUE
184{
185 struct parse_events__term *term;
186
187 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM,
188 $1, NULL, $3));
189 $$ = term;
190}
191|
192PE_NAME
193{
194 struct parse_events__term *term;
195
196 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM,
197 $1, NULL, 1));
198 $$ = term;
199}
200|
201PE_TERM '=' PE_VALUE
202{
203 struct parse_events__term *term;
204
205 ABORT_ON(parse_events__new_term(&term, $1, NULL, NULL, $3));
206 $$ = term;
207}
208|
209PE_TERM
210{
211 struct parse_events__term *term;
212
213 ABORT_ON(parse_events__new_term(&term, $1, NULL, NULL, 1));
214 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100215}
216
217sep_dc: ':' |
218
Jiri Olsa8f707d82012-03-15 20:09:16 +0100219sep_slash_dc: '/' | ':' |
220
Jiri Olsa89812fc2012-03-15 20:09:15 +0100221%%
222
Jiri Olsa5d7be902012-03-20 19:15:40 +0100223void parse_events_error(struct list_head *list_all __used,
224 struct list_head *list_event __used,
225 int *idx __used,
Jiri Olsa89812fc2012-03-15 20:09:15 +0100226 char const *msg __used)
227{
228}