From patchwork Thu Nov 7 23:24:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Merey X-Patchwork-Id: 35736 Received: (qmail 107956 invoked by alias); 7 Nov 2019 23:24:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 107922 invoked by uid 89); 7 Nov 2019 23:24:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=tracing, UD:selftest.h, selftesth, selftest.h X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Nov 2019 23:24:47 +0000 Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 699AB859FB for ; Thu, 7 Nov 2019 23:24:46 +0000 (UTC) Received: by mail-vk1-f199.google.com with SMTP id f73so1869759vka.4 for ; Thu, 07 Nov 2019 15:24:46 -0800 (PST) MIME-Version: 1.0 References: <20190820202809.25367-1-amerey@redhat.com> <87pnj6dl3k.fsf@tromey.com> <87sgn71ji6.fsf@tromey.com> <87lfsye5l5.fsf@redhat.com> <87bltrelab.fsf@redhat.com> <20191104162616.GA13319@redhat.com> In-Reply-To: From: Aaron Merey Date: Thu, 7 Nov 2019 18:24:34 -0500 Message-ID: Subject: Re: [RFC PATCH] Support debuginfo and source file fetching via debuginfo server To: Tom Tromey Cc: Simon Marchi , Christian Biesinger via gdb-patches , Christian Biesinger , Frank Eigler 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 --- 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