Bug 31806 - [gdb/symtab] debuginfod query can fail silently
Summary: [gdb/symtab] debuginfod query can fail silently
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: 14.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-27 14:22 UTC by Tom de Vries
Modified: 2024-05-28 08:48 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2024-05-27 14:22:45 UTC
Using a 14.2 based package, I ran into:
...
(gdb) core /home/abuild/rpmbuild/BUILD/gdb-14.2/build-x86_64-suse-linux/gdb/testsuite.unix.-m64/outputs/gdb.debuginfod/fetch_src_and_symbols/corefile^M
^M
This GDB supports auto-downloading debuginfo from the following URLs:^M
  <http://127.0.0.1:8002>^M
Enable debuginfod for this session? (y or [n]) y^M
Debuginfod has been enabled.^M
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.^M
Downloading executable for /home/abuild/rpmbuild/BUILD/gdb-14.2/build-x86_64-suse-linux/gdb/testsuite.unix.-m64/outputs/gdb.debuginfod/fetch_src_and_symbols/fetch_src_and_symbols2...^M
warning: Can't open file /home/abuild/rpmbuild/BUILD/gdb-14.2/build-x86_64-suse-linux/gdb/testsuite.unix.-m64/outputs/gdb.debuginfod/fetch_src_and_symbols/fetch_src_and_symbols2 during file-backed mapping note processing^M
[New LWP 11699]^M
Core was generated by `/home/abuild/rpmbuild/BUILD/gdb-14.2/build-x86_64-suse-linux/gdb/testsuite.unix.'.^M
Program terminated with signal SIGTRAP, Trace/breakpoint trap.^M
#0  0x000055555555468d in ?? ()^M
(gdb) FAIL: gdb.debuginfod/fetch_src_and_symbols.exp: local_url: file corefile
...

AFAICT, everything is going well until the "Downloading" executable message, issued by this debuginfod_exec_query in core_target::build_file_mappings:
...
            if (expanded_fname == nullptr && build_id != nullptr)
              debuginfod_exec_query (build_id->data, build_id->size,
                                     filename, &expanded_fname);

            if (expanded_fname == nullptr)
              {
                m_core_unavailable_mappings.emplace_back (start, end - start);
                unavailable_paths.insert (filename);
                warning (_("Can't open file %s during file-backed mapping "
                           "note processing"),
                         filename);
                return;
              }
...

But somehow it returns with expanded_fname nullptr, after which we see the warning.

The query returns a scoped fd, and if it's negative it represents an errno.

If the errno is not ENOENT, the query will have issued a message in print_outcome:
...
static void
print_outcome (int fd, const char *desc, const char *fname)
{
  if (fd < 0 && fd != -ENOENT)
    {
      ui_file *outstream = get_unbuffered (gdb_stdout);
      gdb_printf (outstream,
                  _("Download failed: %s.  Continuing without %s %ps.\n"),
                  safe_strerror (-fd),
                  desc,
                  styled_string (file_name_style.style (), fname));
    }
}
...

But otherwise, the download fails silently, and you have to read the source code to understand why.

This is a reasonable default for general usage.

But for test-cases it's useful to be more verbose, to get more info for rare and hard-to-reproduce fails.

I think this is a reasonable default for
Comment 1 Tom de Vries 2024-05-27 14:23:34 UTC
This patch series improves things somewhat: https://sourceware.org/pipermail/gdb-patches/2024-May/209428.html
Comment 2 Tom de Vries 2024-05-28 08:48:05 UTC
I think this is another instance of the same problem:
...
(gdb) file /home/abuild/rpmbuild/BUILD/gdb-14.2/build-x86_64-suse-linux/gdb/testsuite.unix.-m32.-fno-PIE.-no-pie/outputs/gdb.debuginfod/crc_mismatch/crc_mismatch-2^M
Reading symbols from /home/abuild/rpmbuild/BUILD/gdb-14.2/build-x86_64-suse-linux/gdb/testsuite.unix.-m32.-fno-PIE.-no-pie/outputs/gdb.debuginfod/crc_mismatch/crc_mismatch-2...^M
Downloading separate debug info for /home/abuild/rpmbuild/BUILD/gdb-14.2/build-x86_64-suse-linux/gdb/testsuite.unix.-m32.-fno-PIE.-no-pie/outputs/gdb.debuginfod/crc_mismatch/crc_mismatch-2...^M
warning: the debug information found in "/home/abuild/rpmbuild/BUILD/gdb-14.2/build-x86_64-suse-linux/gdb/testsuite.unix.-m32.-fno-PIE.-no-pie/outputs/gdb.debuginfod/crc_mismatch/crc_mismatch-2.debug" does not match "/home/abuild/rpmbuild/BUILD/gdb-14.2/build-x86_64-suse-linux/gdb/testsuite.unix.-m32.-fno-PIE.-no-pie/outputs/gdb.debuginfod/crc_mismatch/crc_mismatch-2" (CRC mismatch).^M
(No debugging symbols found in /home/abuild/rpmbuild/BUILD/gdb-14.2/build-x86_64-suse-linux/gdb/testsuite.unix.-m32.-fno-PIE.-no-pie/outputs/gdb.debuginfod/crc_mismatch/crc_mismatch-2)^M
(gdb) FAIL: gdb.debuginfod/crc_mismatch.exp: local_debuginfod: debuginfod running, info downloaded, no CRC mismatch
...