From 4f73cac85321bd5b77fdeecbb38e850d37537c4b Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 24 Jun 2021 10:01:27 -0300 Subject: [PATCH] core: Make function->linkage_name a real string For the threaded code we want to access strings in tags at the same time that the string table may grow in another thread making the previous pointer invalid, so, to avoid excessive locking, use plain strings. The way the tools work will either consume the just produced CU straight away or keep just one copy of each data structure when we keep all CUs in memory, so lets try stopping using strings_t for strings. Signed-off-by: Arnaldo Carvalho de Melo --- dwarf_loader.c | 2 +- dwarves.h | 7 +++---- dwarves_fprintf.c | 5 ++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/dwarf_loader.c b/dwarf_loader.c index 95673f8..48469a4 100644 --- a/dwarf_loader.c +++ b/dwarf_loader.c @@ -1059,7 +1059,7 @@ static struct function *function__new(Dwarf_Die *die, struct cu *cu) ftype__init(&func->proto, die, cu); lexblock__init(&func->lexblock, cu, die); func->name = strings__add(strings, attr_string(die, DW_AT_name)); - func->linkage_name = strings__add(strings, attr_string(die, DW_AT_MIPS_linkage_name)); + func->linkage_name = strdup_attr_string(die, DW_AT_MIPS_linkage_name); func->inlined = attr_numeric(die, DW_AT_inline); func->declaration = dwarf_hasattr(die, DW_AT_declaration); func->external = dwarf_hasattr(die, DW_AT_external); diff --git a/dwarves.h b/dwarves.h index 9752c8d5..75d003d 100644 --- a/dwarves.h +++ b/dwarves.h @@ -807,7 +807,7 @@ struct function { struct lexblock lexblock; struct rb_node rb_node; strings_t name; - strings_t linkage_name; + const char *linkage_name; uint32_t cu_total_size_inline_expansions; uint16_t cu_total_nr_inline_expansions; uint8_t inlined:2; @@ -854,10 +854,9 @@ static __pure inline int tag__is_function(const struct tag *tag) const char *function__name(struct function *func, const struct cu *cu); -static inline const char *function__linkage_name(const struct function *func, - const struct cu *cu) +static inline const char *function__linkage_name(const struct function *func) { - return cu__string(cu, func->linkage_name); + return func->linkage_name; } size_t function__fprintf_stats(const struct tag *tag_func, diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c index 9e76f51..37537ca 100644 --- a/dwarves_fprintf.c +++ b/dwarves_fprintf.c @@ -1349,7 +1349,7 @@ static size_t class__vtable_fprintf(struct class *class, const struct cu *cu, printed += fprintf(fp, "%.*s [%d] = %s(%s), \n", conf->indent, tabs, pos->vtable_entry, function__name(pos, cu), - function__linkage_name(pos, cu)); + function__linkage_name(pos)); } printed += fprintf(fp, "%.*s} */", conf->indent, tabs); @@ -1936,8 +1936,7 @@ size_t tag__fprintf(struct tag *tag, const struct cu *cu, const struct function *func = tag__function(tag); if (func->linkage_name) - printed += fprintf(fp, " /* linkage=%s */", - function__linkage_name(func, cu)); + printed += fprintf(fp, " /* linkage=%s */", function__linkage_name(func)); } if (pconf->expand_types)