+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.
/* 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];
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. */
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
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)
{
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));
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
{
+ 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;