Re: [PATCH] perf tools: report initial event parsing error

From: Ian Rogers
Date: Sat Nov 16 2019 - 02:54:03 EST


On Mon, Nov 11, 2019 at 4:03 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> On Fri, Nov 08, 2019 at 10:15:33AM -0800, Ian Rogers wrote:
> > Record the first event parsing error and report. Implementing feedback
> > from Jiri Olsa:
> > https://lkml.org/lkml/2019/10/28/680
> >
> > An example error is:
> >
> > $ tools/perf/perf stat -e c/c/
> > WARNING: multiple event parsing errors
> > event syntax error: 'c/c/'
> > \___ unknown term
> >
> > valid terms: event,filter_rem,filter_opc0,edge,filter_isoc,filter_tid,filter_loc,filter_nc,inv,umask,filter_opc1,tid_en,thresh,filter_all_op,filter_not_nm,filter_state,filter_nm,config,config1,config2,name,period,percore
> >
> > Initial error:
> > event syntax error: 'c/c/'
> > \___ Cannot find PMU `c'. Missing kernel support?
> > 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: Ian Rogers <irogers@xxxxxxxxxx>
> > ---
> > tools/perf/arch/powerpc/util/kvm-stat.c | 9 ++-
> > tools/perf/builtin-stat.c | 2 +
> > tools/perf/builtin-trace.c | 16 ++++--
> > tools/perf/tests/parse-events.c | 3 +-
> > tools/perf/util/metricgroup.c | 2 +-
> > tools/perf/util/parse-events.c | 76 ++++++++++++++++++-------
> > tools/perf/util/parse-events.h | 4 ++
> > 7 files changed, 84 insertions(+), 28 deletions(-)
> >
> > diff --git a/tools/perf/arch/powerpc/util/kvm-stat.c b/tools/perf/arch/powerpc/util/kvm-stat.c
> > index 9cc1c4a9dec4..30f5310373ca 100644
> > --- a/tools/perf/arch/powerpc/util/kvm-stat.c
> > +++ b/tools/perf/arch/powerpc/util/kvm-stat.c
> > @@ -113,10 +113,15 @@ static int is_tracepoint_available(const char *str, struct evlist *evlist)
> > struct parse_events_error err;
> > int ret;
> >
> > - err.str = NULL;
> > + bzero(&err, sizeof(err));
> > ret = parse_events(evlist, str, &err);
> > - if (err.str)
> > + if (err.str) {
> > pr_err("%s : %s\n", str, err.str);
> > + free(&err->str);
> > + free(&err->help);
> > + free(&err->first_str);
> > + free(&err->first_help);
>
> it's used in other places, so it's better to put it in
> parse_events_error__exit or such..

Done, using parse_events_print_error like other callers. This may
affect the output on error.

Thanks,
Ian

> jirka
>