public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Store the mangled name as a string_view
@ 2019-10-23 23:11 gdb-buildbot
  2019-10-23 23:11 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, branch master gdb-buildbot
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: gdb-buildbot @ 2019-10-23 23:11 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT 7bb43059820c5febb4509b15202a93efde442bc6 ***

commit 7bb43059820c5febb4509b15202a93efde442bc6
Author:     Christian Biesinger <cbiesinger@google.com>
AuthorDate: Fri Sep 27 12:40:04 2019 -0500
Commit:     Christian Biesinger <cbiesinger@google.com>
CommitDate: Tue Oct 22 11:25:31 2019 -0500

    Store the mangled name as a string_view
    
    This should be a bit faster (because we can compare the size first),
    but it is also a dependency for the next patch.
    
    (3.47% of gdb startup time is spent in eq_demangled_name_entry when
    attaching to Chrome's content_shell binary)
    
    gdb/ChangeLog:
    
    2019-10-22  Christian Biesinger  <cbiesinger@google.com>
    
            * symtab.c (struct demangled_name_entry): Change type of mangled
            to gdb::string_view. Also adds a constructor that takes the
            mangled name.
            (hash_demangled_name_entry): Update.
            (eq_demangled_name_entry): Update.
            (free_demangled_name_entry): New function to call the destructor
            now that this is not a POD anymore.
            (create_demangled_names_hash): Pass free_demangled_name_entry to
            htab_create_alloc.
            (symbol_set_names): Update.
    
    Change-Id: I24711ae2bcaa9e79ca89a6f8fda385d400419175

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a70f3e1795..d271330400 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,16 @@
+2019-10-22  Christian Biesinger  <cbiesinger@google.com>
+
+	* symtab.c (struct demangled_name_entry): Change type of mangled
+	to gdb::string_view. Also adds a constructor that takes the
+	mangled name.
+	(hash_demangled_name_entry): Update.
+	(eq_demangled_name_entry): Update.
+	(free_demangled_name_entry): New function to call the destructor
+	now that this is not a POD anymore.
+	(create_demangled_names_hash): Pass free_demangled_name_entry to
+	htab_create_alloc.
+	(symbol_set_names): Update.
+
 2019-10-21  Ali Tamur  <tamu@google.com>
 
 	* dwarf2read.c (dir_index): Change type.
diff --git a/gdb/symtab.c b/gdb/symtab.c
index fc736fd2b7..567d09d355 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -68,6 +68,7 @@
 #include "filename-seen-cache.h"
 #include "arch-utils.h"
 #include <algorithm>
+#include "gdbsupport/gdb_string_view.h"
 #include "gdbsupport/pathstuff.h"
 
 /* Forward declarations for local functions.  */
@@ -713,7 +714,7 @@ symbol_set_language (struct general_symbol_info *gsymbol,
 /* Objects of this type are stored in the demangled name hash table.  */
 struct demangled_name_entry
 {
-  const char *mangled;
+  gdb::string_view mangled;
   ENUM_BITFIELD(language) language : LANGUAGE_BITS;
   char demangled[1];
 };
@@ -726,7 +727,7 @@ hash_demangled_name_entry (const void *data)
   const struct demangled_name_entry *e
     = (const struct demangled_name_entry *) data;
 
-  return htab_hash_string (e->mangled);
+  return iterative_hash (e->mangled.data (), e->mangled.length (), 0);
 }
 
 /* Equality function for the demangled name hash.  */
@@ -739,7 +740,7 @@ eq_demangled_name_entry (const void *a, const void *b)
   const struct demangled_name_entry *db
     = (const struct demangled_name_entry *) b;
 
-  return strcmp (da->mangled, db->mangled) == 0;
+  return da->mangled == db->mangled;
 }
 
 /* Create the hash table used for demangled names.  Each hash entry is
@@ -855,7 +856,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
   else
     linkage_name_copy = linkage_name;
 
-  entry.mangled = linkage_name_copy;
+  entry.mangled = gdb::string_view (linkage_name_copy, len);
   slot = ((struct demangled_name_entry **)
 	  htab_find_slot (per_bfd->demangled_names_hash.get (),
 			  &entry, INSERT));
@@ -888,7 +889,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
 	       obstack_alloc (&per_bfd->storage_obstack,
 			      offsetof (struct demangled_name_entry, demangled)
 			      + demangled_len + 1));
-	  (*slot)->mangled = linkage_name;
+	  (*slot)->mangled = gdb::string_view (linkage_name, len);
 	}
       else
 	{
@@ -904,7 +905,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
 			      + len + demangled_len + 2));
 	  mangled_ptr = &((*slot)->demangled[demangled_len + 1]);
 	  strcpy (mangled_ptr, linkage_name_copy);
-	  (*slot)->mangled = mangled_ptr;
+	  (*slot)->mangled = gdb::string_view (mangled_ptr, len);
 	}
       (*slot)->language = gsymbol->language;
 
@@ -917,7 +918,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
 	   || gsymbol->language == language_auto)
     gsymbol->language = (*slot)->language;
 
-  gsymbol->name = (*slot)->mangled;
+  gsymbol->name = (*slot)->mangled.data ();
   if ((*slot)->demangled[0] != '\0')
     symbol_set_demangled_name (gsymbol, (*slot)->demangled,
 			       &per_bfd->storage_obstack);


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

end of thread, other threads:[~2019-11-09 17:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23 23:11 [binutils-gdb] Store the mangled name as a string_view gdb-buildbot
2019-10-23 23:11 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, branch master gdb-buildbot
2019-10-23 23:42 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2019-11-09 13:12 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2019-11-09 13:41 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2019-11-09 14:54 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2019-11-09 16:30 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot
2019-11-09 17:02 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot

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