Hi Roland,

On Wed, 2023-05-31 at 16:44 -0700, Roland McGrath via Elfutils-devel
wrote:
> In elfutils, the libdwfl library is responsible for the "library for
> obtaining debug info writ large" stuff. It provides <argp.h> API parsers
> for command-line arguments that mesh with its library stuff like
> Dwfl_Callbacks that set the search path used equivalently to GDB's `set
> debug-file-directory` path. eu-* tools as well as things like systemtap use
> this to accept `--debuginfo-path=PATH`, but AFAIK none of them support
> environment variables.  In the binutils world outside of GDB itself, I
> think only objdump and readelf do .build-id/... lookup and those use common
> binutils-private code (binutils/dwarf.c) that just has a hard-coded
> directory list.  Some more uniformity here would be beneficial to everyone,
> I think.

One difference is that the elfutils and gdb traditional "search path"
mechanism is mainly based on path/file names (lookups through
.gnu_debuglink, possibly relative .debug dirs/files) while the primary
lookup method for libdebuginfod is based on build-id.

libdebuginfod kind of assumes you already know the traditional lookup
didn't work.

That is also how dwfl_standard_find_debuginfo uses libdebuginfod. It
first gets the build-id from the ELF file, looks for that in the
traditional way (/usr/lib/debug/.build-id/xx/yyyy.debug), if that fails
it does a path based search (using the file name, debuglink file name
and Dwfl_Callbacks debuginfo_path), and if that also fails then it
tries to use libdebuginfod.

Another difference is the lookup of .dwz files. Since they contain an
"artificial" build-id, libdebuginfod uses that to look them up as if a
"normal" .debug file. While the traditional lookup uses the (relative!)
path in the .gnu_debugaltlink section of the .debug file.

I wonder which parts of the "traditional" lookup are still
useful/relevant. Could we get away with pointing at a "traditional"
/usr/lib/debug/ like path that contains a .build-id and (optional) .dwz
subdir to make libdebuginfo that "uniform" debug file lookup library?

Cheers,

Mark

Reply via email to