public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb/symtab] Make gold index workaround more precise
@ 2020-05-28 15:26 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2020-05-28 15:26 UTC (permalink / raw)
  To: gdb-cvs

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

commit f030440daa989ae3dadc1fa4342cfa16d690db3c
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu May 28 17:26:22 2020 +0200

    [gdb/symtab] Make gold index workaround more precise
    
    There's a PR gold/15646 - "gold-generated .gdb_index has duplicated
    symbols that gdb-generated index doesn't", that causes gold to generate
    duplicate symbols in the index.
    
    F.i., a namespace N1 declared in a header file can be listed for two CUs that
    include the header file:
    ...
    [759] N1:
            2 [global type]
            3 [global type]
    ...
    
    This causes a gdb performance problem: f.i. when attempting to set a
    breakpoint on a non-existing function N1::misspelled, the symtab for both CUs
    will be expanded.
    
    Gdb contains a workaround for this, added in commit 8943b87476 "Work around
    gold/15646", that skips duplicate global symbols in the index.
    
    However, the workaround does not check for the symbol kind ("type" in the
    example above).
    
    Make the workaround more precise by limiting it to symbol kind "type".
    
    Tested on x86_64-linux, with target boards cc-with-gdb-index and
    gold-gdb-index.
    
    gdb/ChangeLog:
    
    2020-05-28  Tom de Vries  <tdevries@suse.de>
    
            * dwarf2/read.c (dw2_symtab_iter_next, dw2_expand_marked_cus): Limit
            PR gold/15646 workaround to symbol kind "type".

Diff:
---
 gdb/ChangeLog     |  5 +++++
 gdb/dwarf2/read.c | 22 ++++++++++++++--------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 90577b7e61e..593ff01cc9d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-05-28  Tom de Vries  <tdevries@suse.de>
+
+	* dwarf2/read.c	(dw2_symtab_iter_next, dw2_expand_marked_cus): Limit
+	PR gold/15646 workaround to symbol kind "type".
+
 2020-05-27  Tom Tromey  <tromey@adacore.com>
 
 	* dwarf2/read.c (load_partial_dies): Use add_partial_symbol.
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index a62224c0be2..25f05fb9930 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -3522,10 +3522,14 @@ dw2_symtab_iter_next (struct dw2_symtab_iterator *iter)
 	    }
 
 	  /* Work around gold/15646.  */
-	  if (!is_static && iter->global_seen)
-	    continue;
-	  if (!is_static)
-	    iter->global_seen = 1;
+	  if (!is_static
+	      && symbol_kind == GDB_INDEX_SYMBOL_KIND_TYPE)
+	    {
+	      if (iter->global_seen)
+		continue;
+
+	      iter->global_seen = 1;
+	    }
 	}
 
       /* Only check the symbol's kind if it has one.  */
@@ -4627,12 +4631,14 @@ dw2_expand_marked_cus
 	 && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE);
 
       /* Work around gold/15646.  */
-      if (attrs_valid)
+      if (attrs_valid
+	  && !is_static
+	  && symbol_kind == GDB_INDEX_SYMBOL_KIND_TYPE)
 	{
-	  if (!is_static && global_seen)
+	  if (global_seen)
 	    continue;
-	  if (!is_static)
-	    global_seen = true;
+
+	  global_seen = true;
 	}
 
       /* Only check the symbol's kind if it has one.  */


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

only message in thread, other threads:[~2020-05-28 15:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 15:26 [binutils-gdb] [gdb/symtab] Make gold index workaround more precise Tom de Vries

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