Re: [PATCH perf/core v4 18/19] perf probe: Allow wildcard for cached events

From: Masami Hiramatsu
Date: Wed Apr 27 2016 - 14:51:39 EST


On Wed, 27 Apr 2016 21:04:53 +0530
Hemant Kumar <hemant@xxxxxxxxxxxxxxxxxx> wrote:

>
>
> On 04/26/2016 02:34 PM, Masami Hiramatsu wrote:
> > Allo glob wildcard for reusing cached/SDT events. This also
> > automatically find the target binaries, e.g.
> >
> > # perf probe -a %sdt_libc:\*
> >
> > This example adds probes for all SDT in libc.
> > Note that the SDTs must have been scanned by perf buildid-cache.
>
> There is a segfault after applying this patch :
>
> # perf probe -x /home/hemant/test %marker1
> Segmentation fault (core dumped)
>
> The problem is there is no group name with this marker and
> strglobmatch tries to match entry->pev.group with pev->group (which is
> NULL).

Thank you for testing!

[...]
> > +/* Try to find probe_trace_event from given probe caches */
> > +static int find_cached_events(struct perf_probe_event *pev,
> > + struct probe_trace_event **tevs,
> > + const char *target)
> > +{
> > + struct probe_cache *cache;
> > + struct probe_cache_entry *entry;
> > + struct probe_trace_event *tmp_tevs = NULL;
> > + int ntevs = 0;
> > + int ret = 0;
> > +
> > + cache = probe_cache__new(target);
> > + if (!cache)
> > + return -ENOENT;
> > +
> > + for_each_probe_cache_entry(entry, cache) {
> > + /* Skip the cache entry which has no name */
> > + if (!entry->pev.event || !entry->pev.group)
> > + continue;
> > + if (strglobmatch(entry->pev.group, pev->group) &&
> > + strglobmatch(entry->pev.event, pev->event)) {
>
> Due to the above issue, we can change the above condition to :
> if (strglobmatch(entry->pev.event, pev->event) {
> if (!pev->group || (pev->group && strglobmatch(entry->pev.group,
> pev->group)))
> // Do stuff
> }

OK, I'll fix that.

thanks!!

--
Masami Hiramatsu <mhiramat@xxxxxxxxxx>