core: Convert cu__find_base_type_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 <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2021-06-24 13:54:59 -03:00
parent f84e8777ea
commit 46f3f37241
3 changed files with 8 additions and 11 deletions

View File

@ -777,7 +777,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 base_types of less than 8 bits, etc.
*/
recoded = cu__find_base_type_by_sname_and_size(cu, sname, bit_size, &short_id);
recoded = cu__find_base_type_by_name_and_size(cu, name, bit_size, &short_id);
if (recoded != NULL)
return short_id;

View File

@ -731,23 +731,22 @@ struct tag *cu__find_base_type_by_name(const struct cu *cu,
return NULL;
}
struct tag *cu__find_base_type_by_sname_and_size(const struct cu *cu,
strings_t sname,
uint16_t bit_size,
type_id_t *idp)
struct tag *cu__find_base_type_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) {
if (pos->tag == DW_TAG_base_type) {
const struct base_type *bt = tag__base_type(pos);
char bf[64];
if (bt->bit_size == bit_size &&
bt->name == sname) {
strcmp(base_type__name(bt, cu, bf, sizeof(bf)), name) == 0) {
if (idp != NULL)
*idp = id;
return pos;

View File

@ -351,10 +351,8 @@ int cu__table_add_tag_with_id(struct cu *cu, struct tag *tag, uint32_t id);
int cu__table_nullify_type_entry(struct cu *cu, uint32_t id);
struct tag *cu__find_base_type_by_name(const struct cu *cu, const char *name,
type_id_t *id);
struct tag *cu__find_base_type_by_sname_and_size(const struct cu *cu,
strings_t name,
uint16_t bit_size,
type_id_t *idp);
struct tag *cu__find_base_type_by_name_and_size(const struct cu *cu, const char* name,
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_name_and_size(const struct cu *cu, const char* name,
uint16_t bit_size, type_id_t *idp);