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