From: Mark Wielaard Date: Thu, 30 Apr 2020 21:57:26 +0000 (+0200) Subject: libdwfl: Handle debugaltlink in dwfl_standard_find_debuginfo. X-Git-Tag: elfutils-0.180~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b1d2404cc6ca0d9ce786e229a87c24db49163cfe;p=thirdparty%2Felfutils.git libdwfl: Handle debugaltlink in dwfl_standard_find_debuginfo. When we fall back to the debuginfod client then we need to do the same trick we do for local lookups in dwfl_build_id_find_debuginfo. If the debug file (dw) is already set, then we must be looking for the altfile. But we cannot use the actual file/path name given as hint. We'll have to lookup the alt file "build-id". Because the debuginfod client only handles build-ids. Previously we would use the build-id of the main file which meant the debuginfod client would give us another copy of the debug file, which would then be set as its own altfile. This caused lots of confusion... Signed-off-by: Mark Wielaard --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index daedaed8f..3f9cd6659 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,8 @@ +2020-04-30 Mark Wielaard + + * find-debuginfo.c (dwfl_standard_find_debuginfo): When mod->dw + is already set then try fetching debugaltlink. + 2020-04-25 Mark Wielaard * gzip.c (open_stream): Return DWFL_E_NOMEM instead of calling diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c index 2dd11c48d..4cfd0b8b2 100644 --- a/libdwfl/find-debuginfo.c +++ b/libdwfl/find-debuginfo.c @@ -398,8 +398,27 @@ dwfl_standard_find_debuginfo (Dwfl_Module *mod, free (canon); } - if (fd < 0 && bits_len > 0) - fd = __libdwfl_debuginfod_find_debuginfo (mod->dwfl, bits, bits_len); + /* Still nothing? Try if we can use the debuginfod client. + But note that we might be looking for the alt file. + We use the same trick as dwfl_build_id_find_debuginfo. + If the debug file (dw) is already set, then we must be + looking for the altfile. But we cannot use the actual + file/path name given as hint. We'll have to lookup the + alt file "build-id". Because the debuginfod client only + handles build-ids. */ + if (fd < 0) + { + if (mod->dw != NULL) + { + const char *altname; + bits_len = INTUSE(dwelf_dwarf_gnu_debugaltlink) (mod->dw, &altname, + (const void **) + &bits); + } + + if (bits_len > 0) + fd = __libdwfl_debuginfod_find_debuginfo (mod->dwfl, bits, bits_len); + } return fd; }