Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Aaron Merey <amerey@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: Simon Marchi <simark@simark.ca>,
		Christian Biesinger via gdb-patches <gdb-patches@sourceware.org>,
	Christian Biesinger <cbiesinger@google.com>,
		Frank Eigler <fche@redhat.com>
Subject: Re: [RFC PATCH] Support debuginfo and source file fetching via debuginfo server
Date: Thu, 07 Nov 2019 23:24:00 -0000	[thread overview]
Message-ID: <CAJDtP-Q9gET5cn-qphbkgT0MsPx-a1mDGA6HxTzScUtGDC3Vsg@mail.gmail.com> (raw)
In-Reply-To: <CAJDtP-S6DpxEGG=T01h5_O8nbYYme1+ErJhcfJEomHBm2OObKQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 453 bytes --]

Here's a patch that adds debuginfod queries for dwz files when they
otherwise cannot be found. It's very similar to the normal debuginfo
lookup code. With this libdebuginfod now hooks into three functions
in gdb: dwarf2_get_dwz_file, open_source_file and elf_symfile_read.
Does anyone know of any code paths that gdb might take when
searching for dwz, source files, or separate DWARF debuginfo that
bypass all of the current libdebuginfod calls?

Aaron

[-- Attachment #2: dwz_lookups.patch --]
[-- Type: text/x-patch, Size: 1820 bytes --]

---
 gdb/dwarf2read.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 0a7a033420..d0cc5f327b 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -77,6 +77,9 @@
 #include "gdbsupport/selftest.h"
 #include "rust-lang.h"
 #include "gdbsupport/pathstuff.h"
+#if HAVE_LIBDEBUGINFOD
+#include "elfutils/debuginfod.h"
+#endif
 
 /* When == 1, print basic high level tracing messages.
    When > 1, be more verbose.
@@ -2714,6 +2717,38 @@ dwarf2_get_dwz_file (struct dwarf2_per_objfile *dwarf2_per_objfile)
   if (dwz_bfd == NULL)
     dwz_bfd = build_id_to_debug_bfd (buildid_len, buildid);
 
+#if HAVE_LIBDEBUGINFOD
+  if (dwz_bfd == NULL)
+    {
+      /* Query debuginfod servers for the dwz file.  */
+      char *alt_filename;
+
+      /* Allow debuginfod to abort the download if SIGINT is raised.  */
+      debuginfod_set_progressfn(
+        [] (long a, long b) { return 1 ? check_quit_flag () : 0; }
+      );
+
+      /* Query debuginfod servers for symfile.  */
+      scoped_fd fd (debuginfod_find_debuginfo (buildid,
+                                               buildid_len,
+                                               &alt_filename));
+
+      if (fd.get () >= 0)
+        {
+          /* File successfully retrieved from server.  */
+          dwz_bfd = gdb_bfd_open (alt_filename, gnutarget, -1);
+
+          if(dwz_bfd != NULL)
+            {
+              if (!build_id_verify (dwz_bfd.get (), buildid_len, buildid))
+                dwz_bfd.reset (nullptr);
+            }
+
+          xfree (alt_filename);
+        }
+    }
+#endif /* HAVE_LIBDEBUGINFOD */
+
   if (dwz_bfd == NULL)
     error (_("could not find '.gnu_debugaltlink' file for %s"),
 	   objfile_name (dwarf2_per_objfile->objfile));
-- 
2.21.0

      parent reply	other threads:[~2019-11-07 23:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-20 20:28 Aaron Merey
2019-09-13 21:03 ` Tom Tromey
2019-09-22  3:53 ` Christian Biesinger via gdb-patches
2019-10-09 14:55   ` Tom Tromey
2019-10-28 20:34     ` Aaron Merey
2019-11-01 19:31       ` Tom Tromey
2019-11-01 21:03         ` Aaron Merey
2019-11-02 14:05           ` Frank Ch. Eigler
2019-11-04 15:03             ` Frank Ch. Eigler
2019-11-04 15:46               ` Simon Marchi
2019-11-04 16:26                 ` Frank Ch. Eigler
2019-11-05  1:59                   ` Aaron Merey
2019-11-05  5:27                     ` Simon Marchi
2019-11-05 10:25                       ` Frank Ch. Eigler
2019-11-05 15:19                         ` Simon Marchi
2019-11-05 15:50                           ` Frank Ch. Eigler
2019-11-05  5:35                     ` Simon Marchi
2019-11-07 23:24                     ` Aaron Merey [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJDtP-Q9gET5cn-qphbkgT0MsPx-a1mDGA6HxTzScUtGDC3Vsg@mail.gmail.com \
    --to=amerey@redhat.com \
    --cc=cbiesinger@google.com \
    --cc=fche@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox