Re: [PATCH v3 0/3] perf srcline: Fix addr2line cache and fallback bugs

From: Arnaldo Carvalho de Melo

Date: Fri Sep 18 2026 - 16:25:50 EST


On Wed, Sep 16, 2026 at 04:43:59PM -0700, Ian Rogers wrote:
> Three fixes to source line resolution, all on the addr2line paths.
>
> 1) libdw is pointed at the wrong file. dso__libdw_dwfl() opens the Dwfl
> with the name of the file the samples came from, but when the debug
> information is in a separate file, symbol loading records that as the
> dso's symsrc filename and the Dwfl is left referring to a file with
> no DWARF in it.
>
> 2) The dso addr2line cache is shared between implementations. The libbfd
> reader caches a struct a2l_data and the command line fallback caches
> a struct child_process through the same pointer, so once a dso has
> fallen back from one to the other the cached object is read back as
> the wrong type.
>
> 3) libbfd only reports success when the caller asked for a file name.
> addr2inlines() doesn't, so srcline.c treats a resolved address as a
> failure and tries the next implementation, which appends its own
> frames to the ones libbfd already appended. Every frame that isn't
> inlined is then reported twice. This is the default when perf is
> built with libbfd but without libdw:
>
> $ perf record --call-graph dwarf -- perf test -w inlineloop 1
> $ perf script --fields +srcline
> ...
> 56051a99503a inlineloop+0x8a (perf)
> inlineloop.c:47
> 56051a99503a inlineloop+0x8a (perf)
> inlineloop.c:47
> ...
>
> With addr2line.style set to "libbfd,addr2line" so the fallback is
> taken, the script output for that workload drops from 288 lines to
> 176, and each repeated frame goes from appearing 16 times to 8.

Thanks, applied to perf-tools-next, for v7.4.

- Arnaldo