2 %name-prefix "parse_events_"
3 %parse-param {void *_data}
4 %parse-param {void *scanner}
5 %lex-param {void* scanner}
11 #include <linux/compiler.h>
12 #include <linux/list.h>
15 #include "parse-events.h"
16 #include "parse-events-bison.h"
18 extern int parse_events_lex (YYSTYPE* lvalp, void* scanner);
20 #define ABORT_ON(val) \
28 %token PE_VALUE PE_VALUE_SYM PE_RAW PE_TERM
30 %token PE_MODIFIER_EVENT PE_MODIFIER_BP
31 %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
32 %token PE_PREFIX_MEM PE_PREFIX_RAW
35 %type <num> PE_VALUE_SYM
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
43 %type <head> event_config
44 %type <term> event_term
45 %type <head> event_pmu
46 %type <head> event_legacy_symbol
47 %type <head> event_legacy_cache
48 %type <head> event_legacy_mem
49 %type <head> event_legacy_tracepoint
50 %type <head> event_legacy_numeric
51 %type <head> event_legacy_raw
52 %type <head> event_def
58 struct list_head *head;
59 struct parse_events__term *term;
64 events ',' event | event
67 event_def PE_MODIFIER_EVENT
69 struct parse_events_data__events *data = _data;
72 * Apply modifier on all events added by single event definition
73 * (there could be more events added for multiple tracepoint
74 * definitions via '*?'.
76 ABORT_ON(parse_events_modifier($1, $2));
77 parse_events_update_lists($1, &data->list);
82 struct parse_events_data__events *data = _data;
84 parse_events_update_lists($1, &data->list);
87 event_def: event_pmu |
89 event_legacy_cache sep_dc |
91 event_legacy_tracepoint sep_dc |
92 event_legacy_numeric sep_dc |
93 event_legacy_raw sep_dc
96 PE_NAME '/' event_config '/'
98 struct parse_events_data__events *data = _data;
99 struct list_head *list = NULL;
101 ABORT_ON(parse_events_add_pmu(&list, &data->idx, $1, $3));
102 parse_events__free_terms($3);
107 PE_VALUE_SYM '/' event_config '/'
109 struct parse_events_data__events *data = _data;
110 struct list_head *list = NULL;
112 int config = $1 & 255;
114 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
116 parse_events__free_terms($3);
120 PE_VALUE_SYM sep_slash_dc
122 struct parse_events_data__events *data = _data;
123 struct list_head *list = NULL;
125 int config = $1 & 255;
127 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
128 type, config, NULL));
133 PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
135 struct parse_events_data__events *data = _data;
136 struct list_head *list = NULL;
138 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, $5));
142 PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
144 struct parse_events_data__events *data = _data;
145 struct list_head *list = NULL;
147 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, NULL));
153 struct parse_events_data__events *data = _data;
154 struct list_head *list = NULL;
156 ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, NULL, NULL));
161 PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
163 struct parse_events_data__events *data = _data;
164 struct list_head *list = NULL;
166 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
171 PE_PREFIX_MEM PE_VALUE sep_dc
173 struct parse_events_data__events *data = _data;
174 struct list_head *list = NULL;
176 ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
181 event_legacy_tracepoint:
184 struct parse_events_data__events *data = _data;
185 struct list_head *list = NULL;
187 ABORT_ON(parse_events_add_tracepoint(&list, &data->idx, $1, $3));
191 event_legacy_numeric:
192 PE_VALUE ':' PE_VALUE
194 struct parse_events_data__events *data = _data;
195 struct list_head *list = NULL;
197 ABORT_ON(parse_events_add_numeric(&list, &data->idx, $1, $3, NULL));
204 struct parse_events_data__events *data = _data;
205 struct list_head *list = NULL;
207 ABORT_ON(parse_events_add_numeric(&list, &data->idx,
208 PERF_TYPE_RAW, $1, NULL));
213 event_config ',' event_term
215 struct list_head *head = $1;
216 struct parse_events__term *term = $3;
219 list_add_tail(&term->list, head);
225 struct list_head *head = malloc(sizeof(*head));
226 struct parse_events__term *term = $1;
229 INIT_LIST_HEAD(head);
230 list_add_tail(&term->list, head);
237 struct parse_events__term *term;
239 ABORT_ON(parse_events__term_str(&term, PARSE_EVENTS__TERM_TYPE_USER,
246 struct parse_events__term *term;
248 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
255 struct parse_events__term *term;
257 ABORT_ON(parse_events__term_num(&term, PARSE_EVENTS__TERM_TYPE_USER,
264 struct parse_events__term *term;
266 ABORT_ON(parse_events__term_str(&term, $1, NULL, $3));
272 struct parse_events__term *term;
274 ABORT_ON(parse_events__term_num(&term, $1, NULL, $3));
280 struct parse_events__term *term;
282 ABORT_ON(parse_events__term_num(&term, $1, NULL, 1));
288 sep_slash_dc: '/' | ':' |
292 void parse_events_error(void *data __used, void *scanner __used,
293 char const *msg __used)