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


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

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