Re: [PATCH 3/3] perf parse: Allow names to start with digits

From: Ian Rogers
Date: Sun Apr 07 2024 - 14:33:12 EST


On Sun, Apr 7, 2024 at 5:38 AM Dominique Martinet
<asmadeus@xxxxxxxxxxxxx> wrote:
>
> Dominique Martinet wrote on Sun, Apr 07, 2024 at 09:18:21PM +0900:
> > diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
> > index e86c45675e1d..41c30ff29783 100644
> > --- a/tools/perf/util/parse-events.l
> > +++ b/tools/perf/util/parse-events.l
> > @@ -158,7 +158,7 @@ event [^,{}/]+
> > num_dec [0-9]+
> > num_hex 0x[a-fA-F0-9]{1,16}
> > num_raw_hex [a-fA-F0-9]{1,16}
> > -name [a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]!\-]*
> > +name [a-zA-Z0-9_*?\[\]][a-zA-Z0-9_*?.\[\]!\-]*
>
> grmbl sorry I guess I didn't actually test this two years ago (?!), or
> used it differently (commit message is weird and also needs fixing,
> perf probe -e 9p:* does not make sense) or something changed but
> that's not enough:
>
> ----
> $ sudo ./perf trace -e 9p:9p_fid_ref
> event syntax error: '9p:9p_fid_ref'
> \___ parser error
> Run 'perf list' for a list of valid events
> ----
>
> Adding 0-9 to name_tag as well makes perf trace works.
>
> I'm not sure what name_minus is for but I did't need to add that one in
> my test.
>
> That also highlights that the test I added isn't sufficient, if someone
> familiar with the code could hint at a better place to test please tell!
> Otherwise I'll have a look next weekend, I need to get back to my 9p
> bugs now I've got a working perf command..
>
> > name_tag [\'][a-zA-Z_*?\[\]][a-zA-Z0-9_*?\-,\.\[\]:=]*[\']
> > name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.:]*
> > drv_cfg_term [a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)?
> >

Try adding PARSER_DEBUG=1 to your command line, I need to do the following:
```
$ make EXTRA_CFLAGS="-Wno-error=redundant-decls" PARSER_DEBUG=1
```
For your example it seems to parse with the changes, but I see (which
should be expected):
```
event syntax error: '9p:9p_fid_ref'
\___ unknown tracepoint

Error: File /sys/kernel/tracing//events/9p/9p_fid_ref not found.
Hint: Perhaps this kernel misses some CONFIG_ setting to enable this feature?.

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
```
I think Jiri's e-mail should be jolsa@xxxxxxxxxx.

Thanks,
Ian

> --
> Dominique Martinet | Asmadeus