perf parse-events: Additional error reporting
When no events or PMUs match report an error for event_pmu:
Before:
```
$ perf stat -e 'asdfasdf' -a sleep 1
Run 'perf list' for a list of valid events
Usage: perf stat [<options>] [<command>]
-e, --event <event> event selector. use 'perf list' to list available events
```
After:
```
$ perf stat -e 'asdfasdf' -a sleep 1
event syntax error: 'asdfasdf'
\___ Bad event name
Unabled to find PMU or event on a PMU of 'asdfasdf'
Run 'perf list' for a list of valid events
Usage: perf stat [<options>] [<command>]
-e, --event <event> event selector. use 'perf list' to list available events
```
Fixes the inadvertent removal when hybrid parsing was modified.
Fixes: 70c90e4a6b
("perf parse-events: Avoid scanning PMUs before parsing")
Signed-off-by: Ian 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: Ian Rogers <irogers@google.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-11-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
b52cb995f1
commit
b30d4f0b69
@ -291,7 +291,6 @@ PE_NAME opt_pmu_config
|
|||||||
{
|
{
|
||||||
struct parse_events_state *parse_state = _parse_state;
|
struct parse_events_state *parse_state = _parse_state;
|
||||||
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 \
|
#define CLEANUP \
|
||||||
@ -303,9 +302,6 @@ PE_NAME opt_pmu_config
|
|||||||
free(pattern); \
|
free(pattern); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
if (error)
|
|
||||||
error->idx = @1.first_column;
|
|
||||||
|
|
||||||
if (parse_events_copy_term_list($2, &orig_terms)) {
|
if (parse_events_copy_term_list($2, &orig_terms)) {
|
||||||
CLEANUP;
|
CLEANUP;
|
||||||
YYNOMEM;
|
YYNOMEM;
|
||||||
@ -360,6 +356,14 @@ PE_NAME opt_pmu_config
|
|||||||
$2 = NULL;
|
$2 = NULL;
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
|
struct parse_events_error *error = parse_state->error;
|
||||||
|
char *help;
|
||||||
|
|
||||||
|
if (asprintf(&help, "Unabled to find PMU or event on a PMU of '%s'", $1) < 0)
|
||||||
|
help = NULL;
|
||||||
|
parse_events_error__handle(error, @1.first_column,
|
||||||
|
strdup("Bad event or PMU"),
|
||||||
|
help);
|
||||||
CLEANUP;
|
CLEANUP;
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
@ -376,9 +380,18 @@ PE_NAME sep_dc
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = parse_events_multi_pmu_add(_parse_state, $1, NULL, &list);
|
err = parse_events_multi_pmu_add(_parse_state, $1, NULL, &list);
|
||||||
free($1);
|
if (err < 0) {
|
||||||
if (err < 0)
|
struct parse_events_state *parse_state = _parse_state;
|
||||||
|
struct parse_events_error *error = parse_state->error;
|
||||||
|
char *help;
|
||||||
|
|
||||||
|
if (asprintf(&help, "Unabled to find PMU or event on a PMU of '%s'", $1) < 0)
|
||||||
|
help = NULL;
|
||||||
|
parse_events_error__handle(error, @1.first_column, strdup("Bad event name"), help);
|
||||||
|
free($1);
|
||||||
PE_ABORT(err);
|
PE_ABORT(err);
|
||||||
|
}
|
||||||
|
free($1);
|
||||||
$$ = list;
|
$$ = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user