~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/util/parse-events.y

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/perf/util/parse-events.y (Version linux-6.12-rc7) and /tools/perf/util/parse-events.y (Version linux-5.18.19)


  1 %define api.pure full                               1 %define api.pure full
  2 %parse-param {void *_parse_state}                   2 %parse-param {void *_parse_state}
  3 %parse-param {void *scanner}                        3 %parse-param {void *scanner}
  4 %lex-param {void* scanner}                          4 %lex-param {void* scanner}
  5 %locations                                          5 %locations
  6                                                     6 
  7 %{                                                  7 %{
  8                                                     8 
  9 #ifndef NDEBUG                                 << 
 10 #define YYDEBUG 1                                   9 #define YYDEBUG 1
 11 #endif                                         << 
 12                                                    10 
 13 #include <errno.h>                             !!  11 #include <fnmatch.h>
                                                   >>  12 #include <stdio.h>
 14 #include <linux/compiler.h>                        13 #include <linux/compiler.h>
 15 #include <linux/types.h>                           14 #include <linux/types.h>
                                                   >>  15 #include <linux/zalloc.h>
 16 #include "pmu.h"                                   16 #include "pmu.h"
 17 #include "pmus.h"                              << 
 18 #include "evsel.h"                                 17 #include "evsel.h"
 19 #include "parse-events.h"                          18 #include "parse-events.h"
 20 #include "parse-events-bison.h"                    19 #include "parse-events-bison.h"
 21                                                    20 
 22 int parse_events_lex(YYSTYPE * yylval_param, Y << 
 23 void parse_events_error(YYLTYPE *loc, void *pa     21 void parse_events_error(YYLTYPE *loc, void *parse_state, void *scanner, char const *msg);
 24                                                    22 
 25 #define PE_ABORT(val) \                        !!  23 #define ABORT_ON(val) \
 26 do { \                                             24 do { \
 27         if (val == -ENOMEM) \                  !!  25         if (val) \
 28                 YYNOMEM; \                     !!  26                 YYABORT; \
 29         YYABORT; \                             << 
 30 } while (0)                                        27 } while (0)
 31                                                    28 
 32 static struct list_head* alloc_list(void)          29 static struct list_head* alloc_list(void)
 33 {                                                  30 {
 34         struct list_head *list;                    31         struct list_head *list;
 35                                                    32 
 36         list = malloc(sizeof(*list));              33         list = malloc(sizeof(*list));
 37         if (!list)                                 34         if (!list)
 38                 return NULL;                       35                 return NULL;
 39                                                    36 
 40         INIT_LIST_HEAD(list);                      37         INIT_LIST_HEAD(list);
 41         return list;                               38         return list;
 42 }                                                  39 }
 43                                                    40 
 44 static void free_list_evsel(struct list_head*      41 static void free_list_evsel(struct list_head* list_evsel)
 45 {                                                  42 {
 46         struct evsel *evsel, *tmp;                 43         struct evsel *evsel, *tmp;
 47                                                    44 
 48         list_for_each_entry_safe(evsel, tmp, l     45         list_for_each_entry_safe(evsel, tmp, list_evsel, core.node) {
 49                 list_del_init(&evsel->core.nod     46                 list_del_init(&evsel->core.node);
 50                 evsel__delete(evsel);              47                 evsel__delete(evsel);
 51         }                                          48         }
 52         free(list_evsel);                          49         free(list_evsel);
 53 }                                                  50 }
 54                                                    51 
                                                   >>  52 static void inc_group_count(struct list_head *list,
                                                   >>  53                        struct parse_events_state *parse_state)
                                                   >>  54 {
                                                   >>  55         /* Count groups only have more than 1 members */
                                                   >>  56         if (!list_is_last(list->next, list))
                                                   >>  57                 parse_state->nr_groups++;
                                                   >>  58 }
                                                   >>  59 
 55 %}                                                 60 %}
 56                                                    61 
 57 %token PE_START_EVENTS PE_START_TERMS              62 %token PE_START_EVENTS PE_START_TERMS
 58 %token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_S !!  63 %token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM
 59 %token PE_VALUE_SYM_TOOL                           64 %token PE_VALUE_SYM_TOOL
 60 %token PE_EVENT_NAME                               65 %token PE_EVENT_NAME
 61 %token PE_RAW PE_NAME                          !!  66 %token PE_NAME
 62 %token PE_MODIFIER_EVENT PE_MODIFIER_BP PE_BP_ !!  67 %token PE_BPF_OBJECT PE_BPF_SOURCE
 63 %token PE_LEGACY_CACHE                         !!  68 %token PE_MODIFIER_EVENT PE_MODIFIER_BP
 64 %token PE_PREFIX_MEM                           !!  69 %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
                                                   >>  70 %token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP
 65 %token PE_ERROR                                    71 %token PE_ERROR
                                                   >>  72 %token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_PMU_EVENT_SUF2 PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE
                                                   >>  73 %token PE_ARRAY_ALL PE_ARRAY_RANGE
 66 %token PE_DRV_CFG_TERM                             74 %token PE_DRV_CFG_TERM
 67 %token PE_TERM_HW                              << 
 68 %type <num> PE_VALUE                               75 %type <num> PE_VALUE
 69 %type <num> PE_VALUE_SYM_HW                        76 %type <num> PE_VALUE_SYM_HW
 70 %type <num> PE_VALUE_SYM_SW                        77 %type <num> PE_VALUE_SYM_SW
 71 %type <num> PE_VALUE_SYM_TOOL                      78 %type <num> PE_VALUE_SYM_TOOL
 72 %type <mod> PE_MODIFIER_EVENT                  !!  79 %type <num> PE_RAW
 73 %type <term_type> PE_TERM                      !!  80 %type <num> PE_TERM
 74 %type <num> value_sym                              81 %type <num> value_sym
 75 %type <str> PE_RAW                             << 
 76 %type <str> PE_NAME                                82 %type <str> PE_NAME
 77 %type <str> PE_LEGACY_CACHE                    !!  83 %type <str> PE_BPF_OBJECT
                                                   >>  84 %type <str> PE_BPF_SOURCE
                                                   >>  85 %type <str> PE_NAME_CACHE_TYPE
                                                   >>  86 %type <str> PE_NAME_CACHE_OP_RESULT
                                                   >>  87 %type <str> PE_MODIFIER_EVENT
 78 %type <str> PE_MODIFIER_BP                         88 %type <str> PE_MODIFIER_BP
 79 %type <str> PE_EVENT_NAME                          89 %type <str> PE_EVENT_NAME
                                                   >>  90 %type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_PMU_EVENT_SUF2 PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE
 80 %type <str> PE_DRV_CFG_TERM                        91 %type <str> PE_DRV_CFG_TERM
 81 %type <str> name_or_raw                        !!  92 %type <str> event_pmu_name
 82 %destructor { free ($$); } <str>                   93 %destructor { free ($$); } <str>
 83 %type <term> event_term                            94 %type <term> event_term
 84 %destructor { parse_events_term__delete ($$);      95 %destructor { parse_events_term__delete ($$); } <term>
 85 %type <list_terms> event_config                    96 %type <list_terms> event_config
 86 %type <list_terms> opt_event_config                97 %type <list_terms> opt_event_config
 87 %type <list_terms> opt_pmu_config                  98 %type <list_terms> opt_pmu_config
 88 %destructor { parse_events_terms__delete ($$);     99 %destructor { parse_events_terms__delete ($$); } <list_terms>
 89 %type <list_evsel> event_pmu                      100 %type <list_evsel> event_pmu
 90 %type <list_evsel> event_legacy_symbol            101 %type <list_evsel> event_legacy_symbol
 91 %type <list_evsel> event_legacy_cache             102 %type <list_evsel> event_legacy_cache
 92 %type <list_evsel> event_legacy_mem               103 %type <list_evsel> event_legacy_mem
 93 %type <list_evsel> event_legacy_tracepoint        104 %type <list_evsel> event_legacy_tracepoint
 94 %type <list_evsel> event_legacy_numeric           105 %type <list_evsel> event_legacy_numeric
 95 %type <list_evsel> event_legacy_raw               106 %type <list_evsel> event_legacy_raw
                                                   >> 107 %type <list_evsel> event_bpf_file
 96 %type <list_evsel> event_def                      108 %type <list_evsel> event_def
 97 %type <list_evsel> event_mod                      109 %type <list_evsel> event_mod
 98 %type <list_evsel> event_name                     110 %type <list_evsel> event_name
 99 %type <list_evsel> event                          111 %type <list_evsel> event
100 %type <list_evsel> events                         112 %type <list_evsel> events
101 %type <list_evsel> group_def                      113 %type <list_evsel> group_def
102 %type <list_evsel> group                          114 %type <list_evsel> group
103 %type <list_evsel> groups                         115 %type <list_evsel> groups
104 %destructor { free_list_evsel ($$); } <list_ev    116 %destructor { free_list_evsel ($$); } <list_evsel>
105 %type <tracepoint_name> tracepoint_name           117 %type <tracepoint_name> tracepoint_name
106 %destructor { free ($$.sys); free ($$.event);     118 %destructor { free ($$.sys); free ($$.event); } <tracepoint_name>
107 %type <hardware_term> PE_TERM_HW               !! 119 %type <array> array
108 %destructor { free ($$.str); } <hardware_term> !! 120 %type <array> array_term
                                                   >> 121 %type <array> array_terms
                                                   >> 122 %destructor { free ($$.ranges); } <array>
109                                                   123 
110 %union                                            124 %union
111 {                                                 125 {
112         char *str;                                126         char *str;
113         u64 num;                                  127         u64 num;
114         struct parse_events_modifier mod;      << 
115         enum parse_events__term_type term_type << 
116         struct list_head *list_evsel;             128         struct list_head *list_evsel;
117         struct parse_events_terms *list_terms; !! 129         struct list_head *list_terms;
118         struct parse_events_term *term;           130         struct parse_events_term *term;
119         struct tracepoint_name {                  131         struct tracepoint_name {
120                 char *sys;                        132                 char *sys;
121                 char *event;                      133                 char *event;
122         } tracepoint_name;                        134         } tracepoint_name;
123         struct hardware_term {                 !! 135         struct parse_events_array array;
124                 char *str;                     << 
125                 u64 num;                       << 
126         } hardware_term;                       << 
127 }                                                 136 }
128 %%                                                137 %%
129                                                   138 
130  /*                                            << 
131   * Entry points. We are either parsing events << 
132   * parsing is used for parsing events in sysf << 
133   */                                           << 
134 start:                                            139 start:
135 PE_START_EVENTS start_events                      140 PE_START_EVENTS start_events
136 |                                                 141 |
137 PE_START_TERMS  start_terms                       142 PE_START_TERMS  start_terms
138                                                   143 
139 start_events: groups                              144 start_events: groups
140 {                                                 145 {
141         /* Take the parsed events, groups.. an << 
142         struct list_head *groups  = $1;        << 
143         struct parse_events_state *parse_state    146         struct parse_events_state *parse_state = _parse_state;
144                                                   147 
145         list_splice_tail(groups, &parse_state- !! 148         /* frees $1 */
146         free(groups);                          !! 149         parse_events_update_lists($1, &parse_state->list);
147 }                                                 150 }
148                                                   151 
149 groups: /* A list of groups or events. */      !! 152 groups:
150 groups ',' group                                  153 groups ',' group
151 {                                                 154 {
152         /* Merge group into the list of events !! 155         struct list_head *list  = $1;
153         struct list_head *groups  = $1;        !! 156         struct list_head *group = $3;
154         struct list_head *group  = $3;         !! 157 
155                                                !! 158         /* frees $3 */
156         list_splice_tail(group, groups);       !! 159         parse_events_update_lists(group, list);
157         free(group);                           !! 160         $$ = list;
158         $$ = groups;                           << 
159 }                                                 161 }
160 |                                                 162 |
161 groups ',' event                                  163 groups ',' event
162 {                                                 164 {
163         /* Merge event into the list of events !! 165         struct list_head *list  = $1;
164         struct list_head *groups  = $1;        << 
165         struct list_head *event = $3;             166         struct list_head *event = $3;
166                                                   167 
167                                                !! 168         /* frees $3 */
168         list_splice_tail(event, groups);       !! 169         parse_events_update_lists(event, list);
169         free(event);                           !! 170         $$ = list;
170         $$ = groups;                           << 
171 }                                                 171 }
172 |                                                 172 |
173 group                                             173 group
174 |                                                 174 |
175 event                                             175 event
176                                                   176 
177 group:                                            177 group:
178 group_def ':' PE_MODIFIER_EVENT                   178 group_def ':' PE_MODIFIER_EVENT
179 {                                                 179 {
180         /* Apply the modifier to the events in << 
181         struct list_head *list = $1;              180         struct list_head *list = $1;
182         int err;                                  181         int err;
183                                                   182 
184         err = parse_events__modifier_group(_pa !! 183         err = parse_events__modifier_group(list, $3);
185         if (err)                               !! 184         free($3);
                                                   >> 185         if (err) {
                                                   >> 186                 struct parse_events_state *parse_state = _parse_state;
                                                   >> 187                 struct parse_events_error *error = parse_state->error;
                                                   >> 188 
                                                   >> 189                 parse_events_error__handle(error, @3.first_column,
                                                   >> 190                                            strdup("Bad modifier"), NULL);
                                                   >> 191                 free_list_evsel(list);
186                 YYABORT;                          192                 YYABORT;
                                                   >> 193         }
187         $$ = list;                                194         $$ = list;
188 }                                                 195 }
189 |                                                 196 |
190 group_def                                         197 group_def
191                                                   198 
192 group_def:                                        199 group_def:
193 PE_NAME '{' events '}'                            200 PE_NAME '{' events '}'
194 {                                                 201 {
195         struct list_head *list = $3;              202         struct list_head *list = $3;
196                                                   203 
197         /*                                     !! 204         inc_group_count(list, _parse_state);
198          * Set the first entry of list to be t !! 205         parse_events__set_leader($1, list, _parse_state);
199          * the leader to $1 taking ownership.  !! 206         free($1);
200          */                                    << 
201         parse_events__set_leader($1, list);    << 
202         $$ = list;                                207         $$ = list;
203 }                                                 208 }
204 |                                                 209 |
205 '{' events '}'                                    210 '{' events '}'
206 {                                                 211 {
207         struct list_head *list = $2;              212         struct list_head *list = $2;
208                                                   213 
209         /* Set the first entry of list to be t !! 214         inc_group_count(list, _parse_state);
210         parse_events__set_leader(NULL, list);  !! 215         parse_events__set_leader(NULL, list, _parse_state);
211         $$ = list;                                216         $$ = list;
212 }                                                 217 }
213                                                   218 
214 events:                                           219 events:
215 events ',' event                                  220 events ',' event
216 {                                                 221 {
217         struct list_head *events  = $1;        << 
218         struct list_head *event = $3;             222         struct list_head *event = $3;
                                                   >> 223         struct list_head *list  = $1;
219                                                   224 
220         list_splice_tail(event, events);       !! 225         /* frees $3 */
221         free(event);                           !! 226         parse_events_update_lists(event, list);
222         $$ = events;                           !! 227         $$ = list;
223 }                                                 228 }
224 |                                                 229 |
225 event                                             230 event
226                                                   231 
227 event: event_mod                                  232 event: event_mod
228                                                   233 
229 event_mod:                                        234 event_mod:
230 event_name PE_MODIFIER_EVENT                      235 event_name PE_MODIFIER_EVENT
231 {                                                 236 {
232         struct list_head *list = $1;              237         struct list_head *list = $1;
233         int err;                                  238         int err;
234                                                   239 
235         /*                                        240         /*
236          * Apply modifier on all events added     241          * Apply modifier on all events added by single event definition
237          * (there could be more events added f    242          * (there could be more events added for multiple tracepoint
238          * definitions via '*?'.                  243          * definitions via '*?'.
239          */                                       244          */
240         err = parse_events__modifier_event(_pa !! 245         err = parse_events__modifier_event(list, $2, false);
241         if (err)                               !! 246         free($2);
                                                   >> 247         if (err) {
                                                   >> 248                 struct parse_events_state *parse_state = _parse_state;
                                                   >> 249                 struct parse_events_error *error = parse_state->error;
                                                   >> 250 
                                                   >> 251                 parse_events_error__handle(error, @2.first_column,
                                                   >> 252                                            strdup("Bad modifier"), NULL);
                                                   >> 253                 free_list_evsel(list);
242                 YYABORT;                          254                 YYABORT;
                                                   >> 255         }
243         $$ = list;                                256         $$ = list;
244 }                                                 257 }
245 |                                                 258 |
246 event_name                                        259 event_name
247                                                   260 
248 event_name:                                       261 event_name:
249 PE_EVENT_NAME event_def                           262 PE_EVENT_NAME event_def
250 {                                                 263 {
251         /*                                     !! 264         int err;
252          * When an event is parsed the text is << 
253          * the event is set to the str of PE_E << 
254          * no name was on an event via a term, << 
255          * taking ownership of the allocation. << 
256          */                                    << 
257         int err = parse_events__set_default_na << 
258                                                   265 
                                                   >> 266         err = parse_events_name($2, $1);
                                                   >> 267         free($1);
259         if (err) {                                268         if (err) {
260                 free_list_evsel($2);              269                 free_list_evsel($2);
261                 YYNOMEM;                       !! 270                 YYABORT;
262         }                                         271         }
263         $$ = $2;                                  272         $$ = $2;
264 }                                                 273 }
265 |                                                 274 |
266 event_def                                         275 event_def
267                                                   276 
268 event_def: event_pmu |                            277 event_def: event_pmu |
269            event_legacy_symbol |                  278            event_legacy_symbol |
270            event_legacy_cache sep_dc |            279            event_legacy_cache sep_dc |
271            event_legacy_mem sep_dc |           !! 280            event_legacy_mem |
272            event_legacy_tracepoint sep_dc |       281            event_legacy_tracepoint sep_dc |
273            event_legacy_numeric sep_dc |          282            event_legacy_numeric sep_dc |
274            event_legacy_raw sep_dc             !! 283            event_legacy_raw sep_dc |
                                                   >> 284            event_bpf_file
                                                   >> 285 
                                                   >> 286 event_pmu_name:
                                                   >> 287 PE_NAME | PE_PMU_EVENT_PRE
275                                                   288 
276 event_pmu:                                        289 event_pmu:
277 PE_NAME opt_pmu_config                         !! 290 event_pmu_name opt_pmu_config
278 {                                                 291 {
279         /* List of created evsels. */          !! 292         struct parse_events_state *parse_state = _parse_state;
280         struct list_head *list = NULL;         !! 293         struct parse_events_error *error = parse_state->error;
281         int err = parse_events_multi_pmu_add_o !! 294         struct list_head *list = NULL, *orig_terms = NULL, *terms= NULL;
                                                   >> 295         char *pattern = NULL;
282                                                   296 
                                                   >> 297 #define CLEANUP_YYABORT                                 \
                                                   >> 298         do {                                            \
                                                   >> 299                 parse_events_terms__delete($2);         \
                                                   >> 300                 parse_events_terms__delete(orig_terms); \
                                                   >> 301                 free(list);                             \
                                                   >> 302                 free($1);                               \
                                                   >> 303                 free(pattern);                          \
                                                   >> 304                 YYABORT;                                \
                                                   >> 305         } while(0)
                                                   >> 306 
                                                   >> 307         if (parse_events_copy_term_list($2, &orig_terms))
                                                   >> 308                 CLEANUP_YYABORT;
                                                   >> 309 
                                                   >> 310         if (error)
                                                   >> 311                 error->idx = @1.first_column;
                                                   >> 312 
                                                   >> 313         list = alloc_list();
                                                   >> 314         if (!list)
                                                   >> 315                 CLEANUP_YYABORT;
                                                   >> 316         if (parse_events_add_pmu(_parse_state, list, $1, $2, false, false)) {
                                                   >> 317                 struct perf_pmu *pmu = NULL;
                                                   >> 318                 int ok = 0;
                                                   >> 319 
                                                   >> 320                 if (asprintf(&pattern, "%s*", $1) < 0)
                                                   >> 321                         CLEANUP_YYABORT;
                                                   >> 322 
                                                   >> 323                 while ((pmu = perf_pmu__scan(pmu)) != NULL) {
                                                   >> 324                         char *name = pmu->name;
                                                   >> 325 
                                                   >> 326                         if (!strncmp(name, "uncore_", 7) &&
                                                   >> 327                             strncmp($1, "uncore_", 7))
                                                   >> 328                                 name += 7;
                                                   >> 329                         if (!perf_pmu__match(pattern, name, $1) ||
                                                   >> 330                             !perf_pmu__match(pattern, pmu->alias_name, $1)) {
                                                   >> 331                                 if (parse_events_copy_term_list(orig_terms, &terms))
                                                   >> 332                                         CLEANUP_YYABORT;
                                                   >> 333                                 if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, true, false))
                                                   >> 334                                         ok++;
                                                   >> 335                                 parse_events_terms__delete(terms);
                                                   >> 336                         }
                                                   >> 337                 }
                                                   >> 338 
                                                   >> 339                 if (!ok)
                                                   >> 340                         CLEANUP_YYABORT;
                                                   >> 341         }
283         parse_events_terms__delete($2);           342         parse_events_terms__delete($2);
                                                   >> 343         parse_events_terms__delete(orig_terms);
                                                   >> 344         free(pattern);
284         free($1);                                 345         free($1);
285         if (err)                               << 
286                 PE_ABORT(err);                 << 
287         $$ = list;                                346         $$ = list;
                                                   >> 347 #undef CLEANUP_YYABORT
288 }                                                 348 }
289 |                                                 349 |
290 PE_NAME sep_dc                                 !! 350 PE_KERNEL_PMU_EVENT sep_dc
291 {                                                 351 {
292         struct list_head *list;                   352         struct list_head *list;
293         int err;                                  353         int err;
294                                                   354 
295         err = parse_events_multi_pmu_add(_pars !! 355         err = parse_events_multi_pmu_add(_parse_state, $1, NULL, &list);
296         if (err < 0) {                         !! 356         free($1);
297                 struct parse_events_state *par !! 357         if (err < 0)
298                 struct parse_events_error *err !! 358                 YYABORT;
299                 char *help;                    !! 359         $$ = list;
                                                   >> 360 }
                                                   >> 361 |
                                                   >> 362 PE_KERNEL_PMU_EVENT opt_pmu_config
                                                   >> 363 {
                                                   >> 364         struct list_head *list;
                                                   >> 365         int err;
300                                                   366 
301                 if (asprintf(&help, "Unable to !! 367         /* frees $2 */
302                         help = NULL;           !! 368         err = parse_events_multi_pmu_add(_parse_state, $1, $2, &list);
303                 parse_events_error__handle(err !! 369         free($1);
304                 free($1);                      !! 370         if (err < 0)
305                 PE_ABORT(err);                 !! 371                 YYABORT;
                                                   >> 372         $$ = list;
                                                   >> 373 }
                                                   >> 374 |
                                                   >> 375 PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF '-' PE_PMU_EVENT_SUF2 sep_dc
                                                   >> 376 {
                                                   >> 377         struct list_head *list;
                                                   >> 378         char pmu_name[128];
                                                   >> 379         snprintf(pmu_name, sizeof(pmu_name), "%s-%s-%s", $1, $3, $5);
                                                   >> 380         free($1);
                                                   >> 381         free($3);
                                                   >> 382         free($5);
                                                   >> 383         if (parse_events_multi_pmu_add(_parse_state, pmu_name, NULL, &list) < 0)
                                                   >> 384                 YYABORT;
                                                   >> 385         $$ = list;
                                                   >> 386 }
                                                   >> 387 |
                                                   >> 388 PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
                                                   >> 389 {
                                                   >> 390         struct list_head *list;
                                                   >> 391         char pmu_name[128];
                                                   >> 392 
                                                   >> 393         snprintf(pmu_name, sizeof(pmu_name), "%s-%s", $1, $3);
                                                   >> 394         free($1);
                                                   >> 395         free($3);
                                                   >> 396         if (parse_events_multi_pmu_add(_parse_state, pmu_name, NULL, &list) < 0)
                                                   >> 397                 YYABORT;
                                                   >> 398         $$ = list;
                                                   >> 399 }
                                                   >> 400 |
                                                   >> 401 PE_PMU_EVENT_FAKE sep_dc
                                                   >> 402 {
                                                   >> 403         struct list_head *list;
                                                   >> 404         int err;
                                                   >> 405 
                                                   >> 406         list = alloc_list();
                                                   >> 407         if (!list)
                                                   >> 408                 YYABORT;
                                                   >> 409 
                                                   >> 410         err = parse_events_add_pmu(_parse_state, list, $1, NULL, false, false);
                                                   >> 411         free($1);
                                                   >> 412         if (err < 0) {
                                                   >> 413                 free(list);
                                                   >> 414                 YYABORT;
306         }                                         415         }
                                                   >> 416         $$ = list;
                                                   >> 417 }
                                                   >> 418 |
                                                   >> 419 PE_PMU_EVENT_FAKE opt_pmu_config
                                                   >> 420 {
                                                   >> 421         struct list_head *list;
                                                   >> 422         int err;
                                                   >> 423 
                                                   >> 424         list = alloc_list();
                                                   >> 425         if (!list)
                                                   >> 426                 YYABORT;
                                                   >> 427 
                                                   >> 428         err = parse_events_add_pmu(_parse_state, list, $1, $2, false, false);
307         free($1);                                 429         free($1);
                                                   >> 430         parse_events_terms__delete($2);
                                                   >> 431         if (err < 0) {
                                                   >> 432                 free(list);
                                                   >> 433                 YYABORT;
                                                   >> 434         }
308         $$ = list;                                435         $$ = list;
309 }                                                 436 }
310                                                   437 
311 value_sym:                                        438 value_sym:
312 PE_VALUE_SYM_HW                                   439 PE_VALUE_SYM_HW
313 |                                                 440 |
314 PE_VALUE_SYM_SW                                   441 PE_VALUE_SYM_SW
315                                                   442 
316 event_legacy_symbol:                              443 event_legacy_symbol:
317 value_sym '/' event_config '/'                    444 value_sym '/' event_config '/'
318 {                                                 445 {
319         struct list_head *list;                   446         struct list_head *list;
320         int type = $1 >> 16;                      447         int type = $1 >> 16;
321         int config = $1 & 255;                    448         int config = $1 & 255;
322         int err;                                  449         int err;
323         bool wildcard = (type == PERF_TYPE_HAR << 
324                                                   450 
325         list = alloc_list();                      451         list = alloc_list();
326         if (!list)                             !! 452         ABORT_ON(!list);
327                 YYNOMEM;                       !! 453         err = parse_events_add_numeric(_parse_state, list, type, config, $3);
328         err = parse_events_add_numeric(_parse_ << 
329         parse_events_terms__delete($3);           454         parse_events_terms__delete($3);
330         if (err) {                                455         if (err) {
331                 free_list_evsel(list);            456                 free_list_evsel(list);
332                 PE_ABORT(err);                 !! 457                 YYABORT;
333         }                                         458         }
334         $$ = list;                                459         $$ = list;
335 }                                                 460 }
336 |                                                 461 |
337 value_sym sep_slash_slash_dc                      462 value_sym sep_slash_slash_dc
338 {                                                 463 {
339         struct list_head *list;                   464         struct list_head *list;
340         int type = $1 >> 16;                      465         int type = $1 >> 16;
341         int config = $1 & 255;                    466         int config = $1 & 255;
342         bool wildcard = (type == PERF_TYPE_HAR << 
343         int err;                               << 
344                                                   467 
345         list = alloc_list();                      468         list = alloc_list();
346         if (!list)                             !! 469         ABORT_ON(!list);
347                 YYNOMEM;                       !! 470         ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL));
348         err = parse_events_add_numeric(_parse_ << 
349         if (err)                               << 
350                 PE_ABORT(err);                 << 
351         $$ = list;                                471         $$ = list;
352 }                                                 472 }
353 |                                                 473 |
354 PE_VALUE_SYM_TOOL sep_slash_slash_dc              474 PE_VALUE_SYM_TOOL sep_slash_slash_dc
355 {                                                 475 {
356         struct list_head *list;                   476         struct list_head *list;
357         int err;                               << 
358                                                   477 
359         list = alloc_list();                      478         list = alloc_list();
360         if (!list)                             !! 479         ABORT_ON(!list);
361                 YYNOMEM;                       !! 480         ABORT_ON(parse_events_add_tool(_parse_state, list, $1));
362         err = parse_events_add_tool(_parse_sta << 
363         if (err)                               << 
364                 YYNOMEM;                       << 
365         $$ = list;                                481         $$ = list;
366 }                                                 482 }
367                                                   483 
368 event_legacy_cache:                               484 event_legacy_cache:
369 PE_LEGACY_CACHE opt_event_config               !! 485 PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config
370 {                                                 486 {
371         struct parse_events_state *parse_state    487         struct parse_events_state *parse_state = _parse_state;
                                                   >> 488         struct parse_events_error *error = parse_state->error;
372         struct list_head *list;                   489         struct list_head *list;
373         int err;                                  490         int err;
374                                                   491 
375         list = alloc_list();                      492         list = alloc_list();
376         if (!list)                             !! 493         ABORT_ON(!list);
377                 YYNOMEM;                       !! 494         err = parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6,
                                                   >> 495                                      parse_state);
                                                   >> 496         parse_events_terms__delete($6);
                                                   >> 497         free($1);
                                                   >> 498         free($3);
                                                   >> 499         free($5);
                                                   >> 500         if (err) {
                                                   >> 501                 free_list_evsel(list);
                                                   >> 502                 YYABORT;
                                                   >> 503         }
                                                   >> 504         $$ = list;
                                                   >> 505 }
                                                   >> 506 |
                                                   >> 507 PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config
                                                   >> 508 {
                                                   >> 509         struct parse_events_state *parse_state = _parse_state;
                                                   >> 510         struct parse_events_error *error = parse_state->error;
                                                   >> 511         struct list_head *list;
                                                   >> 512         int err;
378                                                   513 
379         err = parse_events_add_cache(list, &pa !! 514         list = alloc_list();
                                                   >> 515         ABORT_ON(!list);
                                                   >> 516         err = parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4,
                                                   >> 517                                      parse_state);
                                                   >> 518         parse_events_terms__delete($4);
                                                   >> 519         free($1);
                                                   >> 520         free($3);
                                                   >> 521         if (err) {
                                                   >> 522                 free_list_evsel(list);
                                                   >> 523                 YYABORT;
                                                   >> 524         }
                                                   >> 525         $$ = list;
                                                   >> 526 }
                                                   >> 527 |
                                                   >> 528 PE_NAME_CACHE_TYPE opt_event_config
                                                   >> 529 {
                                                   >> 530         struct parse_events_state *parse_state = _parse_state;
                                                   >> 531         struct parse_events_error *error = parse_state->error;
                                                   >> 532         struct list_head *list;
                                                   >> 533         int err;
380                                                   534 
                                                   >> 535         list = alloc_list();
                                                   >> 536         ABORT_ON(!list);
                                                   >> 537         err = parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2,
                                                   >> 538                                      parse_state);
381         parse_events_terms__delete($2);           539         parse_events_terms__delete($2);
382         free($1);                                 540         free($1);
383         if (err) {                                541         if (err) {
384                 free_list_evsel(list);            542                 free_list_evsel(list);
385                 PE_ABORT(err);                 !! 543                 YYABORT;
386         }                                         544         }
387         $$ = list;                                545         $$ = list;
388 }                                                 546 }
389                                                   547 
390 event_legacy_mem:                                 548 event_legacy_mem:
391 PE_PREFIX_MEM PE_VALUE PE_BP_SLASH PE_VALUE PE !! 549 PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
392 {                                                 550 {
                                                   >> 551         struct parse_events_state *parse_state = _parse_state;
393         struct list_head *list;                   552         struct list_head *list;
394         int err;                                  553         int err;
395                                                   554 
396         list = alloc_list();                      555         list = alloc_list();
397         if (!list)                             !! 556         ABORT_ON(!list);
398                 YYNOMEM;                       !! 557         err = parse_events_add_breakpoint(list, &parse_state->idx,
399                                                !! 558                                           $2, $6, $4);
400         err = parse_events_add_breakpoint(_par << 
401                                           $2,  << 
402         parse_events_terms__delete($7);        << 
403         free($6);                                 559         free($6);
404         if (err) {                                560         if (err) {
405                 free(list);                       561                 free(list);
406                 PE_ABORT(err);                 !! 562                 YYABORT;
407         }                                         563         }
408         $$ = list;                                564         $$ = list;
409 }                                                 565 }
410 |                                                 566 |
411 PE_PREFIX_MEM PE_VALUE PE_BP_SLASH PE_VALUE op !! 567 PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
412 {                                                 568 {
                                                   >> 569         struct parse_events_state *parse_state = _parse_state;
413         struct list_head *list;                   570         struct list_head *list;
414         int err;                               << 
415                                                   571 
416         list = alloc_list();                      572         list = alloc_list();
417         if (!list)                             !! 573         ABORT_ON(!list);
418                 YYNOMEM;                       !! 574         if (parse_events_add_breakpoint(list, &parse_state->idx,
419                                                !! 575                                         $2, NULL, $4)) {
420         err = parse_events_add_breakpoint(_par << 
421                                           $2,  << 
422         parse_events_terms__delete($5);        << 
423         if (err) {                             << 
424                 free(list);                       576                 free(list);
425                 PE_ABORT(err);                 !! 577                 YYABORT;
426         }                                         578         }
427         $$ = list;                                579         $$ = list;
428 }                                                 580 }
429 |                                                 581 |
430 PE_PREFIX_MEM PE_VALUE PE_BP_COLON PE_MODIFIER !! 582 PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
431 {                                                 583 {
                                                   >> 584         struct parse_events_state *parse_state = _parse_state;
432         struct list_head *list;                   585         struct list_head *list;
433         int err;                                  586         int err;
434                                                   587 
435         list = alloc_list();                      588         list = alloc_list();
436         if (!list)                             !! 589         ABORT_ON(!list);
437                 YYNOMEM;                       !! 590         err = parse_events_add_breakpoint(list, &parse_state->idx,
438                                                !! 591                                           $2, $4, 0);
439         err = parse_events_add_breakpoint(_par << 
440                                           $2,  << 
441         parse_events_terms__delete($5);        << 
442         free($4);                                 592         free($4);
443         if (err) {                                593         if (err) {
444                 free(list);                       594                 free(list);
445                 PE_ABORT(err);                 !! 595                 YYABORT;
446         }                                         596         }
447         $$ = list;                                597         $$ = list;
448 }                                                 598 }
449 |                                                 599 |
450 PE_PREFIX_MEM PE_VALUE opt_event_config        !! 600 PE_PREFIX_MEM PE_VALUE sep_dc
451 {                                                 601 {
                                                   >> 602         struct parse_events_state *parse_state = _parse_state;
452         struct list_head *list;                   603         struct list_head *list;
453         int err;                               << 
454                                                   604 
455         list = alloc_list();                      605         list = alloc_list();
456         if (!list)                             !! 606         ABORT_ON(!list);
457                 YYNOMEM;                       !! 607         if (parse_events_add_breakpoint(list, &parse_state->idx,
458         err = parse_events_add_breakpoint(_par !! 608                                         $2, NULL, 0)) {
459                                           $2,  << 
460         parse_events_terms__delete($3);        << 
461         if (err) {                             << 
462                 free(list);                       609                 free(list);
463                 PE_ABORT(err);                 !! 610                 YYABORT;
464         }                                         611         }
465         $$ = list;                                612         $$ = list;
466 }                                                 613 }
467                                                   614 
468 event_legacy_tracepoint:                          615 event_legacy_tracepoint:
469 tracepoint_name opt_event_config                  616 tracepoint_name opt_event_config
470 {                                                 617 {
471         struct parse_events_state *parse_state    618         struct parse_events_state *parse_state = _parse_state;
472         struct parse_events_error *error = par    619         struct parse_events_error *error = parse_state->error;
473         struct list_head *list;                   620         struct list_head *list;
474         int err;                                  621         int err;
475                                                   622 
476         list = alloc_list();                      623         list = alloc_list();
477         if (!list)                             !! 624         ABORT_ON(!list);
478                 YYNOMEM;                       !! 625         if (error)
                                                   >> 626                 error->idx = @1.first_column;
479                                                   627 
480         err = parse_events_add_tracepoint(pars !! 628         err = parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event,
481                                         error, !! 629                                         error, $2);
482                                                   630 
483         parse_events_terms__delete($2);           631         parse_events_terms__delete($2);
484         free($1.sys);                             632         free($1.sys);
485         free($1.event);                           633         free($1.event);
486         if (err) {                                634         if (err) {
487                 free(list);                       635                 free(list);
488                 PE_ABORT(err);                 !! 636                 YYABORT;
489         }                                         637         }
490         $$ = list;                                638         $$ = list;
491 }                                                 639 }
492                                                   640 
493 tracepoint_name:                                  641 tracepoint_name:
                                                   >> 642 PE_NAME '-' PE_NAME ':' PE_NAME
                                                   >> 643 {
                                                   >> 644         struct tracepoint_name tracepoint;
                                                   >> 645 
                                                   >> 646         ABORT_ON(asprintf(&tracepoint.sys, "%s-%s", $1, $3) < 0);
                                                   >> 647         tracepoint.event = $5;
                                                   >> 648         free($1);
                                                   >> 649         free($3);
                                                   >> 650         $$ = tracepoint;
                                                   >> 651 }
                                                   >> 652 |
494 PE_NAME ':' PE_NAME                               653 PE_NAME ':' PE_NAME
495 {                                                 654 {
496         struct tracepoint_name tracepoint = {$    655         struct tracepoint_name tracepoint = {$1, $3};
497                                                   656 
498         $$ = tracepoint;                          657         $$ = tracepoint;
499 }                                                 658 }
500                                                   659 
501 event_legacy_numeric:                             660 event_legacy_numeric:
502 PE_VALUE ':' PE_VALUE opt_event_config            661 PE_VALUE ':' PE_VALUE opt_event_config
503 {                                                 662 {
504         struct list_head *list;                   663         struct list_head *list;
505         int err;                                  664         int err;
506                                                   665 
507         list = alloc_list();                      666         list = alloc_list();
508         if (!list)                             !! 667         ABORT_ON(!list);
509                 YYNOMEM;                       !! 668         err = parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4);
510         err = parse_events_add_numeric(_parse_ << 
511                                        /*wildc << 
512         parse_events_terms__delete($4);           669         parse_events_terms__delete($4);
513         if (err) {                                670         if (err) {
514                 free(list);                       671                 free(list);
515                 PE_ABORT(err);                 !! 672                 YYABORT;
516         }                                         673         }
517         $$ = list;                                674         $$ = list;
518 }                                                 675 }
519                                                   676 
520 event_legacy_raw:                                 677 event_legacy_raw:
521 PE_RAW opt_event_config                           678 PE_RAW opt_event_config
522 {                                                 679 {
523         struct list_head *list;                   680         struct list_head *list;
524         int err;                                  681         int err;
525         u64 num;                               << 
526                                                   682 
527         list = alloc_list();                      683         list = alloc_list();
528         if (!list)                             !! 684         ABORT_ON(!list);
529                 YYNOMEM;                       !! 685         err = parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, $1, $2);
530         errno = 0;                             !! 686         parse_events_terms__delete($2);
531         num = strtoull($1 + 1, NULL, 16);      !! 687         if (err) {
532         /* Given the lexer will only give [a-f !! 688                 free(list);
533         if (errno)                             << 
534                 YYABORT;                          689                 YYABORT;
                                                   >> 690         }
                                                   >> 691         $$ = list;
                                                   >> 692 }
                                                   >> 693 
                                                   >> 694 event_bpf_file:
                                                   >> 695 PE_BPF_OBJECT opt_event_config
                                                   >> 696 {
                                                   >> 697         struct parse_events_state *parse_state = _parse_state;
                                                   >> 698         struct list_head *list;
                                                   >> 699         int err;
                                                   >> 700 
                                                   >> 701         list = alloc_list();
                                                   >> 702         ABORT_ON(!list);
                                                   >> 703         err = parse_events_load_bpf(parse_state, list, $1, false, $2);
                                                   >> 704         parse_events_terms__delete($2);
535         free($1);                                 705         free($1);
536         err = parse_events_add_numeric(_parse_ !! 706         if (err) {
537                                        /*wildc !! 707                 free(list);
                                                   >> 708                 YYABORT;
                                                   >> 709         }
                                                   >> 710         $$ = list;
                                                   >> 711 }
                                                   >> 712 |
                                                   >> 713 PE_BPF_SOURCE opt_event_config
                                                   >> 714 {
                                                   >> 715         struct list_head *list;
                                                   >> 716         int err;
                                                   >> 717 
                                                   >> 718         list = alloc_list();
                                                   >> 719         ABORT_ON(!list);
                                                   >> 720         err = parse_events_load_bpf(_parse_state, list, $1, true, $2);
538         parse_events_terms__delete($2);           721         parse_events_terms__delete($2);
539         if (err) {                                722         if (err) {
540                 free(list);                       723                 free(list);
541                 PE_ABORT(err);                 !! 724                 YYABORT;
542         }                                         725         }
543         $$ = list;                                726         $$ = list;
544 }                                                 727 }
545                                                   728 
546 opt_event_config:                                 729 opt_event_config:
547 '/' event_config '/'                              730 '/' event_config '/'
548 {                                                 731 {
549         $$ = $2;                                  732         $$ = $2;
550 }                                                 733 }
551 |                                                 734 |
552 '/' '/'                                           735 '/' '/'
553 {                                                 736 {
554         $$ = NULL;                                737         $$ = NULL;
555 }                                                 738 }
556 |                                                 739 |
557 {                                                 740 {
558         $$ = NULL;                                741         $$ = NULL;
559 }                                                 742 }
560                                                   743 
561 opt_pmu_config:                                   744 opt_pmu_config:
562 '/' event_config '/'                              745 '/' event_config '/'
563 {                                                 746 {
564         $$ = $2;                                  747         $$ = $2;
565 }                                                 748 }
566 |                                                 749 |
567 '/' '/'                                           750 '/' '/'
568 {                                                 751 {
569         $$ = NULL;                                752         $$ = NULL;
570 }                                                 753 }
571                                                   754 
572 start_terms: event_config                         755 start_terms: event_config
573 {                                                 756 {
574         struct parse_events_state *parse_state    757         struct parse_events_state *parse_state = _parse_state;
575         if (parse_state->terms) {                 758         if (parse_state->terms) {
576                 parse_events_terms__delete ($1    759                 parse_events_terms__delete ($1);
577                 YYABORT;                          760                 YYABORT;
578         }                                         761         }
579         parse_state->terms = $1;                  762         parse_state->terms = $1;
580 }                                                 763 }
581                                                   764 
582 event_config:                                     765 event_config:
583 event_config ',' event_term                       766 event_config ',' event_term
584 {                                                 767 {
585         struct parse_events_terms *head = $1;  !! 768         struct list_head *head = $1;
586         struct parse_events_term *term = $3;      769         struct parse_events_term *term = $3;
587                                                   770 
588         if (!head) {                              771         if (!head) {
589                 parse_events_term__delete(term    772                 parse_events_term__delete(term);
590                 YYABORT;                          773                 YYABORT;
591         }                                         774         }
592         list_add_tail(&term->list, &head->term !! 775         list_add_tail(&term->list, head);
593         $$ = $1;                                  776         $$ = $1;
594 }                                                 777 }
595 |                                                 778 |
596 event_term                                        779 event_term
597 {                                                 780 {
598         struct parse_events_terms *head = mall !! 781         struct list_head *head = malloc(sizeof(*head));
599         struct parse_events_term *term = $1;      782         struct parse_events_term *term = $1;
600                                                   783 
601         if (!head)                             !! 784         ABORT_ON(!head);
602                 YYNOMEM;                       !! 785         INIT_LIST_HEAD(head);
603         parse_events_terms__init(head);        !! 786         list_add_tail(&term->list, head);
604         list_add_tail(&term->list, &head->term << 
605         $$ = head;                                787         $$ = head;
606 }                                                 788 }
607                                                   789 
608 name_or_raw: PE_RAW | PE_NAME | PE_LEGACY_CACH << 
609 |                                              << 
610 PE_TERM_HW                                     << 
611 {                                              << 
612         $$ = $1.str;                           << 
613 }                                              << 
614                                                << 
615 event_term:                                       790 event_term:
616 PE_RAW                                            791 PE_RAW
617 {                                                 792 {
618         struct parse_events_term *term;           793         struct parse_events_term *term;
619         int err = parse_events_term__str(&term << 
620                                          strdu << 
621                                                   794 
622         if (err) {                             !! 795         ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_CONFIG,
623                 free($1);                      !! 796                                         NULL, $1, false, &@1, NULL));
624                 PE_ABORT(err);                 << 
625         }                                      << 
626         $$ = term;                                797         $$ = term;
627 }                                                 798 }
628 |                                                 799 |
629 name_or_raw '=' name_or_raw                    !! 800 PE_NAME '=' PE_NAME
630 {                                                 801 {
631         struct parse_events_term *term;           802         struct parse_events_term *term;
632         int err = parse_events_term__str(&term << 
633                                                   803 
634         if (err) {                             !! 804         if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
                                                   >> 805                                         $1, $3, &@1, &@3)) {
635                 free($1);                         806                 free($1);
636                 free($3);                         807                 free($3);
637                 PE_ABORT(err);                 !! 808                 YYABORT;
638         }                                         809         }
639         $$ = term;                                810         $$ = term;
640 }                                                 811 }
641 |                                                 812 |
642 name_or_raw '=' PE_VALUE                       !! 813 PE_NAME '=' PE_VALUE
643 {                                                 814 {
644         struct parse_events_term *term;           815         struct parse_events_term *term;
645         int err = parse_events_term__num(&term << 
646                                          $1, $ << 
647                                                   816 
648         if (err) {                             !! 817         if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
                                                   >> 818                                         $1, $3, false, &@1, &@3)) {
649                 free($1);                         819                 free($1);
650                 PE_ABORT(err);                 !! 820                 YYABORT;
651         }                                         821         }
652         $$ = term;                                822         $$ = term;
653 }                                                 823 }
654 |                                                 824 |
655 PE_LEGACY_CACHE                                !! 825 PE_NAME '=' PE_VALUE_SYM_HW
656 {                                                 826 {
657         struct parse_events_term *term;           827         struct parse_events_term *term;
658         int err = parse_events_term__num(&term !! 828         int config = $3 & 255;
659                                          $1, / << 
660                                                   829 
661         if (err) {                             !! 830         if (parse_events_term__sym_hw(&term, $1, config)) {
662                 free($1);                         831                 free($1);
663                 PE_ABORT(err);                 !! 832                 YYABORT;
664         }                                         833         }
665         $$ = term;                                834         $$ = term;
666 }                                                 835 }
667 |                                                 836 |
668 PE_NAME                                           837 PE_NAME
669 {                                                 838 {
670         struct parse_events_term *term;           839         struct parse_events_term *term;
671         int err = parse_events_term__num(&term << 
672                                          $1, / << 
673                                                   840 
674         if (err) {                             !! 841         if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
                                                   >> 842                                         $1, 1, true, &@1, NULL)) {
675                 free($1);                         843                 free($1);
676                 PE_ABORT(err);                 !! 844                 YYABORT;
677         }                                         845         }
678         $$ = term;                                846         $$ = term;
679 }                                                 847 }
680 |                                                 848 |
681 PE_TERM_HW                                     !! 849 PE_VALUE_SYM_HW
682 {                                                 850 {
683         struct parse_events_term *term;           851         struct parse_events_term *term;
684         int err = parse_events_term__num(&term !! 852         int config = $1 & 255;
685                                          $1.st << 
686                                          &@1,  << 
687                                                   853 
688         if (err) {                             !! 854         ABORT_ON(parse_events_term__sym_hw(&term, NULL, config));
689                 free($1.str);                  << 
690                 PE_ABORT(err);                 << 
691         }                                      << 
692         $$ = term;                                855         $$ = term;
693 }                                                 856 }
694 |                                                 857 |
695 PE_TERM '=' name_or_raw                        !! 858 PE_TERM '=' PE_NAME
696 {                                                 859 {
697         struct parse_events_term *term;           860         struct parse_events_term *term;
698         int err = parse_events_term__str(&term << 
699                                                   861 
700         if (err) {                             !! 862         if (parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3)) {
701                 free($3);                         863                 free($3);
702                 PE_ABORT(err);                 !! 864                 YYABORT;
703         }                                         865         }
704         $$ = term;                                866         $$ = term;
705 }                                                 867 }
706 |                                                 868 |
707 PE_TERM '=' PE_TERM                            !! 869 PE_TERM '=' PE_VALUE
708 {                                                 870 {
709         struct parse_events_term *term;           871         struct parse_events_term *term;
710         int err = parse_events_term__term(&ter << 
711                                                << 
712         if (err)                               << 
713                 PE_ABORT(err);                 << 
714                                                   872 
                                                   >> 873         ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, false, &@1, &@3));
715         $$ = term;                                874         $$ = term;
716 }                                                 875 }
717 |                                                 876 |
718 PE_TERM '=' PE_VALUE                           !! 877 PE_TERM
719 {                                                 878 {
720         struct parse_events_term *term;           879         struct parse_events_term *term;
721         int err = parse_events_term__num(&term << 
722                                          /*con << 
723                                          &@1,  << 
724                                                << 
725         if (err)                               << 
726                 PE_ABORT(err);                 << 
727                                                   880 
                                                   >> 881         ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, true, &@1, NULL));
728         $$ = term;                                882         $$ = term;
729 }                                                 883 }
730 |                                                 884 |
731 PE_TERM                                        !! 885 PE_NAME array '=' PE_NAME
732 {                                                 886 {
733         struct parse_events_term *term;           887         struct parse_events_term *term;
734         int err = parse_events_term__num(&term << 
735                                          /*con << 
736                                          &@1,  << 
737                                                   888 
738         if (err)                               !! 889         if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER,
739                 PE_ABORT(err);                 !! 890                                         $1, $4, &@1, &@4)) {
                                                   >> 891                 free($1);
                                                   >> 892                 free($4);
                                                   >> 893                 free($2.ranges);
                                                   >> 894                 YYABORT;
                                                   >> 895         }
                                                   >> 896         term->array = $2;
                                                   >> 897         $$ = term;
                                                   >> 898 }
                                                   >> 899 |
                                                   >> 900 PE_NAME array '=' PE_VALUE
                                                   >> 901 {
                                                   >> 902         struct parse_events_term *term;
740                                                   903 
                                                   >> 904         if (parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER,
                                                   >> 905                                         $1, $4, false, &@1, &@4)) {
                                                   >> 906                 free($1);
                                                   >> 907                 free($2.ranges);
                                                   >> 908                 YYABORT;
                                                   >> 909         }
                                                   >> 910         term->array = $2;
741         $$ = term;                                911         $$ = term;
742 }                                                 912 }
743 |                                                 913 |
744 PE_DRV_CFG_TERM                                   914 PE_DRV_CFG_TERM
745 {                                                 915 {
746         struct parse_events_term *term;           916         struct parse_events_term *term;
747         char *config = strdup($1);                917         char *config = strdup($1);
748         int err;                               << 
749                                                   918 
750         if (!config)                           !! 919         ABORT_ON(!config);
751                 YYNOMEM;                       !! 920         if (parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG,
752         err = parse_events_term__str(&term, PA !! 921                                         config, $1, &@1, NULL)) {
753         if (err) {                             << 
754                 free($1);                         922                 free($1);
755                 free(config);                     923                 free(config);
756                 PE_ABORT(err);                 !! 924                 YYABORT;
757         }                                         925         }
758         $$ = term;                                926         $$ = term;
759 }                                                 927 }
760                                                   928 
                                                   >> 929 array:
                                                   >> 930 '[' array_terms ']'
                                                   >> 931 {
                                                   >> 932         $$ = $2;
                                                   >> 933 }
                                                   >> 934 |
                                                   >> 935 PE_ARRAY_ALL
                                                   >> 936 {
                                                   >> 937         $$.nr_ranges = 0;
                                                   >> 938         $$.ranges = NULL;
                                                   >> 939 }
                                                   >> 940 
                                                   >> 941 array_terms:
                                                   >> 942 array_terms ',' array_term
                                                   >> 943 {
                                                   >> 944         struct parse_events_array new_array;
                                                   >> 945 
                                                   >> 946         new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges;
                                                   >> 947         new_array.ranges = realloc($1.ranges,
                                                   >> 948                                 sizeof(new_array.ranges[0]) *
                                                   >> 949                                 new_array.nr_ranges);
                                                   >> 950         ABORT_ON(!new_array.ranges);
                                                   >> 951         memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges,
                                                   >> 952                $3.nr_ranges * sizeof(new_array.ranges[0]));
                                                   >> 953         free($3.ranges);
                                                   >> 954         $$ = new_array;
                                                   >> 955 }
                                                   >> 956 |
                                                   >> 957 array_term
                                                   >> 958 
                                                   >> 959 array_term:
                                                   >> 960 PE_VALUE
                                                   >> 961 {
                                                   >> 962         struct parse_events_array array;
                                                   >> 963 
                                                   >> 964         array.nr_ranges = 1;
                                                   >> 965         array.ranges = malloc(sizeof(array.ranges[0]));
                                                   >> 966         ABORT_ON(!array.ranges);
                                                   >> 967         array.ranges[0].start = $1;
                                                   >> 968         array.ranges[0].length = 1;
                                                   >> 969         $$ = array;
                                                   >> 970 }
                                                   >> 971 |
                                                   >> 972 PE_VALUE PE_ARRAY_RANGE PE_VALUE
                                                   >> 973 {
                                                   >> 974         struct parse_events_array array;
                                                   >> 975 
                                                   >> 976         ABORT_ON($3 < $1);
                                                   >> 977         array.nr_ranges = 1;
                                                   >> 978         array.ranges = malloc(sizeof(array.ranges[0]));
                                                   >> 979         ABORT_ON(!array.ranges);
                                                   >> 980         array.ranges[0].start = $1;
                                                   >> 981         array.ranges[0].length = $3 - $1 + 1;
                                                   >> 982         $$ = array;
                                                   >> 983 }
                                                   >> 984 
761 sep_dc: ':' |                                     985 sep_dc: ':' |
762                                                   986 
763 sep_slash_slash_dc: '/' '/' | ':' |               987 sep_slash_slash_dc: '/' '/' | ':' |
764                                                   988 
765 %%                                                989 %%
766                                                   990 
767 void parse_events_error(YYLTYPE *loc, void *_p !! 991 void parse_events_error(YYLTYPE *loc, void *parse_state,
768                         void *scanner __maybe_    992                         void *scanner __maybe_unused,
769                         char const *msg __mayb    993                         char const *msg __maybe_unused)
770 {                                                 994 {
771         struct parse_events_state *parse_state !! 995         parse_events_evlist_error(parse_state, loc->last_column, "parser error");
772                                                << 
773         if (!parse_state->error || !list_empty << 
774                 return;                        << 
775                                                << 
776         parse_events_error__handle(parse_state << 
777                                    strdup("Unr << 
778 }                                                 996 }
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php