blob: c88c08e4e79d928d998f05a4d331878d181ea936 [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 Olsa8f707d82012-03-15 20:09:16 +010064event_def: event_legacy_symbol |
Jiri Olsa89812fc2012-03-15 20:09:15 +010065 event_legacy_cache sep_dc |
66 event_legacy_mem |
67 event_legacy_tracepoint sep_dc |
68 event_legacy_numeric sep_dc |
69 event_legacy_raw sep_dc
70
71event_legacy_symbol:
Jiri Olsa8f707d82012-03-15 20:09:16 +010072PE_VALUE_SYM '/' event_config '/'
Jiri Olsa89812fc2012-03-15 20:09:15 +010073{
74 int type = $1 >> 16;
75 int config = $1 & 255;
76
Jiri Olsa8f707d82012-03-15 20:09:16 +010077 ABORT_ON(parse_events_add_numeric(list, idx, type, config, $3));
78 parse_events__free_terms($3);
79}
80|
81PE_VALUE_SYM sep_slash_dc
82{
83 int type = $1 >> 16;
84 int config = $1 & 255;
85
86 ABORT_ON(parse_events_add_numeric(list, idx, type, config, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +010087}
88
89event_legacy_cache:
90PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
91{
92 ABORT_ON(parse_events_add_cache(list, idx, $1, $3, $5));
93}
94|
95PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
96{
97 ABORT_ON(parse_events_add_cache(list, idx, $1, $3, NULL));
98}
99|
100PE_NAME_CACHE_TYPE
101{
102 ABORT_ON(parse_events_add_cache(list, idx, $1, NULL, NULL));
103}
104
105event_legacy_mem:
106PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
107{
108 ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) $2, $4));
109}
110|
111PE_PREFIX_MEM PE_VALUE sep_dc
112{
113 ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) $2, NULL));
114}
115
116event_legacy_tracepoint:
117PE_NAME ':' PE_NAME
118{
119 ABORT_ON(parse_events_add_tracepoint(list, idx, $1, $3));
120}
121
122event_legacy_numeric:
123PE_VALUE ':' PE_VALUE
124{
Jiri Olsa8f707d82012-03-15 20:09:16 +0100125 ABORT_ON(parse_events_add_numeric(list, idx, $1, $3, NULL));
Jiri Olsa89812fc2012-03-15 20:09:15 +0100126}
127
128event_legacy_raw:
129PE_RAW
130{
Jiri Olsa8f707d82012-03-15 20:09:16 +0100131 ABORT_ON(parse_events_add_numeric(list, idx, PERF_TYPE_RAW, $1, NULL));
132}
133
134event_config:
135event_config ',' event_term
136{
137 struct list_head *head = $1;
138 struct parse_events__term *term = $3;
139
140 ABORT_ON(!head);
141 list_add_tail(&term->list, head);
142 $$ = $1;
143}
144|
145event_term
146{
147 struct list_head *head = malloc(sizeof(*head));
148 struct parse_events__term *term = $1;
149
150 ABORT_ON(!head);
151 INIT_LIST_HEAD(head);
152 list_add_tail(&term->list, head);
153 $$ = head;
154}
155
156event_term:
157PE_NAME '=' PE_NAME
158{
159 struct parse_events__term *term;
160
161 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_STR,
162 $1, $3, 0));
163 $$ = term;
164}
165|
166PE_NAME '=' PE_VALUE
167{
168 struct parse_events__term *term;
169
170 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM,
171 $1, NULL, $3));
172 $$ = term;
173}
174|
175PE_NAME
176{
177 struct parse_events__term *term;
178
179 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM,
180 $1, NULL, 1));
181 $$ = term;
182}
183|
184PE_TERM '=' PE_VALUE
185{
186 struct parse_events__term *term;
187
188 ABORT_ON(parse_events__new_term(&term, $1, NULL, NULL, $3));
189 $$ = term;
190}
191|
192PE_TERM
193{
194 struct parse_events__term *term;
195
196 ABORT_ON(parse_events__new_term(&term, $1, NULL, NULL, 1));
197 $$ = term;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100198}
199
200sep_dc: ':' |
201
Jiri Olsa8f707d82012-03-15 20:09:16 +0100202sep_slash_dc: '/' | ':' |
203
Jiri Olsa89812fc2012-03-15 20:09:15 +0100204%%
205
206void parse_events_error(struct list_head *list __used, int *idx __used,
207 char const *msg __used)
208{
209}