Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb/elfread.c: Use bfd filename instead of objfile->original_name
@ 2022-04-01 20:07 Aaron Merey via Gdb-patches
  2022-07-05 22:43 ` Aaron Merey via Gdb-patches
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Merey via Gdb-patches @ 2022-04-01 20:07 UTC (permalink / raw)
  To: gdb-patches

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.
---
 gdb/elfread.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/elfread.c b/gdb/elfread.c
index fb40032c505..3554e5d71a2 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1286,13 +1286,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);
+	  const char *filename = bfd_get_filename (objfile->obfd);
 
 	  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)
@@ -1302,7 +1303,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.get (), symfile_path.get (),
-- 
2.35.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gdb/elfread.c: Use bfd filename instead of objfile->original_name
  2022-04-01 20:07 [PATCH] gdb/elfread.c: Use bfd filename instead of objfile->original_name Aaron Merey via Gdb-patches
@ 2022-07-05 22:43 ` Aaron Merey via Gdb-patches
  2022-08-26 21:24   ` [PING][PATCH] " Aaron Merey via Gdb-patches
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Merey via Gdb-patches @ 2022-07-05 22:43 UTC (permalink / raw)
  To: gdb-patches

Ping

Thanks,
Aaron

On Fri, Apr 1, 2022 at 4:08 PM Aaron Merey <amerey@redhat.com> wrote:
>
> 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.
> ---
>  gdb/elfread.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/elfread.c b/gdb/elfread.c
> index fb40032c505..3554e5d71a2 100644
> --- a/gdb/elfread.c
> +++ b/gdb/elfread.c
> @@ -1286,13 +1286,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);
> +         const char *filename = bfd_get_filename (objfile->obfd);
>
>           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)
> @@ -1302,7 +1303,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.get (), symfile_path.get (),
> --
> 2.35.1
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PING][PATCH] gdb/elfread.c: Use bfd filename instead of objfile->original_name
  2022-07-05 22:43 ` Aaron Merey via Gdb-patches
@ 2022-08-26 21:24   ` Aaron Merey via Gdb-patches
  2022-08-30 18:01     ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Merey via Gdb-patches @ 2022-08-26 21:24 UTC (permalink / raw)
  To: gdb-patches

Ping

Thanks,
Aaron

On Tue, Jul 5, 2022 at 6:43 PM Aaron Merey <amerey@redhat.com> wrote:
>
> Ping
>
> Thanks,
> Aaron
>
> On Fri, Apr 1, 2022 at 4:08 PM Aaron Merey <amerey@redhat.com> wrote:
> >
> > 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.
> > ---
> >  gdb/elfread.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/gdb/elfread.c b/gdb/elfread.c
> > index fb40032c505..3554e5d71a2 100644
> > --- a/gdb/elfread.c
> > +++ b/gdb/elfread.c
> > @@ -1286,13 +1286,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);
> > +         const char *filename = bfd_get_filename (objfile->obfd);
> >
> >           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)
> > @@ -1302,7 +1303,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.get (), symfile_path.get (),
> > --
> > 2.35.1
> >


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PING][PATCH] gdb/elfread.c: Use bfd filename instead of objfile->original_name
  2022-08-26 21:24   ` [PING][PATCH] " Aaron Merey via Gdb-patches
@ 2022-08-30 18:01     ` Tom Tromey
  2022-08-31  0:45       ` Aaron Merey via Gdb-patches
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2022-08-30 18:01 UTC (permalink / raw)
  To: Aaron Merey via Gdb-patches

>>>>> Aaron Merey via Gdb-patches <gdb-patches@sourceware.org> writes:

> Ping

Thanks, this is ok.

>> > In some cases original_name is prefixed with gdb's working directory
>> > even though the objfile is not located in the working directory.

Offhand this seems bad.

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PING][PATCH] gdb/elfread.c: Use bfd filename instead of objfile->original_name
  2022-08-30 18:01     ` Tom Tromey
@ 2022-08-31  0:45       ` Aaron Merey via Gdb-patches
  0 siblings, 0 replies; 5+ messages in thread
From: Aaron Merey via Gdb-patches @ 2022-08-31  0:45 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Aaron Merey via Gdb-patches

On Tue, Aug 30, 2022 at 2:01 PM Tom Tromey <tom@tromey.com> wrote:
> Thanks, this is ok.

Thanks, pushed as commit 803584b96d9.

> >> > In some cases original_name is prefixed with gdb's working directory
> >> > even though the objfile is not located in the working directory.
>
> Offhand this seems bad.

It looks like this can occur when gdb_abspath converts an executable name
to an absolute path in the objfile ctor.  For invocations like `gdb prog`
it assumes the user meant `gdb ./prog` even when prog is found somewhere
else.

Aaron


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-31  0:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 20:07 [PATCH] gdb/elfread.c: Use bfd filename instead of objfile->original_name Aaron Merey via Gdb-patches
2022-07-05 22:43 ` Aaron Merey via Gdb-patches
2022-08-26 21:24   ` [PING][PATCH] " Aaron Merey via Gdb-patches
2022-08-30 18:01     ` Tom Tromey
2022-08-31  0:45       ` Aaron Merey via Gdb-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox