From f84e8777eada296a8e6b3caf758ebd6a6c60d5eb Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 24 Jun 2021 13:54:59 -0300 Subject: [PATCH] core: Convert cu__find_enumeration_by_sname_and_size to search for a string It looked for an index into a string table, a string_t, but since for multithreading we'd be growing the string table while looking up stuff, we'd be looking at realloc'ed memory, so lets move to stable char pointer strings. Signed-off-by: Arnaldo Carvalho de Melo --- dwarf_loader.c | 2 +- dwarves.c | 10 ++++------ dwarves.h | 6 ++---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/dwarf_loader.c b/dwarf_loader.c index 21284ed..7148176 100644 --- a/dwarf_loader.c +++ b/dwarf_loader.c @@ -798,7 +798,7 @@ static int tag__recode_dwarf_bitfield(struct tag *tag, struct cu *cu, uint16_t b * the dwarf_cu as in dwarf there are no such things * as enumeration_types of less than 8 bits, etc. */ - recoded = cu__find_enumeration_by_sname_and_size(cu, sname, bit_size, &short_id); + recoded = cu__find_enumeration_by_name_and_size(cu, name, bit_size, &short_id); if (recoded != NULL) return short_id; diff --git a/dwarves.c b/dwarves.c index 602c928..ff66c93 100644 --- a/dwarves.c +++ b/dwarves.c @@ -758,15 +758,13 @@ struct tag *cu__find_base_type_by_sname_and_size(const struct cu *cu, return NULL; } -struct tag *cu__find_enumeration_by_sname_and_size(const struct cu *cu, - strings_t sname, - uint16_t bit_size, - type_id_t *idp) +struct tag *cu__find_enumeration_by_name_and_size(const struct cu *cu, const char *name, + uint16_t bit_size, type_id_t *idp) { uint32_t id; struct tag *pos; - if (sname == 0) + if (name == NULL) return NULL; cu__for_each_type(cu, id, pos) { @@ -774,7 +772,7 @@ struct tag *cu__find_enumeration_by_sname_and_size(const struct cu *cu, const struct type *t = tag__type(pos); if (t->size == bit_size && - t->namespace.name == sname) { + strcmp(type__name(t, cu), name) == 0) { if (idp != NULL) *idp = id; return pos; diff --git a/dwarves.h b/dwarves.h index b32f17b..37ddb43 100644 --- a/dwarves.h +++ b/dwarves.h @@ -356,10 +356,8 @@ struct tag *cu__find_base_type_by_sname_and_size(const struct cu *cu, uint16_t bit_size, type_id_t *idp); struct tag *cu__find_enumeration_by_name(const struct cu *cu, const char *name, type_id_t *idp); -struct tag *cu__find_enumeration_by_sname_and_size(const struct cu *cu, - strings_t sname, - uint16_t bit_size, - type_id_t *idp); +struct tag *cu__find_enumeration_by_name_and_size(const struct cu *cu, const char* name, + uint16_t bit_size, type_id_t *idp); struct tag *cu__find_first_typedef_of_type(const struct cu *cu, const type_id_t type); struct tag *cu__find_function_by_name(const struct cu *cu, const char *name);