Re: [PATCH v2] perf: fix the probe finder location (.dwo files)

Namhyung Kim
2022-10-04T18:54:36Z

Cc + Masami

On Mon, Oct 3, 2022 at 11:10 AM Henry Castro <hcvcastro@gmail.com> wrote:
>
> If the file object is compiled using -gsplit-dwarf,
> the probe finder location will fail.
>
> Signed-off-by: Henry Castro <hcvcastro@gmail.com>
> ---
>
> > Anyway I think it'd be safer to do
> >
> > if (dwarf_cu_info() == 0 && unit_type == skeleton)
> > pf->cu_die = subdie;
>
> Thank you, I have modifed the patch :)
>
>
> tools/perf/util/probe-finder.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
> index 50d861a80f57..b27039f5f04b 100644
> --- a/tools/perf/util/probe-finder.c
> +++ b/tools/perf/util/probe-finder.c
> @@ -1161,7 +1161,8 @@ static int debuginfo__find_probe_location(struct debuginfo *dbg,
> struct perf_probe_point *pp = &pf->pev->point;
> Dwarf_Off off, noff;
> size_t cuhl;
> - Dwarf_Die *diep;
> + Dwarf_Die *diep, cudie, subdie;
> + uint8_t unit_type;

They will be unused for earlier elfutils.

> int ret = 0;
>
> off = 0;
> @@ -1200,6 +1201,14 @@ static int debuginfo__find_probe_location(struct debuginfo *dbg,
> continue;
> }
>
> +#if _ELFUTILS_VERSION >= 171

Nit, I think we use _ELFUTILS_PREREQ(0, 171).

> + /* Check separate debug information file. */
> + if (dwarf_cu_info(pf->cu_die.cu, NULL, &unit_type,
> + &cudie, &subdie, NULL, NULL, NULL) == 0
> + && unit_type == DW_UT_skeleton)
> + pf->cu_die = subdie;
> +#endif

How about making it a separate function with 2 versions
depending on the elfutils? Then you can have the variables
only if they are used.

Something like get_source_from_debuginfod() in the same
file.

Thanks,
Namhyung

> +
> /* Check if target file is included. */
> if (pp->file)
> pf->fname = cu_find_realpath(&pf->cu_die, pp->file);
> --
> 2.20.1
>