Commit a7a3252d authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf parse-events: Separate YYABORT and YYNOMEM cases

Split cases in event_pmu for greater accuracy.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20230627181030.95608-8-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 9462e4de
...@@ -283,37 +283,42 @@ event_pmu: ...@@ -283,37 +283,42 @@ event_pmu:
PE_NAME opt_pmu_config PE_NAME opt_pmu_config
{ {
struct parse_events_state *parse_state = _parse_state; struct parse_events_state *parse_state = _parse_state;
struct parse_events_error *error = parse_state->error;
struct list_head *list = NULL, *orig_terms = NULL, *terms= NULL; struct list_head *list = NULL, *orig_terms = NULL, *terms= NULL;
struct parse_events_error *error = parse_state->error;
char *pattern = NULL; char *pattern = NULL;
#define CLEANUP_YYABORT \ #define CLEANUP \
do { \ do { \
parse_events_terms__delete($2); \ parse_events_terms__delete($2); \
parse_events_terms__delete(orig_terms); \ parse_events_terms__delete(orig_terms); \
free(list); \ free(list); \
free($1); \ free($1); \
free(pattern); \ free(pattern); \
YYABORT; \
} while(0) } while(0)
if (parse_events_copy_term_list($2, &orig_terms))
CLEANUP_YYABORT;
if (error) if (error)
error->idx = @1.first_column; error->idx = @1.first_column;
if (parse_events_copy_term_list($2, &orig_terms)) {
CLEANUP;
YYNOMEM;
}
list = alloc_list(); list = alloc_list();
if (!list) if (!list) {
CLEANUP_YYABORT; CLEANUP;
YYNOMEM;
}
/* Attempt to add to list assuming $1 is a PMU name. */ /* Attempt to add to list assuming $1 is a PMU name. */
if (parse_events_add_pmu(parse_state, list, $1, $2, /*auto_merge_stats=*/false)) { if (parse_events_add_pmu(parse_state, list, $1, $2, /*auto_merge_stats=*/false)) {
struct perf_pmu *pmu = NULL; struct perf_pmu *pmu = NULL;
int ok = 0; int ok = 0;
/* Failure to add, try wildcard expansion of $1 as a PMU name. */ /* Failure to add, try wildcard expansion of $1 as a PMU name. */
if (asprintf(&pattern, "%s*", $1) < 0) if (asprintf(&pattern, "%s*", $1) < 0) {
CLEANUP_YYABORT; CLEANUP;
YYNOMEM;
}
while ((pmu = perf_pmus__scan(pmu)) != NULL) { while ((pmu = perf_pmus__scan(pmu)) != NULL) {
char *name = pmu->name; char *name = pmu->name;
...@@ -328,8 +333,10 @@ PE_NAME opt_pmu_config ...@@ -328,8 +333,10 @@ PE_NAME opt_pmu_config
!perf_pmu__match(pattern, pmu->alias_name, $1)) { !perf_pmu__match(pattern, pmu->alias_name, $1)) {
bool auto_merge_stats = perf_pmu__auto_merge_stats(pmu); bool auto_merge_stats = perf_pmu__auto_merge_stats(pmu);
if (parse_events_copy_term_list(orig_terms, &terms)) if (parse_events_copy_term_list(orig_terms, &terms)) {
CLEANUP_YYABORT; CLEANUP;
YYNOMEM;
}
if (!parse_events_add_pmu(parse_state, list, pmu->name, terms, if (!parse_events_add_pmu(parse_state, list, pmu->name, terms,
auto_merge_stats)) { auto_merge_stats)) {
ok++; ok++;
...@@ -345,15 +352,15 @@ PE_NAME opt_pmu_config ...@@ -345,15 +352,15 @@ PE_NAME opt_pmu_config
ok = !parse_events_multi_pmu_add(parse_state, $1, $2, &list); ok = !parse_events_multi_pmu_add(parse_state, $1, $2, &list);
$2 = NULL; $2 = NULL;
} }
if (!ok) if (!ok) {
CLEANUP_YYABORT; CLEANUP;
YYABORT;
}
} }
parse_events_terms__delete($2);
parse_events_terms__delete(orig_terms);
free(pattern);
free($1);
$$ = list; $$ = list;
#undef CLEANUP_YYABORT list = NULL;
CLEANUP;
#undef CLEANUP
} }
| |
PE_NAME sep_dc PE_NAME sep_dc
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment