]>
Commit | Line | Data |
---|---|---|
89812fc8 JO |
1 | |
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 | ||
16 | extern int parse_events_lex (void); | |
17 | ||
18 | #define ABORT_ON(val) \ | |
19 | do { \ | |
20 | if (val) \ | |
21 | YYABORT; \ | |
22 | } while (0) | |
23 | ||
24 | %} | |
25 | ||
8f707d84 | 26 | %token PE_VALUE PE_VALUE_SYM PE_RAW PE_TERM |
89812fc8 JO |
27 | %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 | |
8f707d84 | 35 | %type <num> PE_TERM |
89812fc8 JO |
36 | %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 | |
8f707d84 JO |
41 | %type <head> event_config |
42 | %type <term> event_term | |
89812fc8 JO |
43 | |
44 | %union | |
45 | { | |
46 | char *str; | |
47 | unsigned long num; | |
8f707d84 JO |
48 | struct list_head *head; |
49 | struct parse_events__term *term; | |
89812fc8 JO |
50 | } |
51 | %% | |
52 | ||
53 | events: | |
54 | events ',' event | event | |
55 | ||
56 | event: | |
57 | event_def PE_MODIFIER_EVENT | |
58 | { | |
59 | ABORT_ON(parse_events_modifier(list, $2)); | |
60 | } | |
61 | | | |
62 | event_def | |
63 | ||
8f707d84 | 64 | event_def: event_legacy_symbol | |
89812fc8 JO |
65 | 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 | ||
71 | event_legacy_symbol: | |
8f707d84 | 72 | PE_VALUE_SYM '/' event_config '/' |
89812fc8 JO |
73 | { |
74 | int type = $1 >> 16; | |
75 | int config = $1 & 255; | |
76 | ||
8f707d84 JO |
77 | ABORT_ON(parse_events_add_numeric(list, idx, type, config, $3)); |
78 | parse_events__free_terms($3); | |
79 | } | |
80 | | | |
81 | PE_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)); | |
89812fc8 JO |
87 | } |
88 | ||
89 | event_legacy_cache: | |
90 | PE_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 | | | |
95 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT | |
96 | { | |
97 | ABORT_ON(parse_events_add_cache(list, idx, $1, $3, NULL)); | |
98 | } | |
99 | | | |
100 | PE_NAME_CACHE_TYPE | |
101 | { | |
102 | ABORT_ON(parse_events_add_cache(list, idx, $1, NULL, NULL)); | |
103 | } | |
104 | ||
105 | event_legacy_mem: | |
106 | PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc | |
107 | { | |
108 | ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) $2, $4)); | |
109 | } | |
110 | | | |
111 | PE_PREFIX_MEM PE_VALUE sep_dc | |
112 | { | |
113 | ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) $2, NULL)); | |
114 | } | |
115 | ||
116 | event_legacy_tracepoint: | |
117 | PE_NAME ':' PE_NAME | |
118 | { | |
119 | ABORT_ON(parse_events_add_tracepoint(list, idx, $1, $3)); | |
120 | } | |
121 | ||
122 | event_legacy_numeric: | |
123 | PE_VALUE ':' PE_VALUE | |
124 | { | |
8f707d84 | 125 | ABORT_ON(parse_events_add_numeric(list, idx, $1, $3, NULL)); |
89812fc8 JO |
126 | } |
127 | ||
128 | event_legacy_raw: | |
129 | PE_RAW | |
130 | { | |
8f707d84 JO |
131 | ABORT_ON(parse_events_add_numeric(list, idx, PERF_TYPE_RAW, $1, NULL)); |
132 | } | |
133 | ||
134 | event_config: | |
135 | event_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 | | | |
145 | event_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 | ||
156 | event_term: | |
157 | PE_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 | | | |
166 | PE_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 | | | |
175 | PE_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 | | | |
184 | PE_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 | | | |
192 | PE_TERM | |
193 | { | |
194 | struct parse_events__term *term; | |
195 | ||
196 | ABORT_ON(parse_events__new_term(&term, $1, NULL, NULL, 1)); | |
197 | $$ = term; | |
89812fc8 JO |
198 | } |
199 | ||
200 | sep_dc: ':' | | |
201 | ||
8f707d84 JO |
202 | sep_slash_dc: '/' | ':' | |
203 | ||
89812fc8 JO |
204 | %% |
205 | ||
206 | void parse_events_error(struct list_head *list __used, int *idx __used, | |
207 | char const *msg __used) | |
208 | { | |
209 | } |