public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Fix compile error & incorrect push
@ 2019-10-22 18:47 Christian Biesinger
  0 siblings, 0 replies; only message in thread
From: Christian Biesinger @ 2019-10-22 18:47 UTC (permalink / raw)
  To: gdb-cvs

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

commit 3a49427939764f53e196ae10013c72fcffb8c085
Author: Christian Biesinger <cbiesinger@google.com>
Date:   Tue Oct 22 13:37:37 2019 -0500

    Fix compile error & incorrect push
    
    I accidentally pushed the wrong version of the patch for commit
    7bb43059820c5febb4509b15202a93efde442bc6 (where the review
    comments were not fixed), and I did a bad conflict resolution
    for ccb1ba62299edce72053dd567b9d384814e11885 leading to a
    compile error when libxxhash is available. This fixes both
    issues.
    
    gdb/ChangeLog:
    
    2019-10-22  Christian Biesinger  <cbiesinger@google.com>
    
    	* symtab.c (struct demangled_name_entry): Add a constructor.
    	(free_demangled_name_entry): New function to call the destructor
    	for demangled_name_entry.
    	(create_demangled_names_hash): Pass free_demangled_name_entry to
    	htab_create_alloc.
    	(symbol_set_names): Call placement new for demangled_name_entry.
    	* utils.c: No longer include xxhash.h here, now that fast_hash
    	is inlined in the header.
    	* utils.h: Instead, include it here.
    
    Change-Id: If776099d39a65a12733d42efcb859feca1b07a39

Diff:
---
 gdb/ChangeLog | 12 ++++++++++++
 gdb/symtab.c  | 23 ++++++++++++++++++-----
 gdb/utils.c   |  4 ----
 gdb/utils.h   |  4 ++++
 4 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3fac795..8255a85 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,17 @@
 2019-10-22  Christian Biesinger  <cbiesinger@google.com>
 
+	* symtab.c (struct demangled_name_entry): Add a constructor.
+	(free_demangled_name_entry): New function to call the destructor
+	for demangled_name_entry.
+	(create_demangled_names_hash): Pass free_demangled_name_entry to
+	htab_create_alloc.
+	(symbol_set_names): Call placement new for demangled_name_entry.
+	* utils.c: No longer include xxhash.h here, now that fast_hash
+	is inlined in the header.
+	* utils.h: Instead, include it here.
+
+2019-10-22  Christian Biesinger  <cbiesinger@google.com>
+
 	* Makefile.in: Link with libxxhash.
 	* config.in: Regenerate.
 	* configure: Regenerate.
diff --git a/gdb/symtab.c b/gdb/symtab.c
index dff92ca..ed55cec 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -715,6 +715,9 @@ symbol_set_language (struct general_symbol_info *gsymbol,
 /* Objects of this type are stored in the demangled name hash table.  */
 struct demangled_name_entry
 {
+  demangled_name_entry (gdb::string_view mangled_name)
+    : mangled (mangled_name) {}
+
   gdb::string_view mangled;
   ENUM_BITFIELD(language) language : LANGUAGE_BITS;
   char demangled[1];
@@ -744,6 +747,15 @@ eq_demangled_name_entry (const void *a, const void *b)
   return da->mangled == db->mangled;
 }
 
+static void
+free_demangled_name_entry (void *data)
+{
+  struct demangled_name_entry *e
+    = (struct demangled_name_entry *) data;
+
+  e->~demangled_name_entry();
+}
+
 /* Create the hash table used for demangled names.  Each hash entry is
    a pair of strings; one for the mangled name and one for the demangled
    name.  The entry is hashed via just the mangled name.  */
@@ -758,7 +770,7 @@ create_demangled_names_hash (struct objfile_per_bfd_storage *per_bfd)
 
   per_bfd->demangled_names_hash.reset (htab_create_alloc
     (256, hash_demangled_name_entry, eq_demangled_name_entry,
-     NULL, xcalloc, xfree));
+     free_demangled_name_entry, xcalloc, xfree));
 }
 
 /* Try to determine the demangled name for a symbol, based on the
@@ -819,7 +831,6 @@ symbol_set_names (struct general_symbol_info *gsymbol,
   struct demangled_name_entry **slot;
   /* A 0-terminated copy of the linkage name.  */
   const char *linkage_name_copy;
-  struct demangled_name_entry entry;
 
   if (gsymbol->language == language_ada)
     {
@@ -857,7 +868,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
   else
     linkage_name_copy = linkage_name;
 
-  entry.mangled = gdb::string_view (linkage_name_copy, len);
+  struct demangled_name_entry entry (gdb::string_view (linkage_name_copy, len));
   slot = ((struct demangled_name_entry **)
 	  htab_find_slot (per_bfd->demangled_names_hash.get (),
 			  &entry, INSERT));
@@ -890,7 +901,8 @@ 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 = gdb::string_view (linkage_name, len);
+	  new (*slot) demangled_name_entry
+	    (gdb::string_view (linkage_name, len));
 	}
       else
 	{
@@ -906,7 +918,8 @@ 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 = gdb::string_view (mangled_ptr, len);
+	  new (*slot) demangled_name_entry
+	    (gdb::string_view (mangled_ptr, len));
 	}
       (*slot)->language = gsymbol->language;
 
diff --git a/gdb/utils.c b/gdb/utils.c
index 1b62e55..3afb8e5 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -36,10 +36,6 @@
 #include <pc.h>
 #endif
 
-#ifdef HAVE_LIBXXHASH
-#include <xxhash.h>
-#endif
-
 #include <signal.h>
 #include "gdbcmd.h"
 #include "serial.h"
diff --git a/gdb/utils.h b/gdb/utils.h
index a8ad9d9..e837621 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -25,6 +25,10 @@
 #include "gdbsupport/scoped_restore.h"
 #include <chrono>
 
+#ifdef HAVE_LIBXXHASH
+#include <xxhash.h>
+#endif
+
 struct completion_match_for_lcd;
 class compiled_regex;


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

only message in thread, other threads:[~2019-10-22 18:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-22 18:47 [binutils-gdb] Fix compile error & incorrect push Christian Biesinger

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