~ [ 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.11.22)


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

~ [ 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