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

perf parse-events: Inline parse_events_evlist_error

Inline parse_events_evlist_error that is only used in
parse_events_error. Modify parse_events_error to not report a parser
error unless errors haven't already been reported. Make it clearer
that the latter case only happens for unrecognized input.

Before:

  $ perf stat -e 'cycles/period=99999999999999999999/' true
  event syntax error: 'cycles/period=99999999999999999999/'
                                    \___ parser error

  event syntax error: '..les/period=99999999999999999999/'
                                    \___ Bad base 10 number "99999999999999999999"
  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
  $ perf stat -e 'cycles:xyz' true
  event syntax error: 'cycles:xyz'
                             \___ parser error
  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 'cycles/period=99999999999999999999/xyz' true
  event syntax error: '..les/period=99999999999999999999/xyz'
                                    \___ Bad base 10 number "99999999999999999999"
  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
  $ perf stat -e 'cycles:xyz' true
  event syntax error: 'cycles:xyz'
                             \___ Unrecognized input
  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
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
Tested-by: default avatarAtish Patra <atishp@rivosinc.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Beeman Strong <beeman@rivosinc.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240416061533.921723-13-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ba5c371e
...@@ -2760,15 +2760,6 @@ int parse_events_terms__to_strbuf(const struct parse_events_terms *terms, struct ...@@ -2760,15 +2760,6 @@ int parse_events_terms__to_strbuf(const struct parse_events_terms *terms, struct
return 0; return 0;
} }
void parse_events_evlist_error(struct parse_events_state *parse_state,
int idx, const char *str)
{
if (!parse_state->error)
return;
parse_events_error__handle(parse_state->error, idx, strdup(str), NULL);
}
static void config_terms_list(char *buf, size_t buf_sz) static void config_terms_list(char *buf, size_t buf_sz)
{ {
int i; int i;
......
...@@ -226,8 +226,6 @@ int parse_events_multi_pmu_add_or_add_pmu(struct parse_events_state *parse_state ...@@ -226,8 +226,6 @@ int parse_events_multi_pmu_add_or_add_pmu(struct parse_events_state *parse_state
void *loc_); void *loc_);
void parse_events__set_leader(char *name, struct list_head *list); void parse_events__set_leader(char *name, struct list_head *list);
void parse_events_evlist_error(struct parse_events_state *parse_state,
int idx, const char *str);
struct event_symbol { struct event_symbol {
const char *symbol; const char *symbol;
......
...@@ -790,9 +790,15 @@ sep_slash_slash_dc: '/' '/' | ':' | ...@@ -790,9 +790,15 @@ sep_slash_slash_dc: '/' '/' | ':' |
%% %%
void parse_events_error(YYLTYPE *loc, void *parse_state, void parse_events_error(YYLTYPE *loc, void *_parse_state,
void *scanner __maybe_unused, void *scanner __maybe_unused,
char const *msg __maybe_unused) char const *msg __maybe_unused)
{ {
parse_events_evlist_error(parse_state, loc->last_column, "parser error"); struct parse_events_state *parse_state = _parse_state;
if (!parse_state->error || !list_empty(&parse_state->error->list))
return;
parse_events_error__handle(parse_state->error, loc->last_column,
strdup("Unrecognized input"), NULL);
} }
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