public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Aaron Merey <amerey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb/elfread.c: Use bfd filename instead of objfile->original_name
Date: Wed, 31 Aug 2022 00:22:33 +0000 (GMT)	[thread overview]
Message-ID: <20220831002233.A7708383A21A@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=803584b96d97e1f6ea50b0a0064d2a03ab0baa60

commit 803584b96d97e1f6ea50b0a0064d2a03ab0baa60
Author: Aaron Merey <amerey@redhat.com>
Date:   Tue Aug 30 20:18:11 2022 -0400

    gdb/elfread.c: Use bfd filename instead of objfile->original_name
    
    The call to debuginfod_debuginfo_query in elf_symfile_read is given
    objfile->original_name as the filename to print when downloading the
    objfile's debuginfo.
    
    In some cases original_name is prefixed with gdb's working directory
    even though the objfile is not located in the working directory. This
    causes debuginfod to display the wrong path of the objfile during a download.
    
    Fix this by using the objfile's bfd filename instead.

Diff:
---
 gdb/elfread.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/elfread.c b/gdb/elfread.c
index 08db208ebbb..13dbaf0227a 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1279,13 +1279,14 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 	  has_dwarf2 = false;
 	  const struct bfd_build_id *build_id
 	    = build_id_bfd_get (objfile->obfd.get ());
+	  const char *filename = bfd_get_filename (objfile->obfd.get ());
 
 	  if (build_id != nullptr)
 	    {
 	      gdb::unique_xmalloc_ptr<char> symfile_path;
 	      scoped_fd fd (debuginfod_debuginfo_query (build_id->data,
 							build_id->size,
-							objfile->original_name,
+							filename,
 							&symfile_path));
 
 	      if (fd.get () >= 0)
@@ -1295,7 +1296,7 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 
 		  if (debug_bfd == nullptr)
 		    warning (_("File \"%s\" from debuginfod cannot be opened as bfd"),
-			     objfile->original_name);
+			     filename);
 		  else if (build_id_verify (debug_bfd.get (), build_id->size, build_id->data))
 		    {
 		      symbol_file_add_separate (debug_bfd, symfile_path.get (),

                 reply	other threads:[~2022-08-31  0:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220831002233.A7708383A21A@sourceware.org \
    --to=amerey@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).