diff options
Diffstat (limited to 'libdwfl/find-debuginfo.c')
-rw-r--r-- | libdwfl/find-debuginfo.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c index 40857645..449df5a1 100644 --- a/libdwfl/find-debuginfo.c +++ b/libdwfl/find-debuginfo.c @@ -355,9 +355,12 @@ dwfl_standard_find_debuginfo (Dwfl_Module *mod, GElf_Word debuglink_crc, char **debuginfo_file_name) { + if (mod == NULL) + return -1; + /* First try by build ID if we have one. If that succeeds or fails other than just by finding nothing, that's all we do. */ - const unsigned char *bits; + const unsigned char *bits = NULL; GElf_Addr vaddr; int bits_len; if ((bits_len = INTUSE(dwfl_module_build_id) (mod, &bits, &vaddr)) > 0) @@ -398,8 +401,29 @@ 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); +#ifdef ENABLE_LIBDEBUGINFOD + /* 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); + } +#endif return fd; } |