Re: [PATCH bpf-next 10/13] selftests/bpf: Add uprobe/usdt optimized test

Jiri Olsa
2024-12-16T07:58:38Z

On Fri, Dec 13, 2024 at 01:58:38PM -0800, Andrii Nakryiko wrote:

SNIP

> > +static int find_uprobes_trampoline(void **start, void **end)
> > +{
> > + char line[128];
> > + int ret = -1;
> > + FILE *maps;
> > +
> > + maps = fopen("/proc/self/maps", "r");
> > + if (!maps) {
> > + fprintf(stderr, "cannot open maps\n");
> > + return -1;
> > + }
> > +
> > + while (fgets(line, sizeof(line), maps)) {
> > + int m = -1;
> > +
> > + /* We care only about private r-x mappings. */
> > + if (sscanf(line, "%p-%p r-xp %*x %*x:%*x %*u %n", start, end, &m) != 2)
> > + continue;
> > + if (m < 0)
> > + continue;
> > + if (!strncmp(&line[m], TRAMP, sizeof(TRAMP)-1)) {
> > + ret = 0;
> > + break;
> > + }
> > + }
>
> you could have used PROCMAP_QUERY ;)

true ;-) will check on that in new version

thanks,
jirka

>
> > +
> > + fclose(maps);
> > + return ret;
> > +}
> > +
>
> …