2 %parse
-param
{void *_data
}
3 %parse
-param
{void *scanner
}
4 %lex
-param
{void* scanner
}
10 #include <linux/compiler.h>
11 #include <linux/list.h>
12 #include <linux/types.h>
14 #include "parse-events.h"
15 #include "parse-events-bison.h"
17 extern
int parse_events_lex
(YYSTYPE* lvalp
, void* scanner
);
19 #define ABORT_ON(val) \
25 #define ALLOC_LIST(list) \
27 list
= malloc
(sizeof
(*list
)); \
29 INIT_LIST_HEAD
(list
); \
32 static inc_group_count
(struct list_head
*list
,
33 struct parse_events_evlist
*data
)
35 /* Count groups only have more than 1 members */
36 if
(!list_is_last
(list
->next
, list
))
42 %token PE_START_EVENTS PE_START_TERMS
43 %token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM
46 %token PE_MODIFIER_EVENT PE_MODIFIER_BP
47 %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
48 %token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP
51 %type
<num
> PE_VALUE_SYM_HW
52 %type
<num
> PE_VALUE_SYM_SW
56 %type
<str
> PE_NAME_CACHE_TYPE
57 %type
<str
> PE_NAME_CACHE_OP_RESULT
58 %type
<str
> PE_MODIFIER_EVENT
59 %type
<str
> PE_MODIFIER_BP
60 %type
<str
> PE_EVENT_NAME
62 %type
<head
> event_config
63 %type
<term
> event_term
64 %type
<head
> event_pmu
65 %type
<head
> event_legacy_symbol
66 %type
<head
> event_legacy_cache
67 %type
<head
> event_legacy_mem
68 %type
<head
> event_legacy_tracepoint
69 %type
<head
> event_legacy_numeric
70 %type
<head
> event_legacy_raw
71 %type
<head
> event_def
72 %type
<head
> event_mod
73 %type
<head
> event_name
76 %type
<head
> group_def
84 struct list_head
*head
;
85 struct parse_events_term
*term
;
90 PE_START_EVENTS start_events
92 PE_START_TERMS start_terms
96 struct parse_events_evlist
*data
= _data
;
98 parse_events_update_lists
($1, &data
->list
);
104 struct list_head
*list
= $1;
105 struct list_head
*group
= $3;
107 parse_events_update_lists
(group
, list
);
113 struct list_head
*list
= $1;
114 struct list_head
*event
= $3;
116 parse_events_update_lists
(event
, list
);
125 group_def
':' PE_MODIFIER_EVENT
127 struct list_head
*list
= $1;
129 ABORT_ON
(parse_events__modifier_group
(list
, $3));
136 PE_NAME
'{' events
'}'
138 struct list_head
*list
= $3;
140 inc_group_count
(list
, _data
);
141 parse_events__set_leader
($1, list
);
147 struct list_head
*list
= $2;
149 inc_group_count
(list
, _data
);
150 parse_events__set_leader
(NULL
, list
);
157 struct list_head
*event
= $3;
158 struct list_head
*list
= $1;
160 parse_events_update_lists
(event
, list
);
169 event_name PE_MODIFIER_EVENT
171 struct list_head
*list
= $1;
174 * Apply modifier on all events added by single event definition
175 * (there could be more events added for multiple tracepoint
176 * definitions via '*?'.
178 ABORT_ON
(parse_events__modifier_event
(list
, $2, false
));
185 PE_EVENT_NAME event_def
187 ABORT_ON
(parse_events_name
($2, $1));
194 event_def: event_pmu |
195 event_legacy_symbol |
196 event_legacy_cache sep_dc |
198 event_legacy_tracepoint sep_dc |
199 event_legacy_numeric sep_dc |
200 event_legacy_raw sep_dc
203 PE_NAME
'/' event_config
'/'
205 struct parse_events_evlist
*data
= _data
;
206 struct list_head
*list
;
209 ABORT_ON
(parse_events_add_pmu
(list
, &data
->idx
, $1, $3));
210 parse_events__free_terms
($3);
220 value_sym
'/' event_config
'/'
222 struct parse_events_evlist
*data
= _data
;
223 struct list_head
*list
;
225 int config
= $1 & 255;
228 ABORT_ON
(parse_events_add_numeric
(list
, &data
->idx
,
230 parse_events__free_terms
($3);
234 value_sym sep_slash_dc
236 struct parse_events_evlist
*data
= _data
;
237 struct list_head
*list
;
239 int config
= $1 & 255;
242 ABORT_ON
(parse_events_add_numeric
(list
, &data
->idx
,
243 type
, config
, NULL
));
248 PE_NAME_CACHE_TYPE
'-' PE_NAME_CACHE_OP_RESULT
'-' PE_NAME_CACHE_OP_RESULT
250 struct parse_events_evlist
*data
= _data
;
251 struct list_head
*list
;
254 ABORT_ON
(parse_events_add_cache
(list
, &data
->idx
, $1, $3, $5));
258 PE_NAME_CACHE_TYPE
'-' PE_NAME_CACHE_OP_RESULT
260 struct parse_events_evlist
*data
= _data
;
261 struct list_head
*list
;
264 ABORT_ON
(parse_events_add_cache
(list
, &data
->idx
, $1, $3, NULL
));
270 struct parse_events_evlist
*data
= _data
;
271 struct list_head
*list
;
274 ABORT_ON
(parse_events_add_cache
(list
, &data
->idx
, $1, NULL
, NULL
));
279 PE_PREFIX_MEM PE_VALUE
':' PE_MODIFIER_BP sep_dc
281 struct parse_events_evlist
*data
= _data
;
282 struct list_head
*list
;
285 ABORT_ON
(parse_events_add_breakpoint
(list
, &data
->idx
,
290 PE_PREFIX_MEM PE_VALUE sep_dc
292 struct parse_events_evlist
*data
= _data
;
293 struct list_head
*list
;
296 ABORT_ON
(parse_events_add_breakpoint
(list
, &data
->idx
,
301 event_legacy_tracepoint:
302 PE_NAME
'-' PE_NAME
':' PE_NAME
304 struct parse_events_evlist
*data
= _data
;
305 struct list_head
*list
;
307 snprintf
(&sys_name
, 128, "%s-%s", $1, $3);
310 ABORT_ON
(parse_events_add_tracepoint
(list
, &data
->idx
, &sys_name
, $5));
316 struct parse_events_evlist
*data
= _data
;
317 struct list_head
*list
;
320 ABORT_ON
(parse_events_add_tracepoint
(list
, &data
->idx
, $1, $3));
324 event_legacy_numeric:
325 PE_VALUE
':' PE_VALUE
327 struct parse_events_evlist
*data
= _data
;
328 struct list_head
*list
;
331 ABORT_ON
(parse_events_add_numeric
(list
, &data
->idx
, (u32
)$1, $3, NULL
));
338 struct parse_events_evlist
*data
= _data
;
339 struct list_head
*list
;
342 ABORT_ON
(parse_events_add_numeric
(list
, &data
->idx
,
343 PERF_TYPE_RAW
, $1, NULL
));
347 start_terms: event_config
349 struct parse_events_terms
*data
= _data
;
354 event_config
',' event_term
356 struct list_head
*head
= $1;
357 struct parse_events_term
*term
= $3;
360 list_add_tail
(&term
->list
, head
);
366 struct list_head
*head
= malloc
(sizeof
(*head
));
367 struct parse_events_term
*term
= $1;
370 INIT_LIST_HEAD
(head
);
371 list_add_tail
(&term
->list
, head
);
378 struct parse_events_term
*term
;
380 ABORT_ON
(parse_events_term__str
(&term
, PARSE_EVENTS__TERM_TYPE_USER
,
387 struct parse_events_term
*term
;
389 ABORT_ON
(parse_events_term__num
(&term
, PARSE_EVENTS__TERM_TYPE_USER
,
394 PE_NAME
'=' PE_VALUE_SYM_HW
396 struct parse_events_term
*term
;
397 int config
= $3 & 255;
399 ABORT_ON
(parse_events_term__sym_hw
(&term
, $1, config
));
405 struct parse_events_term
*term
;
407 ABORT_ON
(parse_events_term__num
(&term
, PARSE_EVENTS__TERM_TYPE_USER
,
414 struct parse_events_term
*term
;
415 int config
= $1 & 255;
417 ABORT_ON
(parse_events_term__sym_hw
(&term
, NULL
, config
));
423 struct parse_events_term
*term
;
425 ABORT_ON
(parse_events_term__str
(&term
, (int)$1, NULL
, $3));
431 struct parse_events_term
*term
;
433 ABORT_ON
(parse_events_term__num
(&term
, (int)$1, NULL
, $3));
439 struct parse_events_term
*term
;
441 ABORT_ON
(parse_events_term__num
(&term
, (int)$1, NULL
, 1));
447 sep_slash_dc: '/' |
':' |
451 void parse_events_error
(void *data __maybe_unused
, void *scanner __maybe_unused
,
452 char const *msg __maybe_unused
)