[6/7] Move fixup_partial_die to partial_die_info::fixup
Commit Message
fixup_partial_die can be a partial_die_info method fixup, and field
fixup_called can be private.
gdb:
2018-01-11 Yao Qi <yao.qi@linaro.org>
* dwarf2read.c (struct partial_die_info) <fixup>: New method.
(struct partial_die_info) <fixup_called>: Change it to
m_fixup_called.
(fixup_partial_die): Remove declaration.
(scan_partial_symbols): Update.
(partial_die_parent_scope): Likewise.
(partial_die_full_name): Likewise.
(fixup_partial_die): Change it to partial_die_info::fixup.
---
gdb/dwarf2read.c | 79 +++++++++++++++++++++++++++-----------------------------
1 file changed, 38 insertions(+), 41 deletions(-)
Comments
On 01/25/2018 09:38 AM, Yao Qi wrote:
> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
> index 0ee102a..9b6f2ec 100644
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c
> @@ -1410,6 +1410,11 @@ struct partial_die_info
> load_partial_dies. */
> partial_die_info& operator=(const partial_die_info& rhs) = delete;
>
> + /* Adjust the partial die before generating a symbol for it. This
> + function may set the is_external flag or change the DIE's
> + name. */
> + void fixup (struct dwarf2_cu *cu);
> +
> /* Offset of this DIE. */
> const sect_offset sect_off;
>
> @@ -1442,9 +1447,6 @@ struct partial_die_info
> /* Flag set if any of the DIE's children are template arguments. */
> unsigned int has_template_arguments : 1;
>
> - /* Flag set if fixup_partial_die has been called on this die. */
> - unsigned int fixup_called : 1;
> -
> /* Flag set if DW_TAG_imported_unit uses DW_FORM_GNU_ref_alt. */
> unsigned int is_dwz : 1;
>
> @@ -1519,10 +1521,13 @@ struct partial_die_info
> has_byte_size = 0;
> has_const_value = 0;
> has_template_arguments = 0;
> - fixup_called = 0;
> + m_fixup_called = false;
> is_dwz = 0;
> spec_is_dwz = 0;
> }
> +
> + /* Flag set if fixup has been called on this die. */
> + bool m_fixup_called : 1;
> };
Currently, the boolean bits were all together for packing.
This moves the bit away from the others, after some pointer
fields, I think. This is probably growing the size of
the structure with some padding holes.
Thanks,
Pedro Alves
@@ -1410,6 +1410,11 @@ struct partial_die_info
load_partial_dies. */
partial_die_info& operator=(const partial_die_info& rhs) = delete;
+ /* Adjust the partial die before generating a symbol for it. This
+ function may set the is_external flag or change the DIE's
+ name. */
+ void fixup (struct dwarf2_cu *cu);
+
/* Offset of this DIE. */
const sect_offset sect_off;
@@ -1442,9 +1447,6 @@ struct partial_die_info
/* Flag set if any of the DIE's children are template arguments. */
unsigned int has_template_arguments : 1;
- /* Flag set if fixup_partial_die has been called on this die. */
- unsigned int fixup_called : 1;
-
/* Flag set if DW_TAG_imported_unit uses DW_FORM_GNU_ref_alt. */
unsigned int is_dwz : 1;
@@ -1519,10 +1521,13 @@ struct partial_die_info
has_byte_size = 0;
has_const_value = 0;
has_template_arguments = 0;
- fixup_called = 0;
+ m_fixup_called = false;
is_dwz = 0;
spec_is_dwz = 0;
}
+
+ /* Flag set if fixup has been called on this die. */
+ bool m_fixup_called : 1;
};
/* This data structure holds the information of an abbrev. */
@@ -1839,9 +1844,6 @@ static const gdb_byte *read_partial_die (const struct die_reader_specs *,
static struct partial_die_info *find_partial_die (sect_offset, int,
struct dwarf2_cu *);
-static void fixup_partial_die (struct partial_die_info *,
- struct dwarf2_cu *);
-
static const gdb_byte *read_attribute (const struct die_reader_specs *,
struct attribute *, struct attr_abbrev *,
const gdb_byte *);
@@ -9025,7 +9027,7 @@ scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc,
while (pdi != NULL)
{
- fixup_partial_die (pdi, cu);
+ pdi->fixup (cu);
/* Anonymous namespaces or modules have no name but have interesting
children, so we need to look at them. Ditto for anonymous
@@ -9161,7 +9163,7 @@ partial_die_parent_scope (struct partial_die_info *pdi,
if (parent->scope_set)
return parent->scope;
- fixup_partial_die (parent, cu);
+ parent->fixup (cu);
grandparent_scope = partial_die_parent_scope (parent, cu);
@@ -9226,7 +9228,7 @@ partial_die_full_name (struct partial_die_info *pdi,
types here will be reused if full symbols are loaded later. */
if (pdi->has_template_arguments)
{
- fixup_partial_die (pdi, cu);
+ pdi->fixup (cu);
if (pdi->name != NULL && strchr (pdi->name, '<') == NULL)
{
@@ -9535,7 +9537,7 @@ add_partial_subprogram (struct partial_die_info *pdi,
pdi = pdi->die_child;
while (pdi != NULL)
{
- fixup_partial_die (pdi, cu);
+ pdi->fixup (cu);
if (pdi->tag == DW_TAG_subprogram
|| pdi->tag == DW_TAG_inlined_subroutine
|| pdi->tag == DW_TAG_lexical_block)
@@ -18842,45 +18844,40 @@ guess_partial_die_structure_name (struct partial_die_info *struct_pdi,
}
}
-/* Adjust PART_DIE before generating a symbol for it. This function
- may set the is_external flag or change the DIE's name. */
-
-static void
-fixup_partial_die (struct partial_die_info *part_die,
- struct dwarf2_cu *cu)
+void
+partial_die_info::fixup (struct dwarf2_cu *cu)
{
/* Once we've fixed up a die, there's no point in doing so again.
This also avoids a memory leak if we were to call
guess_partial_die_structure_name multiple times. */
- if (part_die->fixup_called)
+ if (m_fixup_called)
return;
/* If we found a reference attribute and the DIE has no name, try
to find a name in the referred to DIE. */
- if (part_die->name == NULL && part_die->has_specification)
+ if (name == NULL && has_specification)
{
struct partial_die_info *spec_die;
- spec_die = find_partial_die (part_die->spec_offset,
- part_die->spec_is_dwz, cu);
+ spec_die = find_partial_die (spec_offset, spec_is_dwz, cu);
- fixup_partial_die (spec_die, cu);
+ spec_die->fixup (cu);
if (spec_die->name)
{
- part_die->name = spec_die->name;
+ name = spec_die->name;
/* Copy DW_AT_external attribute if it is set. */
if (spec_die->is_external)
- part_die->is_external = spec_die->is_external;
+ is_external = spec_die->is_external;
}
}
/* Set default names for some unnamed DIEs. */
- if (part_die->name == NULL && part_die->tag == DW_TAG_namespace)
- part_die->name = CP_ANONYMOUS_NAMESPACE_STR;
+ if (name == NULL && tag == DW_TAG_namespace)
+ name = CP_ANONYMOUS_NAMESPACE_STR;
/* If there is no parent die to provide a namespace, and there are
children, see if we can determine the namespace from their linkage
@@ -18888,25 +18885,25 @@ fixup_partial_die (struct partial_die_info *part_die,
if (cu->language == language_cplus
&& !VEC_empty (dwarf2_section_info_def,
cu->per_cu->dwarf2_per_objfile->types)
- && part_die->die_parent == NULL
- && part_die->has_children
- && (part_die->tag == DW_TAG_class_type
- || part_die->tag == DW_TAG_structure_type
- || part_die->tag == DW_TAG_union_type))
- guess_partial_die_structure_name (part_die, cu);
+ && die_parent == NULL
+ && has_children
+ && (tag == DW_TAG_class_type
+ || tag == DW_TAG_structure_type
+ || tag == DW_TAG_union_type))
+ guess_partial_die_structure_name (this, cu);
/* 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 (part_die->name == NULL
- && (part_die->tag == DW_TAG_class_type
- || part_die->tag == DW_TAG_interface_type
- || part_die->tag == DW_TAG_structure_type
- || part_die->tag == DW_TAG_union_type)
- && part_die->linkage_name != NULL)
+ if (name == NULL
+ && (tag == DW_TAG_class_type
+ || tag == DW_TAG_interface_type
+ || tag == DW_TAG_structure_type
+ || tag == DW_TAG_union_type)
+ && linkage_name != NULL)
{
char *demangled;
- demangled = gdb_demangle (part_die->linkage_name, DMGL_TYPES);
+ demangled = gdb_demangle (linkage_name, DMGL_TYPES);
if (demangled)
{
const char *base;
@@ -18920,7 +18917,7 @@ fixup_partial_die (struct partial_die_info *part_die,
base = demangled;
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
- part_die->name
+ name
= ((const char *)
obstack_copy0 (&objfile->per_bfd->storage_obstack,
base, strlen (base)));
@@ -18928,7 +18925,7 @@ fixup_partial_die (struct partial_die_info *part_die,
}
}
- part_die->fixup_called = 1;
+ m_fixup_called = true;
}
/* Read an attribute value described by an attribute form. */