const struct abbrev_info &abbrev,
const gdb_byte *info_ptr);
+ /* Compute the name of this partial DIE. This memoizes the
+ result, so it is safe to call multiple times. */
+ const char *name (dwarf2_cu *cu);
+
/* Offset of this DIE. */
const sect_offset sect_off;
/* Flag set if spec_offset uses DW_FORM_GNU_ref_alt. */
unsigned int spec_is_dwz : 1;
+ unsigned int canonical_name : 1;
+
/* The name of this DIE. Normally the value of DW_AT_name, but
sometimes a default name for unnamed DIEs. */
- const char *name = nullptr;
+ const char *raw_name = nullptr;
/* The linkage name, if present. */
const char *linkage_name = nullptr;
fixup_called = 0;
is_dwz = 0;
spec_is_dwz = 0;
+ canonical_name = 0;
}
};
children, so we need to look at them. Ditto for anonymous
enums. */
- if (pdi->name != NULL || pdi->tag == DW_TAG_namespace
+ if (pdi->raw_name != NULL || pdi->tag == DW_TAG_namespace
|| pdi->tag == DW_TAG_module || pdi->tag == DW_TAG_enumeration_type
|| pdi->tag == DW_TAG_imported_unit
|| pdi->tag == DW_TAG_inlined_subroutine)
Work around this problem here. */
if (cu->language == language_cplus
&& parent->tag == DW_TAG_namespace
- && strcmp (parent->name, "::") == 0
+ && strcmp (parent->name (cu), "::") == 0
&& grandparent_scope == NULL)
{
parent->scope = NULL;
&& pdi->tag == DW_TAG_subprogram))
{
if (grandparent_scope == NULL)
- parent->scope = parent->name;
+ parent->scope = parent->name (cu);
else
parent->scope = typename_concat (&cu->comp_unit_obstack,
grandparent_scope,
- parent->name, 0, cu);
+ parent->name (cu), 0, cu);
}
else
{
{
pdi->fixup (cu);
- if (pdi->name != NULL && strchr (pdi->name, '<') == NULL)
+ if (pdi->name (cu) != NULL && strchr (pdi->name (cu), '<') == NULL)
{
struct die_info *die;
struct attribute attr;
return NULL;
else
return gdb::unique_xmalloc_ptr<char> (typename_concat (NULL, parent_scope,
- pdi->name, 0, cu));
+ pdi->name (cu),
+ 0, cu));
}
static void
actual_name = built_actual_name.get ();
if (actual_name == NULL)
- actual_name = pdi->name;
+ actual_name = pdi->name (cu);
partial_symbol psymbol;
memset (&psymbol, 0, sizeof (psymbol));
/* Ignore subprogram DIEs that do not have a name, they are
illegal. Do not emit a complaint at this point, we will
do so when we convert this psymtab into a symtab. */
- if (pdi->name)
+ if (pdi->name (cu))
add_partial_symbol (pdi, cu);
}
}
{
struct partial_die_info *pdi;
- if (enum_pdi->name != NULL)
+ if (enum_pdi->name (cu) != NULL)
add_partial_symbol (enum_pdi, cu);
pdi = enum_pdi->die_child;
while (pdi)
{
- if (pdi->tag != DW_TAG_enumerator || pdi->name == NULL)
+ if (pdi->tag != DW_TAG_enumerator || pdi->raw_name == NULL)
complaint (_("malformed enumerator DIE ignored"));
else
add_partial_symbol (pdi, cu);
|| pdi.tag == DW_TAG_base_type
|| pdi.tag == DW_TAG_subrange_type))
{
- if (building_psymtab && pdi.name != NULL)
- add_psymbol_to_list (pdi.name, false,
+ if (building_psymtab && pdi.raw_name != NULL)
+ add_psymbol_to_list (pdi.name (cu), false,
VAR_DOMAIN, LOC_TYPEDEF, -1,
psymbol_placement::STATIC,
0, cu->language, objfile);
&& parent_die->tag == DW_TAG_enumeration_type
&& parent_die->has_specification == 0)
{
- if (pdi.name == NULL)
+ if (pdi.raw_name == NULL)
complaint (_("malformed enumerator DIE ignored"));
else if (building_psymtab)
- add_psymbol_to_list (pdi.name, false,
+ add_psymbol_to_list (pdi.name (cu), false,
VAR_DOMAIN, LOC_CONST, -1,
cu->language == language_cplus
? psymbol_placement::GLOBAL
|| last_die->tag == DW_TAG_enumeration_type
|| (cu->language == language_cplus
&& last_die->tag == DW_TAG_subprogram
- && (last_die->name == NULL
- || strchr (last_die->name, '<') == NULL))
+ && (last_die->raw_name == NULL
+ || strchr (last_die->raw_name, '<') == NULL))
|| (cu->language != language_c
&& (last_die->tag == DW_TAG_class_type
|| last_die->tag == DW_TAG_interface_type
{
}
+/* See class definition. */
+
+const char *
+partial_die_info::name (dwarf2_cu *cu)
+{
+ if (!canonical_name && raw_name != nullptr)
+ {
+ struct objfile *objfile = cu->per_objfile->objfile;
+ raw_name = dwarf2_canonicalize_name (raw_name, cu, objfile);
+ canonical_name = 1;
+ }
+
+ return raw_name;
+}
+
/* Read a minimal amount of information into the minimal die structure.
INFO_PTR should point just after the initial uleb128 of a DIE. */
case DW_TAG_enumerator:
/* These tags always have simple identifiers already; no need
to canonicalize them. */
- name = DW_STRING (&attr);
+ canonical_name = 1;
+ raw_name = DW_STRING (&attr);
break;
default:
- {
- struct objfile *objfile = dwarf2_per_objfile->objfile;
-
- name
- = dwarf2_canonicalize_name (DW_STRING (&attr), cu, objfile);
- }
+ canonical_name = 0;
+ raw_name = DW_STRING (&attr);
break;
}
break;
Really, though, this is just a workaround for the fact that gdb
doesn't store both the name and the linkage name. */
if (cu->language == language_ada && linkage_name != nullptr)
- name = linkage_name;
+ raw_name = linkage_name;
if (high_pc_relative)
highpc += lowpc;
if (actual_class_name != NULL)
{
struct objfile *objfile = cu->per_objfile->objfile;
- struct_pdi->name = objfile->intern (actual_class_name.get ());
+ struct_pdi->raw_name = objfile->intern (actual_class_name.get ());
+ struct_pdi->canonical_name = 1;
}
break;
}
/* If we found a reference attribute and the DIE has no name, try
to find a name in the referred to DIE. */
- if (name == NULL && has_specification)
+ if (raw_name == NULL && has_specification)
{
struct partial_die_info *spec_die;
spec_die->fixup (cu);
- if (spec_die->name)
+ if (spec_die->raw_name)
{
- name = spec_die->name;
+ raw_name = spec_die->raw_name;
+ canonical_name = spec_die->canonical_name;
/* Copy DW_AT_external attribute if it is set. */
if (spec_die->is_external)
/* Set default names for some unnamed DIEs. */
- if (name == NULL && tag == DW_TAG_namespace)
- name = CP_ANONYMOUS_NAMESPACE_STR;
+ if (raw_name == NULL && tag == DW_TAG_namespace)
+ {
+ raw_name = CP_ANONYMOUS_NAMESPACE_STR;
+ canonical_name = 1;
+ }
/* If there is no parent die to provide a namespace, and there are
children, see if we can determine the namespace from their linkage
/* GCC might emit a nameless struct or union that has a linkage
name. See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47510. */
- if (name == NULL
+ if (raw_name == NULL
&& (tag == DW_TAG_class_type
|| tag == DW_TAG_interface_type
|| tag == DW_TAG_structure_type
base = demangled.get ();
struct objfile *objfile = cu->per_objfile->objfile;
- name = objfile->intern (base);
+ raw_name = objfile->intern (base);
+ canonical_name = 1;
}
}