diff options
author | Christian Biesinger <cbiesinger@google.com> | 2019-10-22 13:37:37 -0500 |
---|---|---|
committer | Christian Biesinger <cbiesinger@google.com> | 2019-10-22 13:41:12 -0500 |
commit | 3a49427939764f53e196ae10013c72fcffb8c085 (patch) | |
tree | 3fd19bc98d4e2d2b6b6cce5f182683c61d4f6d92 | |
parent | ccb1ba62299edce72053dd567b9d384814e11885 (diff) | |
download | gdb-3a49427939764f53e196ae10013c72fcffb8c085.zip gdb-3a49427939764f53e196ae10013c72fcffb8c085.tar.gz gdb-3a49427939764f53e196ae10013c72fcffb8c085.tar.bz2 |
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
-rw-r--r-- | gdb/ChangeLog | 12 | ||||
-rw-r--r-- | gdb/symtab.c | 23 | ||||
-rw-r--r-- | gdb/utils.c | 4 | ||||
-rw-r--r-- | 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; |