perf tools: Add support for displaying event parser debug info
[deliverable/linux.git] / tools / perf / util / parse-events.y
CommitLineData
89812fc8
JO
1
2%name-prefix "parse_events_"
5d7be90e
JO
3%parse-param {struct list_head *list_all}
4%parse-param {struct list_head *list_event}
89812fc8
JO
5%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
8f707d84 27%token PE_VALUE PE_VALUE_SYM PE_RAW PE_TERM
89812fc8
JO
28%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
8f707d84 36%type <num> PE_TERM
89812fc8
JO
37%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
8f707d84
JO
42%type <head> event_config
43%type <term> event_term
89812fc8
JO
44
45%union
46{
47 char *str;
48 unsigned long num;
8f707d84
JO
49 struct list_head *head;
50 struct parse_events__term *term;
89812fc8
JO
51}
52%%
53
54events:
55events ',' event | event
56
57event:
58event_def PE_MODIFIER_EVENT
59{
5d7be90e
JO
60 /*
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);
89812fc8
JO
67}
68|
69event_def
5d7be90e
JO
70{
71 parse_events_update_lists(list_event, list_all);
72}
89812fc8 73
5f537a26
JO
74event_def: event_pmu |
75 event_legacy_symbol |
89812fc8
JO
76 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
5f537a26
JO
82event_pmu:
83PE_NAME '/' event_config '/'
84{
5d7be90e 85 ABORT_ON(parse_events_add_pmu(list_event, idx, $1, $3));
5f537a26
JO
86 parse_events__free_terms($3);
87}
88
89812fc8 89event_legacy_symbol:
8f707d84 90PE_VALUE_SYM '/' event_config '/'
89812fc8
JO
91{
92 int type = $1 >> 16;
93 int config = $1 & 255;
94
5d7be90e 95 ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, $3));
8f707d84
JO
96 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
5d7be90e 104 ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, NULL));
89812fc8
JO
105}
106
107event_legacy_cache:
108PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
109{
5d7be90e 110 ABORT_ON(parse_events_add_cache(list_event, idx, $1, $3, $5));
89812fc8
JO
111}
112|
113PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
114{
5d7be90e 115 ABORT_ON(parse_events_add_cache(list_event, idx, $1, $3, NULL));
89812fc8
JO
116}
117|
118PE_NAME_CACHE_TYPE
119{
5d7be90e 120 ABORT_ON(parse_events_add_cache(list_event, idx, $1, NULL, NULL));
89812fc8
JO
121}
122
123event_legacy_mem:
124PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
125{
5d7be90e 126 ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) $2, $4));
89812fc8
JO
127}
128|
129PE_PREFIX_MEM PE_VALUE sep_dc
130{
5d7be90e 131 ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) $2, NULL));
89812fc8
JO
132}
133
134event_legacy_tracepoint:
135PE_NAME ':' PE_NAME
136{
5d7be90e 137 ABORT_ON(parse_events_add_tracepoint(list_event, idx, $1, $3));
89812fc8
JO
138}
139
140event_legacy_numeric:
141PE_VALUE ':' PE_VALUE
142{
5d7be90e 143 ABORT_ON(parse_events_add_numeric(list_event, idx, $1, $3, NULL));
89812fc8
JO
144}
145
146event_legacy_raw:
147PE_RAW
148{
5d7be90e 149 ABORT_ON(parse_events_add_numeric(list_event, idx, PERF_TYPE_RAW, $1, NULL));
8f707d84
JO
150}
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
16fa7e82
JO
179 ABORT_ON(parse_events__term_str(&term, PARSE_EVENTS__TERM_TYPE_USER,
180 $1, $3));
8f707d84
JO
181 $$ = term;
182}
183|
184PE_NAME '=' PE_VALUE
185{
186 struct parse_events__term *term;
187
16fa7e82
JO
188 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
189 $1, $3));
8f707d84
JO
190 $$ = term;
191}
192|
193PE_NAME
194{
195 struct parse_events__term *term;
196
16fa7e82
JO
197 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
198 $1, 1));
8f707d84
JO
199 $$ = term;
200}
201|
202PE_TERM '=' PE_VALUE
203{
204 struct parse_events__term *term;
205
16fa7e82 206 ABORT_ON(parse_events__term_num(&term, $1, NULL, $3));
8f707d84
JO
207 $$ = term;
208}
209|
210PE_TERM
211{
212 struct parse_events__term *term;
213
16fa7e82 214 ABORT_ON(parse_events__term_num(&term, $1, NULL, 1));
8f707d84 215 $$ = term;
89812fc8
JO
216}
217
218sep_dc: ':' |
219
8f707d84
JO
220sep_slash_dc: '/' | ':' |
221
89812fc8
JO
222%%
223
5d7be90e
JO
224void parse_events_error(struct list_head *list_all __used,
225 struct list_head *list_event __used,
226 int *idx __used,
89812fc8
JO
227 char const *msg __used)
228{
229}
This page took 0.037839 seconds and 5 git commands to generate.