public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Bruno Larsen <blarsen@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH v3 6/7] gdb: remove code to prepend comp dir in buildsym_compunit::start_subfile
Date: Thu, 12 May 2022 10:07:14 -0300	[thread overview]
Message-ID: <6e9157d0-4f5d-82e9-3588-9e5318e9cdb7@redhat.com> (raw)
In-Reply-To: <20220428033542.1636284-7-simon.marchi@polymtl.ca>


On 4/28/22 00:35, Simon Marchi via Gdb-patches wrote:
> The bit of code removed by this patch was introduced to fix the same
> kind of problem that the previous patch fixes.  That is, to try to match
> existing subfiles when different name forms are used to refer to a same
> file.
> 
> The thread for the patch that introduced this code is:
> 
>    https://pi.simark.ca/gdb-patches/45F8CBDF.9090501@hq.tensilica.com/
> 
> The important bits are that the compiler produced a compilation unit
> with:
> 
>      DW_AT_name : test.c
>      DW_AT_comp_dir : /home/maxim/W/BadgerPass/PR_14999
> 
> and DWARF v2 line table with:
> 
>      The Directory Table:
>      /home/maxim/W/BadgerPass/PR_14999
> 
>      The File Name Table:
>      Entry Dir Time Size Name
>      1 1 1173897037 152 test.c
> 
> Because the main symtab was created with only DW_AT_name, it was named
> "test.c".  And because the path built from the line header contained the
> "directory" part, it was "/home/maxim/W/BadgerPass/PR_14999/test.c".
> Because of this mismatch, thing didn't work, so they added this code to
> prepend the compilation directory to the existing subfile names, so that
> this specific case would work.
> 
> With the changes done earlier in this series, where subfiles are
> identified using the "most complete path possible", this case would be
> handled.  The main subfile's would be
> "/home/maxim/W/BadgerPass/PR_14999/test.c" from the start
> (DW_AT_comp_dir + DW_AT_name).  It's not so different from some DWARF 5
> cases actually, which make the compilation directory explicit in the
> line table header.
> 
> I therefore think that this code is no longer needed.  It does feel like
> a quick hack to make one specific case work, and we have a more general
> solution now.  Also, this code was introduced to work around a problem
> in the DWARF debug info or the DWARF debug info reader.  In general, I
> think it's preferable for these hacks to be located in the specific
> debug info reader code, rather than in the common code.
> 
> Even though this code was added to work around a DWARF reader problem,
> it's possible that some other debug info reader has started taking
> advantage of this code in the mean time.  It's very difficult to
> know or verify, but I think the likelyhood is quite small, so I'm
> proposing to get rid of it to simplify things a little bit.
> 
> Change-Id: I710b8ec0d449d1b110d67ddf9fcbdb2b37108306

Hello Simon,

This change seems reasonable, and local testing found no regressions. In fact, because this prepending code was not always applied, it caused some problems when testing using clang, and removing it has fixed failures in gdb.base/maint.exp and gdb.base/jit-elf.exp!

FWIW, I think you can approve your patch.

Cheers!
Bruno Larsen

> ---
>   gdb/buildsym.c | 32 +++++++-------------------------
>   1 file changed, 7 insertions(+), 25 deletions(-)
> 
> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
> index bb258b983ca4..4672d937bd98 100644
> --- a/gdb/buildsym.c
> +++ b/gdb/buildsym.c
> @@ -498,31 +498,13 @@ buildsym_compunit::start_subfile (const char *name, const char *name_for_id)
>     symtab_create_debug_printf ("name = %s, name_for_id = %s", name, name_for_id);
>   
>     for (subfile *subfile = m_subfiles; subfile; subfile = subfile->next)
> -    {
> -      std::string subfile_name_holder;
> -      const char *subfile_name_for_id;
> -
> -      /* If NAME is an absolute path, and this subfile is not, then
> -	 attempt to create an absolute path to compare.  */
> -      if (IS_ABSOLUTE_PATH (name_for_id)
> -	  && !IS_ABSOLUTE_PATH (subfile->name_for_id)
> -	  && !m_comp_dir.empty ())
> -	{
> -	  subfile_name_holder = path_join (m_comp_dir.c_str (),
> -					   subfile->name_for_id.c_str ());
> -	  subfile_name_for_id = subfile_name_holder.c_str ();
> -	}
> -      else
> -	subfile_name_for_id = subfile->name_for_id.c_str ();
> -
> -      if (FILENAME_CMP (subfile_name_for_id, name_for_id) == 0)
> -	{
> -	  symtab_create_debug_printf ("found existing symtab with name_for_id %s (%s)",
> -				      subfile->name_for_id.c_str (), subfile_name_for_id);
> -	  m_current_subfile = subfile;
> -	  return;
> -	}
> -    }
> +    if (FILENAME_CMP (subfile->name_for_id.c_str (), name_for_id) == 0)
> +      {
> +	symtab_create_debug_printf ("found existing symtab with name_for_id %s",
> +				    subfile->name_for_id.c_str ());
> +	m_current_subfile = subfile;
> +	return;
> +      }
>   
>     /* This subfile is not known.  Add an entry for it.  */
>   


  reply	other threads:[~2022-05-12 13:07 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28  3:35 [PATCH v3 0/7] Fix printing macros Simon Marchi
2022-04-28  3:35 ` [PATCH v3 1/7] gdb: introduce symtab_create_debug_printf Simon Marchi
2022-04-28 15:49   ` Tom Tromey
2022-04-28  3:35 ` [PATCH v3 2/7] gdb: add debug prints in buildsym.c Simon Marchi
2022-04-28 15:50   ` Tom Tromey
2022-04-28  3:35 ` [PATCH v3 3/7] gdb/dwarf: pass compilation directory to line header Simon Marchi
2022-04-28 15:48   ` Tom Tromey
2022-04-28 15:59     ` Simon Marchi
2022-04-28  3:35 ` [PATCH v3 4/7] gdb/dwarf: pass a file_entry to line_header::file_file_name Simon Marchi
2022-05-03 20:12   ` Bruno Larsen
2022-07-28 16:26     ` Simon Marchi
2022-04-28  3:35 ` [PATCH v3 5/7] gdb: add "id" fields to identify symtabs and subfiles Simon Marchi
2022-04-28 23:53   ` Lancelot SIX
2022-07-28 17:46     ` Simon Marchi
2022-04-28  3:35 ` [PATCH v3 6/7] gdb: remove code to prepend comp dir in buildsym_compunit::start_subfile Simon Marchi
2022-05-12 13:07   ` Bruno Larsen [this message]
2022-07-28 17:47     ` Simon Marchi
2022-04-28  3:35 ` [PATCH v3 7/7] gdb/testsuite: add macros test for source files compiled in various ways Simon Marchi
2022-05-12 13:17   ` Bruno Larsen
2022-07-28 17:51     ` Simon Marchi
2022-07-30  0:56 ` [PATCH v3 0/7] Fix printing macros Simon Marchi

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=6e9157d0-4f5d-82e9-3588-9e5318e9cdb7@redhat.com \
    --to=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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).