blob: 936913ea0ab6a67344aa56a59900b35fd569e4fb [file] [log] [blame]
Jiri Olsa89812fc2012-03-15 20:09:15 +01001
2%name-prefix "parse_events_"
Jiri Olsa5d7be902012-03-20 19:15:40 +01003%parse-param {struct list_head *list_all}
4%parse-param {struct list_head *list_event}
Jiri Olsa89812fc2012-03-15 20:09:15 +01005%parse-param {int *idx}
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"
16
17extern int parse_events_lex (void);
18
19#define ABORT_ON(val) \
20do { \
21 if (val) \
22 YYABORT; \
23} while (0)
24
25%}
26
Jiri Olsa8f707d82012-03-15 20:09:16 +010027%token PE_VALUE PE_VALUE_SYM PE_RAW PE_TERM
Jiri Olsa89812fc2012-03-15 20:09:15 +010028%token PE_NAME
29%token PE_MODIFIER_EVENT PE_MODIFIER_BP
30%token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
31%token PE_PREFIX_MEM PE_PREFIX_RAW
32%token PE_ERROR
33%type <num> PE_VALUE
34%type <num> PE_VALUE_SYM
35%type <num> PE_RAW
Jiri Olsa8f707d82012-03-15 20:09:16 +010036%type <num> PE_TERM
Jiri Olsa89812fc2012-03-15 20:09:15 +010037%type <str> PE_NAME
38%type <str> PE_NAME_CACHE_TYPE
39%type <str> PE_NAME_CACHE_OP_RESULT
40%type <str> PE_MODIFIER_EVENT
41%type <str> PE_MODIFIER_BP
Jiri Olsa8f707d82012-03-15 20:09:16 +010042%type <head> event_config
43%type <term> event_term
Jiri Olsa89812fc2012-03-15 20:09:15 +010044
45%union
46{
47 char *str;
48 unsigned long num;
Jiri Olsa8f707d82012-03-15 20:09:16 +010049 struct list_head *head;
50 struct parse_events__term *term;
Jiri Olsa89812fc2012-03-15 20:09:15 +010051}
52%%
53
54events:
55events ',' event | event
56
57event:
58event_def PE_MODIFIER_EVENT
59{
Jiri Olsa5d7be902012-03-20 19:15:40 +010060 /*
61 * Apply modifier on all events added by single event definition
62 * (there could be more events added for multiple tracepoint
63 * definitions via '*?'.
64 */
65 ABORT_ON(parse_events_modifier(list_event, $2));
66 parse_events_update_lists(list_event, list_all);
Jiri Olsa89812fc2012-03-15 20:09:15 +010067}
68|
69event_def
Jiri Olsa5d7be902012-03-20 19:15:40 +010070{
71 parse_events_update_lists(list_event, list_all);
72}
Jiri Olsa89812fc2012-03-15 20:09:15 +010073
Jiri Olsa5f537a22012-03-15 20:09:18 +010074event_def: event_pmu |
75 event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +010076 event_legacy_cache sep_dc |
77 event_legacy_mem |
78 event_legacy_tracepoint sep_dc |
79 event_legacy_numeric sep_dc |
80 event_legacy_raw sep_dc
81
Jiri Olsa5f537a22012-03-15 20:09:18 +010082event_pmu:
83PE_NAME '/' event_config '/'
84{
Jiri Olsa5d7be902012-03-20 19:15:40 +010085 ABORT_ON(parse_events_add_pmu(list_event, idx, $1, $3));
Jiri Olsa5f537a22012-03-15 20:09:18 +010086 parse_events__free_terms($3);
87}
88
Jiri Olsa89812fc2012-03-15 20:09:15 +010089event_legacy_symbol:
Jiri Olsa8f707d82012-03-15 20:09:16 +010090PE_VALUE_SYM '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +010091{
92 int type = $1 >> 16;
93 int config = $1 & 255;
94
Jiri Olsa5d7be902012-03-20 19:15:40 +010095 ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +010096 parse_events__free_terms($3);
97}
98|
99PE_VALUE_SYM sep_slash_dc
100{
101 int type = $1 >> 16;
102 int config = $1 & 255;
103
Jiri Olsa5d7be902012-03-20 19:15:40 +0100104 ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100105}
106
107event_legacy_cache:
108PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
109{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100110 ABORT_ON(parse_events_add_cache(list_event, idx, $1, $3, $5));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100111}
112|
113PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
114{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100115 ABORT_ON(parse_events_add_cache(list_event, idx, $1, $3, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100116}
117|
118PE_NAME_CACHE_TYPE
119{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100120 ABORT_ON(parse_events_add_cache(list_event, idx, $1, NULL, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100121}
122
123event_legacy_mem:
124PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
125{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100126 ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) $2, $4));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100127}
128|
129PE_PREFIX_MEM PE_VALUE sep_dc
130{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100131 ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) $2, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100132}
133
134event_legacy_tracepoint:
135PE_NAME ':' PE_NAME
136{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100137 ABORT_ON(parse_events_add_tracepoint(list_event, idx, $1, $3));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100138}
139
140event_legacy_numeric:
141PE_VALUE ':' PE_VALUE
142{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100143 ABORT_ON(parse_events_add_numeric(list_event, idx, $1, $3, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100144}
145
146event_legacy_raw:
147PE_RAW
148{
Jiri Olsa5d7be902012-03-20 19:15:40 +0100149 ABORT_ON(parse_events_add_numeric(list_event, idx, PERF_TYPE_RAW, $1, NULL));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100150}
151
152event_config:
153event_config ',' event_term
154{
155 struct list_head *head = $1;
156 struct parse_events__term *term = $3;
157
158 ABORT_ON(!head);
159 list_add_tail(&term->list, head);
160 $$ = $1;
161}
162|
163event_term
164{
165 struct list_head *head = malloc(sizeof(*head));
166 struct parse_events__term *term = $1;
167
168 ABORT_ON(!head);
169 INIT_LIST_HEAD(head);
170 list_add_tail(&term->list, head);
171 $$ = head;
172}
173
174event_term:
175PE_NAME '=' PE_NAME
176{
177 struct parse_events__term *term;
178
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200179 ABORT_ON(parse_events__term_str(&term, PARSE_EVENTS__TERM_TYPE_USER,
180 $1, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100181 $$ = term;
182}
183|
184PE_NAME '=' PE_VALUE
185{
186 struct parse_events__term *term;
187
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200188 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
189 $1, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100190 $$ = term;
191}
192|
193PE_NAME
194{
195 struct parse_events__term *term;
196
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200197 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
198 $1, 1));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100199 $$ = term;
200}
201|
202PE_TERM '=' PE_VALUE
203{
204 struct parse_events__term *term;
205
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200206 ABORT_ON(parse_events__term_num(&term, $1, NULL, $3));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100207 $$ = term;
208}
209|
210PE_TERM
211{
212 struct parse_events__term *term;
213
Jiri Olsa16fa7e82012-04-25 18:24:57 +0200214 ABORT_ON(parse_events__term_num(&term, $1, NULL, 1));
Jiri Olsa8f707d82012-03-15 20:09:16 +0100215 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100216}
217
218sep_dc: ':' |
219
Jiri Olsa8f707d82012-03-15 20:09:16 +0100220sep_slash_dc: '/' | ':' |
221
Jiri Olsa89812fc2012-03-15 20:09:15 +0100222%%
223
Jiri Olsa5d7be902012-03-20 19:15:40 +0100224void parse_events_error(struct list_head *list_all __used,
225 struct list_head *list_event __used,
226 int *idx __used,
Jiri Olsa89812fc2012-03-15 20:09:15 +0100227 char const *msg __used)
228{
229}