blob: 936faa5fcc37950d2abe01a4d4e85fa1e2e3c3c3 [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
Ashwin Chauguleb33e8252012-06-13 15:29:23 -040026%token PE_VALUE PE_VALUE_SYM PE_RAW PE_SH_RAW PE_FAB_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
Ashwin Chauguleb33e8252012-06-13 15:29:23 -040035%type <num> PE_SH_RAW
36%type <num> PE_FAB_RAW
Jiri Olsa8f707d82012-03-15 20:09:16 +010037%type <num> PE_TERM
Jiri Olsa89812fc2012-03-15 20:09:15 +010038%type <str> PE_NAME
39%type <str> PE_NAME_CACHE_TYPE
40%type <str> PE_NAME_CACHE_OP_RESULT
41%type <str> PE_MODIFIER_EVENT
42%type <str> PE_MODIFIER_BP
Jiri Olsa8f707d82012-03-15 20:09:16 +010043%type <head> event_config
44%type <term> event_term
Jiri Olsa89812fc2012-03-15 20:09:15 +010045
46%union
47{
48 char *str;
49 unsigned long num;
Jiri Olsa8f707d82012-03-15 20:09:16 +010050 struct list_head *head;
51 struct parse_events__term *term;
Jiri Olsa89812fc2012-03-15 20:09:15 +010052}
53%%
54
55events:
56events ',' event | event
57
58event:
59event_def PE_MODIFIER_EVENT
60{
Jiri Olsa5d7be902012-03-20 19:15:40 +010061 /*
62 * Apply modifier on all events added by single event definition
63 * (there could be more events added for multiple tracepoint
64 * definitions via '*?'.
65 */
66 ABORT_ON(parse_events_modifier(list_event, $2));
67 parse_events_update_lists(list_event, list_all);
Jiri Olsa89812fc2012-03-15 20:09:15 +010068}
69|
70event_def
Jiri Olsa5d7be902012-03-20 19:15:40 +010071{
72 parse_events_update_lists(list_event, list_all);
73}
Jiri Olsa89812fc2012-03-15 20:09:15 +010074
Jiri Olsa5f537a22012-03-15 20:09:18 +010075event_def: event_pmu |
76 event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +010077 event_legacy_cache sep_dc |
78 event_legacy_mem |
79 event_legacy_tracepoint sep_dc |
80 event_legacy_numeric sep_dc |
Ashwin Chauguleb33e8252012-06-13 15:29:23 -040081 event_legacy_raw sep_dc |
82 event_legacy_shared_raw sep_dc |
83 event_legacy_fabric_raw sep_dc
Jiri Olsa89812fc2012-03-15 20:09:15 +010084
Jiri Olsa5f537a22012-03-15 20:09:18 +010085event_pmu:
86PE_NAME '/' event_config '/'
87{
Jiri Olsa5d7be902012-03-20 19:15:40 +010088 ABORT_ON(parse_events_add_pmu(list_event, idx, $1, $3));
Jiri Olsa5f537a22012-03-15 20:09:18 +010089 parse_events__free_terms($3);
90}
91
Jiri Olsa89812fc2012-03-15 20:09:15 +010092event_legacy_symbol:
Jiri Olsa8f707d82012-03-15 20:09:16 +010093PE_VALUE_SYM '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +010094{
95 int type = $1 >> 16;
96 int config = $1 & 255;
97
Jiri Olsa5d7be902012-03-20 19:15:40 +010098 ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +010099 parse_events__free_terms($3);
100}
101|
102PE_VALUE_SYM sep_slash_dc
103{
104 int type = $1 >> 16;
105 int config = $1 & 255;
106
Jiri Olsa5d7be902012-03-20 19:15:40 +0100107 ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100108}
109
110event_legacy_cache:
111PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
112{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100113 ABORT_ON(parse_events_add_cache(list_event, idx, $1, $3, $5));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100114}
115|
116PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
117{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100118 ABORT_ON(parse_events_add_cache(list_event, idx, $1, $3, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100119}
120|
121PE_NAME_CACHE_TYPE
122{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100123 ABORT_ON(parse_events_add_cache(list_event, idx, $1, NULL, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100124}
125
126event_legacy_mem:
127PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
128{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100129 ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) $2, $4));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100130}
131|
132PE_PREFIX_MEM PE_VALUE sep_dc
133{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100134 ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) $2, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100135}
136
137event_legacy_tracepoint:
138PE_NAME ':' PE_NAME
139{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100140 ABORT_ON(parse_events_add_tracepoint(list_event, idx, $1, $3));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100141}
142
143event_legacy_numeric:
144PE_VALUE ':' PE_VALUE
145{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100146 ABORT_ON(parse_events_add_numeric(list_event, idx, $1, $3, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100147}
148
149event_legacy_raw:
150PE_RAW
151{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100152 ABORT_ON(parse_events_add_numeric(list_event, idx, PERF_TYPE_RAW, $1, NULL));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100153}
154
Ashwin Chauguleb33e8252012-06-13 15:29:23 -0400155event_legacy_shared_raw:
156PE_SH_RAW
157{
Ashwin Chaugulef4a533d2012-07-19 18:27:03 -0400158 ABORT_ON(parse_events_add_numeric_legacy(list_event, idx, "msm-l2", $1, NULL));
Ashwin Chauguleb33e8252012-06-13 15:29:23 -0400159}
160
161event_legacy_fabric_raw:
162PE_FAB_RAW
163{
Ashwin Chaugulef4a533d2012-07-19 18:27:03 -0400164 ABORT_ON(parse_events_add_numeric_legacy(list_event, idx, "msm-busmon", $1, NULL));
Ashwin Chauguleb33e8252012-06-13 15:29:23 -0400165}
166
Jiri Olsa8f707d82012-03-15 20:09:16 +0100167event_config:
168event_config ',' event_term
169{
170 struct list_head *head = $1;
171 struct parse_events__term *term = $3;
172
173 ABORT_ON(!head);
174 list_add_tail(&term->list, head);
175 $$ = $1;
176}
177|
178event_term
179{
180 struct list_head *head = malloc(sizeof(*head));
181 struct parse_events__term *term = $1;
182
183 ABORT_ON(!head);
184 INIT_LIST_HEAD(head);
185 list_add_tail(&term->list, head);
186 $$ = head;
187}
188
189event_term:
190PE_NAME '=' PE_NAME
191{
192 struct parse_events__term *term;
193
194 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_STR,
195 $1, $3, 0));
196 $$ = term;
197}
198|
199PE_NAME '=' PE_VALUE
200{
201 struct parse_events__term *term;
202
203 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM,
204 $1, NULL, $3));
205 $$ = term;
206}
207|
208PE_NAME
209{
210 struct parse_events__term *term;
211
212 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM,
213 $1, NULL, 1));
214 $$ = term;
215}
216|
217PE_TERM '=' PE_VALUE
218{
219 struct parse_events__term *term;
220
221 ABORT_ON(parse_events__new_term(&term, $1, NULL, NULL, $3));
222 $$ = term;
223}
224|
225PE_TERM
226{
227 struct parse_events__term *term;
228
229 ABORT_ON(parse_events__new_term(&term, $1, NULL, NULL, 1));
230 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100231}
232
233sep_dc: ':' |
234
Jiri Olsa8f707d82012-03-15 20:09:16 +0100235sep_slash_dc: '/' | ':' |
236
Jiri Olsa89812fc2012-03-15 20:09:15 +0100237%%
238
Jiri Olsa5d7be902012-03-20 19:15:40 +0100239void parse_events_error(struct list_head *list_all __used,
240 struct list_head *list_event __used,
241 int *idx __used,
Jiri Olsa89812fc2012-03-15 20:09:15 +0100242 char const *msg __used)
243{
244}