public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: remove code to prepend comp dir in buildsym_compunit::start_subfile
@ 2022-07-30  0:55 Simon Marchi
  0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2022-07-30  0:55 UTC (permalink / raw)
  To: gdb-cvs

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

commit ee26d001cdf44cff897f994c89ad333bfa66d59e
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Wed Apr 27 12:47:35 2022 -0400

    gdb: remove code to prepend comp dir in buildsym_compunit::start_subfile
    
    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

Diff:
---
 gdb/buildsym.c | 32 +++++++-------------------------
 1 file changed, 7 insertions(+), 25 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 67d88a94ba9..d7c935af703 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -495,31 +495,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.  */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-30  0:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-30  0:55 [binutils-gdb] gdb: remove code to prepend comp dir in buildsym_compunit::start_subfile Simon Marchi

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).