aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/attribute.h4
-rw-r--r--gdb/dwarf2/cooked-index.c42
-rw-r--r--gdb/dwarf2/cooked-indexer.c2
-rw-r--r--gdb/dwarf2/die.c4
-rw-r--r--gdb/dwarf2/die.h12
-rw-r--r--gdb/dwarf2/loc.c12
-rw-r--r--gdb/dwarf2/read.c416
-rw-r--r--gdb/dwarf2/read.h15
8 files changed, 209 insertions, 298 deletions
diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h
index 4dce04d..ce6c563 100644
--- a/gdb/dwarf2/attribute.h
+++ b/gdb/dwarf2/attribute.h
@@ -105,8 +105,8 @@ struct attribute
/* Return an unsigned constant value. This only handles constant
forms (i.e., form_is_constant -- and not the extended list of
"unsigned" forms) and assumes an unsigned value is desired. This
- can intended for use with DWARF-defined enumerations like DW_CC_*
- or DW_INL_*, but also in situations where a nonnegative constant
+ can be used with DWARF-defined enumerations like DW_CC_* or
+ DW_INL_*, but also in situations where a nonnegative constant
integer is specified by DWARF.
If a signed form and negative value is used, or if a non-constant
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 724615f..feaf9b5 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -122,11 +122,8 @@ cooked_index_entry::compare (const char *stra, const char *strb,
/* When completing, if STRB ends earlier than STRA, consider them as
equal. */
- if (mode == COMPLETE || (mode == MATCH && a == munge ('<')))
- {
- if (b == '\0')
- return 0;
- }
+ if (mode == COMPLETE && b == '\0')
+ return 0;
return a < b ? -1 : 1;
}
@@ -550,25 +547,28 @@ cooked_index_shard::finalize (const parent_map_map *parent_maps)
cooked_index_shard::range
cooked_index_shard::find (const std::string &name, bool completing) const
{
- cooked_index_entry::comparison_mode mode = (completing
- ? cooked_index_entry::COMPLETE
- : cooked_index_entry::MATCH);
-
- auto lower = std::lower_bound (m_entries.cbegin (), m_entries.cend (), name,
- [=] (const cooked_index_entry *entry,
- const std::string &n)
+ struct comparator
{
- return cooked_index_entry::compare (entry->canonical, n.c_str (), mode) < 0;
- });
+ cooked_index_entry::comparison_mode mode;
- auto upper = std::upper_bound (m_entries.cbegin (), m_entries.cend (), name,
- [=] (const std::string &n,
- const cooked_index_entry *entry)
- {
- return cooked_index_entry::compare (entry->canonical, n.c_str (), mode) > 0;
- });
+ bool operator() (const cooked_index_entry *entry,
+ const char *name) const noexcept
+ {
+ return cooked_index_entry::compare (entry->canonical, name, mode) < 0;
+ }
+
+ bool operator() (const char *name,
+ const cooked_index_entry *entry) const noexcept
+ {
+ return cooked_index_entry::compare (entry->canonical, name, mode) > 0;
+ }
+ };
- return range (lower, upper);
+ return std::make_from_tuple<range>
+ (std::equal_range (m_entries.cbegin (), m_entries.cend (), name.c_str (),
+ comparator { (completing
+ ? cooked_index_entry::COMPLETE
+ : cooked_index_entry::MATCH) }));
}
/* See cooked-index.h. */
diff --git a/gdb/dwarf2/cooked-indexer.c b/gdb/dwarf2/cooked-indexer.c
index 3b80cd6..789fdb5 100644
--- a/gdb/dwarf2/cooked-indexer.c
+++ b/gdb/dwarf2/cooked-indexer.c
@@ -109,7 +109,7 @@ cooked_indexer::ensure_cu_exists (cutu_reader *reader,
cutu_reader *result = m_index_storage->get_reader (per_cu);
if (result == nullptr)
{
- cutu_reader new_reader (per_cu, per_objfile, nullptr, nullptr, false,
+ cutu_reader new_reader (*per_cu, *per_objfile, nullptr, nullptr, false,
language_minimal,
&m_index_storage->get_abbrev_table_cache ());
diff --git a/gdb/dwarf2/die.c b/gdb/dwarf2/die.c
index 500d7bf..9437c2f 100644
--- a/gdb/dwarf2/die.c
+++ b/gdb/dwarf2/die.c
@@ -184,9 +184,9 @@ dump_die_1 (struct ui_file *f, int level, int max_level, struct die_info *die)
}
}
- if (die->sibling != NULL && level > 0)
+ if (die->next != NULL && level > 0)
{
- dump_die_1 (f, level, max_level, die->sibling);
+ dump_die_1 (f, level, max_level, die->next);
}
}
diff --git a/gdb/dwarf2/die.h b/gdb/dwarf2/die.h
index 770964e..cffb5cb 100644
--- a/gdb/dwarf2/die.h
+++ b/gdb/dwarf2/die.h
@@ -22,6 +22,7 @@
#include "complaints.h"
#include "dwarf2/attribute.h"
+#include "gdbsupport/next-iterator.h"
/* This data structure holds a complete die structure. */
struct die_info
@@ -103,6 +104,13 @@ struct die_info
return 0;
}
+ /* Return a range suitable for iterating over the children of this
+ DIE. */
+ next_range<die_info> children () const
+ {
+ return next_range<die_info> (child);
+ }
+
/* DWARF-2 tag for this DIE. */
ENUM_BITFIELD(dwarf_tag) tag : 16;
@@ -128,9 +136,9 @@ struct die_info
/* The dies in a compilation unit form an n-ary tree. PARENT
points to this die's parent; CHILD points to the first child of
this node; and all the children of a given node are chained
- together via their SIBLING fields. */
+ together via their NEXT fields. */
struct die_info *child; /* Its first child, if any. */
- struct die_info *sibling; /* Its next sibling, if any. */
+ struct die_info *next; /* Its next sibling, if any. */
struct die_info *parent; /* Its parent, if any. */
/* An array of attributes, with NUM_ATTRS elements. There may be
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 7c12c0d..8f66694 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -1784,6 +1784,7 @@ dwarf2_compile_property_to_c (string_file *stream,
CORE_ADDR pc,
struct symbol *sym)
{
+#if defined (HAVE_COMPILE)
const dwarf2_property_baton *baton = prop->baton ();
const gdb_byte *data;
size_t size;
@@ -1810,6 +1811,9 @@ dwarf2_compile_property_to_c (string_file *stream,
gdbarch, registers_used,
per_cu->addr_size (),
data, data + size, per_cu, per_objfile);
+#else
+ gdb_assert_not_reached ("Compile support was disabled");
+#endif
}
/* Compute the correct symbol_needs_kind value for the location
@@ -3852,6 +3856,7 @@ locexpr_generate_c_location (struct symbol *sym, string_file *stream,
std::vector<bool> &registers_used,
CORE_ADDR pc, const char *result_name)
{
+#if defined (HAVE_COMPILE)
struct dwarf2_locexpr_baton *dlbaton
= (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (sym);
unsigned int addr_size = dlbaton->per_cu->addr_size ();
@@ -3863,6 +3868,9 @@ locexpr_generate_c_location (struct symbol *sym, string_file *stream,
sym, pc, gdbarch, registers_used, addr_size,
dlbaton->data, dlbaton->data + dlbaton->size,
dlbaton->per_cu, dlbaton->per_objfile);
+#else
+ gdb_assert_not_reached ("Compile support was disabled");
+#endif
}
/* The set of location functions used with the DWARF-2 expression
@@ -4088,6 +4096,7 @@ loclist_generate_c_location (struct symbol *sym, string_file *stream,
std::vector<bool> &registers_used,
CORE_ADDR pc, const char *result_name)
{
+#if defined (HAVE_COMPILE)
struct dwarf2_loclist_baton *dlbaton
= (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (sym);
unsigned int addr_size = dlbaton->per_cu->addr_size ();
@@ -4103,6 +4112,9 @@ loclist_generate_c_location (struct symbol *sym, string_file *stream,
data, data + size,
dlbaton->per_cu,
dlbaton->per_objfile);
+#else
+ gdb_assert_not_reached ("Compile support was disabled");
+#endif
}
/* The set of location functions used with the DWARF-2 expression
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index b9040a5..3d7b6dd 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1791,7 +1791,7 @@ dw2_get_file_names (dwarf2_per_cu *this_cu, dwarf2_per_objfile *per_objfile)
if (this_cu->files_read)
return this_cu->file_names;
- cutu_reader reader (this_cu, per_objfile, nullptr,
+ cutu_reader reader (*this_cu, *per_objfile, nullptr,
per_objfile->get_cu (this_cu), true, language_minimal,
nullptr);
if (!reader.is_dummy ())
@@ -2710,8 +2710,7 @@ cutu_reader::init_cu_die_reader (dwarf2_cu *cu, dwarf2_section_info *section,
void
cutu_reader::read_cutu_die_from_dwo (dwarf2_cu *cu, dwo_unit *dwo_unit,
die_info *stub_comp_unit_die,
- const char *stub_comp_dir,
- abbrev_table_up *result_dwo_abbrev_table)
+ const char *stub_comp_dir)
{
dwarf2_per_objfile *per_objfile = cu->per_objfile;
dwarf2_per_cu *per_cu = cu->per_cu;
@@ -2829,10 +2828,18 @@ cutu_reader::read_cutu_die_from_dwo (dwarf2_cu *cu, dwo_unit *dwo_unit,
}
dwo_abbrev_section->read (objfile);
- *result_dwo_abbrev_table
+ m_dwo_abbrev_table
= abbrev_table::read (dwo_abbrev_section, cu->header.abbrev_sect_off);
this->init_cu_die_reader (cu, section, dwo_unit->dwo_file,
- result_dwo_abbrev_table->get ());
+ m_dwo_abbrev_table.get ());
+
+ /* Skip dummy compilation units. */
+ if (m_info_ptr >= begin_info_ptr + dwo_unit->length
+ || peek_abbrev_code (abfd, m_info_ptr) == 0)
+ {
+ m_dummy_p = true;
+ return;
+ }
/* Read in the die, filling in the attributes from the stub. This
has the benefit of simplifying the rest of the code - all the
@@ -2841,11 +2848,6 @@ cutu_reader::read_cutu_die_from_dwo (dwarf2_cu *cu, dwo_unit *dwo_unit,
m_top_level_die
= this->read_toplevel_die (gdb::make_array_view (attributes,
next_attr_idx));
-
- /* Skip dummy compilation units. */
- if (m_info_ptr >= begin_info_ptr + dwo_unit->length
- || peek_abbrev_code (abfd, m_info_ptr) == 0)
- m_dummy_p = true;
}
/* Return the signature of the compile unit, if found. In DWARF 4 and before,
@@ -2864,8 +2866,12 @@ lookup_dwo_id (struct dwarf2_cu *cu, struct die_info* comp_unit_die)
}
/* Subroutine of cutu_reader to simplify it.
- Look up the DWO unit specified by COMP_UNIT_DIE of THIS_CU.
- Returns NULL if the specified DWO unit cannot be found. */
+ Look up the DWO unit specified by COMP_UNIT_DIE of CU.
+
+ DWO_NAME is the name (DW_AT_dwo_name) of the DWO unit already read from
+ COMP_UNIT_DIE.
+
+ Returns nullptr if the specified DWO unit cannot be found. */
static struct dwo_unit *
lookup_dwo_unit (dwarf2_cu *cu, die_info *comp_unit_die, const char *dwo_name)
@@ -2883,8 +2889,6 @@ lookup_dwo_unit (dwarf2_cu *cu, die_info *comp_unit_die, const char *dwo_name)
gdb_assert (cu != NULL);
- /* Yeah, we look dwo_name up again, but it simplifies the code. */
- dwo_name = dwarf2_dwo_name (comp_unit_die, cu);
comp_dir = dwarf2_string_attr (comp_unit_die, DW_AT_comp_dir, cu);
if (per_cu->is_debug_types)
@@ -2946,8 +2950,7 @@ cutu_reader::init_tu_and_read_dwo_dies (dwarf2_per_cu *this_cu,
could share abbrev tables. */
read_cutu_die_from_dwo (cu, sig_type->dwo_unit, NULL /* stub_comp_unit_die */,
- sig_type->dwo_unit->dwo_file->comp_dir,
- &m_dwo_abbrev_table);
+ sig_type->dwo_unit->dwo_file->comp_dir);
prepare_one_comp_unit (cu, pretend_language);
}
@@ -2961,16 +2964,16 @@ cutu_reader::init_tu_and_read_dwo_dies (dwarf2_per_cu *this_cu,
If EXISTING_CU is non-NULL, then use it. Otherwise, a new CU is
allocated. */
-cutu_reader::cutu_reader (dwarf2_per_cu *this_cu,
- dwarf2_per_objfile *per_objfile,
+cutu_reader::cutu_reader (dwarf2_per_cu &this_cu,
+ dwarf2_per_objfile &per_objfile,
const struct abbrev_table *abbrev_table,
dwarf2_cu *existing_cu,
bool skip_partial,
enum language pretend_language,
const abbrev_table_cache *cache)
{
- struct objfile *objfile = per_objfile->objfile;
- struct dwarf2_section_info *section = this_cu->section;
+ struct objfile *objfile = per_objfile.objfile;
+ struct dwarf2_section_info *section = this_cu.section;
bfd *abfd = section->get_bfd_owner ();
const gdb_byte *begin_info_ptr;
struct signatured_type *sig_type = NULL;
@@ -2982,17 +2985,17 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu,
if (dwarf_die_debug)
gdb_printf (gdb_stdlog, "Reading %s unit at offset %s\n",
- this_cu->is_debug_types ? "type" : "comp",
- sect_offset_str (this_cu->sect_off));
+ this_cu.is_debug_types ? "type" : "comp",
+ sect_offset_str (this_cu.sect_off));
/* If we're reading a TU directly from a DWO file, including a virtual DWO
file (instead of going through the stub), short-circuit all of this. */
- if (this_cu->reading_dwo_directly)
+ if (this_cu.reading_dwo_directly)
{
/* Narrow down the scope of possibilities to have to understand. */
- gdb_assert (this_cu->is_debug_types);
+ gdb_assert (this_cu.is_debug_types);
gdb_assert (abbrev_table == NULL);
- init_tu_and_read_dwo_dies (this_cu, per_objfile, existing_cu,
+ init_tu_and_read_dwo_dies (&this_cu, &per_objfile, existing_cu,
pretend_language);
return;
}
@@ -3001,9 +3004,9 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu,
section->read (objfile);
begin_info_ptr = m_info_ptr
- = section->buffer + to_underlying (this_cu->sect_off);
+ = section->buffer + to_underlying (this_cu.sect_off);
- abbrev_section = get_abbrev_section_for_cu (this_cu);
+ abbrev_section = get_abbrev_section_for_cu (&this_cu);
dwarf2_cu *cu;
@@ -3028,8 +3031,8 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu,
is irrelevant, and (2) the get_cu method is not
thread-safe. */
gdb_assert (cache != nullptr
- || per_objfile->get_cu (this_cu) == nullptr);
- m_new_cu = std::make_unique<dwarf2_cu> (this_cu, per_objfile);
+ || per_objfile.get_cu (&this_cu) == nullptr);
+ m_new_cu = std::make_unique<dwarf2_cu> (&this_cu, &per_objfile);
cu = m_new_cu.get ();
}
@@ -3041,43 +3044,43 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu,
}
else
{
- if (this_cu->is_debug_types)
+ if (this_cu.is_debug_types)
{
m_info_ptr
- = read_and_check_comp_unit_head (per_objfile, &cu->header, section,
+ = read_and_check_comp_unit_head (&per_objfile, &cu->header, section,
abbrev_section, m_info_ptr,
rcuh_kind::TYPE);
/* Since per_cu is the first member of struct signatured_type,
we can go from a pointer to one to a pointer to the other. */
- sig_type = (struct signatured_type *) this_cu;
+ sig_type = (struct signatured_type *) &this_cu;
gdb_assert (sig_type->signature == cu->header.signature);
gdb_assert (sig_type->type_offset_in_tu
== cu->header.type_cu_offset_in_tu);
- gdb_assert (this_cu->sect_off == cu->header.sect_off);
+ gdb_assert (this_cu.sect_off == cu->header.sect_off);
/* LENGTH has not been set yet for type units if we're
using .gdb_index. */
- this_cu->set_length (cu->header.get_length_with_initial ());
+ this_cu.set_length (cu->header.get_length_with_initial ());
/* Establish the type offset that can be used to lookup the type. */
sig_type->type_offset_in_section =
- this_cu->sect_off + to_underlying (sig_type->type_offset_in_tu);
+ this_cu.sect_off + to_underlying (sig_type->type_offset_in_tu);
}
else
{
m_info_ptr
- = read_and_check_comp_unit_head (per_objfile, &cu->header, section,
+ = read_and_check_comp_unit_head (&per_objfile, &cu->header, section,
abbrev_section, m_info_ptr,
rcuh_kind::COMPILE);
- gdb_assert (this_cu->sect_off == cu->header.sect_off);
- this_cu->set_length (cu->header.get_length_with_initial ());
+ gdb_assert (this_cu.sect_off == cu->header.sect_off);
+ this_cu.set_length (cu->header.get_length_with_initial ());
}
}
/* Skip dummy compilation units. */
- if (m_info_ptr >= begin_info_ptr + this_cu->length ()
+ if (m_info_ptr >= begin_info_ptr + this_cu.length ()
|| peek_abbrev_code (abfd, m_info_ptr) == 0)
m_dummy_p = true;
else
@@ -3129,14 +3132,13 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu,
{
complaint (_("compilation unit with DW_AT_GNU_dwo_name"
" has children (offset %s) [in module %s]"),
- sect_offset_str (this_cu->sect_off),
+ sect_offset_str (this_cu.sect_off),
bfd_get_filename (abfd));
}
dwo_unit = lookup_dwo_unit (cu, m_top_level_die, dwo_name);
if (dwo_unit != NULL)
- read_cutu_die_from_dwo (cu, dwo_unit, m_top_level_die, nullptr,
- &m_dwo_abbrev_table);
+ read_cutu_die_from_dwo (cu, dwo_unit, m_top_level_die, nullptr);
else
{
/* Yikes, we couldn't find the rest of the DIE, we only have
@@ -3165,65 +3167,57 @@ cutu_reader::release_cu ()
return std::move (m_new_cu);
}
-/* Read CU/TU THIS_CU but do not follow DW_AT_GNU_dwo_name (DW_AT_dwo_name)
- if present. DWO_FILE, if non-NULL, is the DWO file to read (the caller is
- assumed to have already done the lookup to find the DWO file).
-
- The caller is required to fill in THIS_CU->section, THIS_CU->offset, and
- THIS_CU->is_debug_types, but nothing else.
-
- We fill in THIS_CU->length.
+/* This constructor exists for the special case of reading many units in a row
+ from a given known DWO file.
- THIS_CU->cu is always freed when done.
- This is done in order to not leave THIS_CU->cu in a state where we have
- to care whether it refers to the "main" CU or the DWO CU.
+ THIS_CU is a special dwarf2_per_cu to represent where to read the unit from,
+ in the DWO file. The caller is required to fill THIS_CU::SECTION,
+ THIS_CU::SECT_OFF, and THIS_CU::IS_DEBUG_TYPES. This constructor will fill
+ in the length. THIS_CU::SECTION must point to a section from the DWO file,
+ which is normally not the case for regular dwarf2_per_cu uses.
- When parent_cu is passed, it is used to provide a default value for
- str_offsets_base and addr_base from the parent. */
+ PARENT_CU is the CU created when reading the skeleton unit, and is used to
+ provide a default value for str_offsets_base and addr_base. */
-cutu_reader::cutu_reader (dwarf2_per_cu *this_cu,
- dwarf2_per_objfile *per_objfile,
- enum language pretend_language,
- struct dwarf2_cu *parent_cu,
- struct dwo_file *dwo_file)
+cutu_reader::cutu_reader (dwarf2_per_cu &this_cu,
+ dwarf2_per_objfile &per_objfile,
+ language pretend_language, dwarf2_cu &parent_cu,
+ dwo_file &dwo_file)
{
- struct objfile *objfile = per_objfile->objfile;
- struct dwarf2_section_info *section = this_cu->section;
+ struct objfile *objfile = per_objfile.objfile;
+ struct dwarf2_section_info *section = this_cu.section;
bfd *abfd = section->get_bfd_owner ();
- gdb_assert (parent_cu != nullptr);
- gdb_assert (dwo_file != nullptr);
-
if (dwarf_die_debug)
gdb_printf (gdb_stdlog, "Reading %s unit at offset %s\n",
- this_cu->is_debug_types ? "type" : "comp",
- sect_offset_str (this_cu->sect_off));
+ this_cu.is_debug_types ? "type" : "comp",
+ sect_offset_str (this_cu.sect_off));
- gdb_assert (per_objfile->get_cu (this_cu) == nullptr);
+ gdb_assert (per_objfile.get_cu (&this_cu) == nullptr);
- dwarf2_section_info *abbrev_section = &dwo_file->sections.abbrev;
+ dwarf2_section_info *abbrev_section = &dwo_file.sections.abbrev;
/* This is cheap if the section is already read in. */
section->read (objfile);
- m_new_cu = std::make_unique<dwarf2_cu> (this_cu, per_objfile);
+ m_new_cu = std::make_unique<dwarf2_cu> (&this_cu, &per_objfile);
- m_info_ptr = section->buffer + to_underlying (this_cu->sect_off);
+ m_info_ptr = section->buffer + to_underlying (this_cu.sect_off);
const gdb_byte *begin_info_ptr = m_info_ptr;
m_info_ptr
- = read_and_check_comp_unit_head (per_objfile, &m_new_cu->header, section,
+ = read_and_check_comp_unit_head (&per_objfile, &m_new_cu->header, section,
abbrev_section, m_info_ptr,
- (this_cu->is_debug_types
+ (this_cu.is_debug_types
? rcuh_kind::TYPE
: rcuh_kind::COMPILE));
- m_new_cu->str_offsets_base = parent_cu->str_offsets_base;
- m_new_cu->addr_base = parent_cu->addr_base;
+ m_new_cu->str_offsets_base = parent_cu.str_offsets_base;
+ m_new_cu->addr_base = parent_cu.addr_base;
- this_cu->set_length (m_new_cu->header.get_length_with_initial ());
+ this_cu.set_length (m_new_cu->header.get_length_with_initial ());
/* Skip dummy compilation units. */
- if (m_info_ptr >= begin_info_ptr + this_cu->length ()
+ if (m_info_ptr >= begin_info_ptr + this_cu.length ()
|| peek_abbrev_code (abfd, m_info_ptr) == 0)
m_dummy_p = true;
else
@@ -3233,7 +3227,7 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu,
= abbrev_table::read (abbrev_section,
m_new_cu->header.abbrev_sect_off);
- this->init_cu_die_reader (m_new_cu.get (), section, dwo_file,
+ this->init_cu_die_reader (m_new_cu.get (), section, &dwo_file,
m_abbrev_table_holder.get ());
m_top_level_die = this->read_toplevel_die ();
}
@@ -3300,7 +3294,7 @@ process_psymtab_comp_unit (dwarf2_per_cu *this_cu,
cutu_reader *reader = storage->get_reader (this_cu);
if (reader == nullptr)
{
- cutu_reader new_reader (this_cu, per_objfile, nullptr, nullptr, false,
+ cutu_reader new_reader (*this_cu, *per_objfile, nullptr, nullptr, false,
language_minimal,
&storage->get_abbrev_table_cache ());
@@ -3447,7 +3441,7 @@ build_type_psymtabs (dwarf2_per_objfile *per_objfile,
++tu_stats->nr_uniq_abbrev_tables;
}
- cutu_reader reader (tu.sig_type, per_objfile,
+ cutu_reader reader (*tu.sig_type, *per_objfile,
abbrev_table.get (), nullptr, false,
language_minimal);
if (!reader.is_dummy ())
@@ -3501,7 +3495,7 @@ process_skeletonless_type_unit (dwo_unit *dwo_unit,
fill_in_sig_entry_from_dwo_entry (per_objfile, *sig_type_it, dwo_unit);
/* This does the job that build_type_psymtabs would have done. */
- cutu_reader reader (*sig_type_it, per_objfile, nullptr, nullptr, false,
+ cutu_reader reader (**sig_type_it, *per_objfile, nullptr, nullptr, false,
language_minimal);
if (!reader.is_dummy ())
build_type_psymtabs_reader (&reader, storage);
@@ -4223,7 +4217,7 @@ load_full_comp_unit (dwarf2_per_cu *this_cu, dwarf2_per_objfile *per_objfile,
gdb_assert (! this_cu->is_debug_types);
gdb_assert (per_objfile->get_cu (this_cu) == nullptr);
- cutu_reader reader (this_cu, per_objfile, nullptr, nullptr, skip_partial,
+ cutu_reader reader (*this_cu, *per_objfile, nullptr, nullptr, skip_partial,
pretend_language);
if (reader.is_dummy ())
return;
@@ -5456,12 +5450,11 @@ dwarf2_compute_name (const char *name,
if (lang == language_cplus && strchr (name, '<') == NULL)
{
struct attribute *attr;
- struct die_info *child;
int first = 1;
die->building_fullname = 1;
- for (child = die->child; child != NULL; child = child->sibling)
+ for (die_info *child : die->children ())
{
struct type *type;
LONGEST value;
@@ -5825,7 +5818,7 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->per_objfile->objfile;
struct attribute *import_attr;
- struct die_info *imported_die, *child_die;
+ struct die_info *imported_die;
struct dwarf2_cu *imported_cu;
const char *imported_name;
const char *imported_name_prefix;
@@ -5908,10 +5901,8 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
else
canonical_name = imported_name;
- if (die->tag == DW_TAG_imported_module
- && cu->lang () == language_fortran)
- for (child_die = die->child; child_die && child_die->tag;
- child_die = child_die->sibling)
+ if (die->tag == DW_TAG_imported_module && cu->lang () == language_fortran)
+ for (die_info *child_die : die->children ())
{
/* DWARF-4: A Fortran use statement with a “rename list” may be
represented by an imported module entry with an import attribute
@@ -6098,7 +6089,6 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
struct objfile *objfile = per_objfile->objfile;
CORE_ADDR lowpc;
struct attribute *attr;
- struct die_info *child_die;
unrelocated_addr unrel_low, unrel_high;
get_scope_pc_bounds (die, &unrel_low, &unrel_high, cu);
@@ -6145,15 +6135,9 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
handle_DW_AT_stmt_list (die, cu, fnd, unrel_low, unrel_low != unrel_high);
/* Process all dies in compilation unit. */
- if (die->child != NULL)
- {
- child_die = die->child;
- while (child_die && child_die->tag)
- {
- process_die (child_die, cu);
- child_die = child_die->sibling;
- }
- }
+ for (die_info *child_die : die->children ())
+ process_die (child_die, cu);
+
per_objfile->sym_cu = nullptr;
/* Decode macro information, if present. Dwarf 2 macro information
@@ -6309,22 +6293,13 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
static void
read_type_unit_scope (struct die_info *die, struct dwarf2_cu *cu)
{
- struct die_info *child_die;
-
/* Initialize (or reinitialize) the machinery for building symtabs.
We do this before processing child DIEs, so that the line header table
is available for DW_AT_decl_file. */
cu->setup_type_unit_groups (die);
- if (die->child != NULL)
- {
- child_die = die->child;
- while (child_die && child_die->tag)
- {
- process_die (child_die, cu);
- child_die = child_die->sibling;
- }
- }
+ for (die_info *child_die : die->children ())
+ process_die (child_die, cu);
}
/* DWO/DWP files.
@@ -6377,8 +6352,8 @@ create_cus_hash_table (dwarf2_cu *cu, dwo_file &dwo_file)
/* The length of the CU gets set by the cutu_reader just below. */
dwarf2_per_cu per_cu (per_bfd, &section, sect_off, 0 /* length */,
false /* is_dwz */);
- cutu_reader reader (&per_cu, per_objfile, language_minimal,
- cu, &dwo_file);
+ cutu_reader reader (per_cu, *per_objfile, language_minimal,
+ *cu, dwo_file);
info_ptr += per_cu.length ();
@@ -8210,8 +8185,8 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
break;
}
- concrete_child = concrete_child->sibling;
- abstract_child = abstract_child->sibling;
+ concrete_child = concrete_child->next;
+ abstract_child = abstract_child->next;
}
/* Walk the origin's children in parallel to the concrete children.
@@ -8224,9 +8199,7 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
std::vector<sect_offset> offsets;
- for (die_info *child_die = die->child;
- child_die && child_die->tag;
- child_die = child_die->sibling)
+ for (die_info *child_die : die->children ())
{
/* We are trying to process concrete instance entries:
DW_TAG_call_site DIEs indeed have a DW_AT_abstract_origin tag, but
@@ -8238,7 +8211,7 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
{
if (are_isomorphic)
corresponding_abstract_child
- = corresponding_abstract_child->sibling;
+ = corresponding_abstract_child->next;
continue;
}
@@ -8296,7 +8269,7 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
}
if (are_isomorphic)
- corresponding_abstract_child = corresponding_abstract_child->sibling;
+ corresponding_abstract_child = corresponding_abstract_child->next;
}
if (!offsets.empty ())
@@ -8314,8 +8287,7 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
}
auto offsets_it = offsets.begin ();
- die_info *origin_child_die = origin_die->child;
- while (origin_child_die != nullptr && origin_child_die->tag != 0)
+ for (die_info *origin_child_die : origin_die->children ())
{
/* Is ORIGIN_CHILD_DIE referenced by any of the DIE children? */
while (offsets_it < offsets.end ()
@@ -8332,8 +8304,6 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
if (!origin_child_die->in_process)
process_die (origin_child_die, origin_cu);
}
-
- origin_child_die = origin_child_die->sibling;
}
origin_cu->list_in_scope = origin_previous_list_in_scope;
@@ -8424,7 +8394,6 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
struct context_stack *newobj;
CORE_ADDR lowpc;
CORE_ADDR highpc;
- struct die_info *child_die;
struct attribute *attr, *call_line, *call_file;
const char *name;
struct block *block;
@@ -8501,7 +8470,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
/* If we have any template arguments, then we must allocate a
different sort of symbol. */
- for (child_die = die->child; child_die; child_die = child_die->sibling)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag == DW_TAG_template_type_param
|| child_die->tag == DW_TAG_template_value_param)
@@ -8539,23 +8508,18 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
cu->list_in_scope = cu->get_builder ()->get_local_symbols ();
- if (die->child != NULL)
+ for (die_info *child_die : die->children ())
{
- child_die = die->child;
- while (child_die && child_die->tag)
+ if (child_die->tag == DW_TAG_template_type_param
+ || child_die->tag == DW_TAG_template_value_param)
{
- if (child_die->tag == DW_TAG_template_type_param
- || child_die->tag == DW_TAG_template_value_param)
- {
- struct symbol *arg = new_symbol (child_die, NULL, cu);
+ struct symbol *arg = new_symbol (child_die, NULL, cu);
- if (arg != NULL)
- template_args.push_back (arg);
- }
- else
- process_die (child_die, cu);
- child_die = child_die->sibling;
+ if (arg != NULL)
+ template_args.push_back (arg);
}
+ else
+ process_die (child_die, cu);
}
inherit_abstract_dies (die, cu);
@@ -8571,13 +8535,9 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
while (spec_die)
{
- child_die = spec_die->child;
- while (child_die && child_die->tag)
- {
- if (child_die->tag == DW_TAG_imported_module)
- process_die (child_die, spec_cu);
- child_die = child_die->sibling;
- }
+ for (die_info *child_die : spec_die->children ())
+ if (child_die->tag == DW_TAG_imported_module)
+ process_die (child_die, spec_cu);
/* In some cases, GCC generates specification DIEs that
themselves contain DW_AT_specification attributes. */
@@ -8646,7 +8606,6 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
{
dwarf2_per_objfile *per_objfile = cu->per_objfile;
CORE_ADDR lowpc, highpc;
- struct die_info *child_die;
/* Ignore blocks with missing or invalid low and high pc attributes. */
/* ??? Perhaps consider discontiguous blocks defined by DW_AT_ranges
@@ -8661,9 +8620,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
/* DW_TAG_lexical_block has no attributes, process its children as if
there was no wrapping by that DW_TAG_lexical_block.
GCC does no longer produces such DWARF since GCC r224161. */
- for (child_die = die->child;
- child_die != NULL && child_die->tag;
- child_die = child_die->sibling)
+ for (die_info *child_die : die->children ())
{
/* We might already be processing this DIE. This can happen
in an unusual circumstance -- where a subroutine A
@@ -8682,15 +8639,9 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
highpc = per_objfile->relocate (unrel_high);
cu->get_builder ()->push_context (0, lowpc);
- if (die->child != NULL)
- {
- child_die = die->child;
- while (child_die && child_die->tag)
- {
- process_die (child_die, cu);
- child_die = child_die->sibling;
- }
- }
+ for (die_info *child_die : die->children ())
+ process_die (child_die, cu);
+
inherit_abstract_dies (die, cu);
struct context_stack cstk = cu->get_builder ()->pop_context ();
@@ -8733,7 +8684,6 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
struct gdbarch *gdbarch = objfile->arch ();
struct attribute *attr;
int nparams;
- struct die_info *child_die;
attr = dwarf2_attr (die, DW_AT_call_return_pc, cu);
if (attr == NULL)
@@ -8754,8 +8704,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
/* Count parameters at the caller. */
nparams = 0;
- for (child_die = die->child; child_die && child_die->tag;
- child_die = child_die->sibling)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag != DW_TAG_call_site_parameter
&& child_die->tag != DW_TAG_GNU_call_site_parameter)
@@ -8924,9 +8873,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
"block nor reference, for DIE %s [in module %s]"),
sect_offset_str (die->sect_off), objfile_name (objfile));
- for (child_die = die->child;
- child_die && child_die->tag;
- child_die = child_die->sibling)
+ for (die_info *child_die : die->children ())
{
struct call_site_parameter *parameter;
struct attribute *loc, *origin;
@@ -9646,7 +9593,6 @@ dwarf2_get_subprogram_pc_bounds (struct die_info *die,
struct dwarf2_cu *cu)
{
unrelocated_addr low, high;
- struct die_info *child = die->child;
if (dwarf2_get_pc_bounds (die, &low, &high, cu, nullptr, nullptr)
>= PC_BOUNDS_RANGES)
@@ -9664,12 +9610,11 @@ dwarf2_get_subprogram_pc_bounds (struct die_info *die,
subprograms, then check their pc bounds. Likewise, we need to
check lexical blocks as well, as they may also contain subprogram
definitions. */
- while (child && child->tag)
+ for (die_info *child : die->children ())
{
if (child->tag == DW_TAG_subprogram
|| child->tag == DW_TAG_lexical_block)
dwarf2_get_subprogram_pc_bounds (child, lowpc, highpc, cu);
- child = child->sibling;
}
}
@@ -9695,9 +9640,7 @@ get_scope_pc_bounds (struct die_info *die,
}
else
{
- struct die_info *child = die->child;
-
- while (child && child->tag)
+ for (die_info *child : die->children ())
{
switch (child->tag) {
case DW_TAG_subprogram:
@@ -9725,8 +9668,6 @@ get_scope_pc_bounds (struct die_info *die,
/* Ignore. */
break;
}
-
- child = child->sibling;
}
}
@@ -11277,9 +11218,7 @@ handle_variant_part (struct die_info *die, struct type *type,
objfile_name (cu->per_objfile->objfile));
}
- for (die_info *child_die = die->child;
- child_die != NULL;
- child_die = child_die->sibling)
+ for (die_info *child_die : die->children ())
handle_struct_member_die (child_die, type, fi, template_args, cu);
}
@@ -11330,9 +11269,7 @@ handle_variant (struct die_info *die, struct type *type,
else
variant.discriminant_value = discr->constant_value (0);
- for (die_info *variant_child = die->child;
- variant_child != NULL;
- variant_child = variant_child->sibling)
+ for (die_info *variant_child : die->children ())
handle_struct_member_die (variant_child, type, fi, template_args, cu);
variant.last_field = fi->fields.size ();
@@ -11401,7 +11338,6 @@ static void
process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->per_objfile->objfile;
- struct die_info *child_die;
struct type *type;
type = get_die_type (die, cu);
@@ -11414,13 +11350,8 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
struct field_info fi;
std::vector<struct symbol *> template_args;
- child_die = die->child;
-
- while (child_die && child_die->tag)
- {
- handle_struct_member_die (child_die, type, &fi, &template_args, cu);
- child_die = child_die->sibling;
- }
+ for (die_info *child_die : die->children ())
+ handle_struct_member_die (child_die, type, &fi, &template_args, cu);
/* Attach template arguments to type. */
if (!template_args.empty ())
@@ -11558,9 +11489,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
current die is a declaration. Normally, of course, a declaration
won't have any children at all. */
- child_die = die->child;
-
- while (child_die != NULL && child_die->tag)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag == DW_TAG_member
|| child_die->tag == DW_TAG_variable
@@ -11572,8 +11501,6 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
}
else
process_die (child_die, cu);
-
- child_die = child_die->sibling;
}
/* Do not consider external references. According to the DWARF standard,
@@ -11673,16 +11600,13 @@ update_enumeration_type_from_children (struct die_info *die,
struct type *type,
struct dwarf2_cu *cu)
{
- struct die_info *child_die;
int unsigned_enum = 1;
int flag_enum = 1;
auto_obstack obstack;
std::vector<struct field> fields;
- for (child_die = die->child;
- child_die != NULL && child_die->tag;
- child_die = child_die->sibling)
+ for (die_info *child_die : die->children ())
{
struct attribute *attr;
LONGEST value;
@@ -11840,10 +11764,7 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
if (die->child != NULL)
{
- struct die_info *child_die;
-
- child_die = die->child;
- while (child_die && child_die->tag)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag != DW_TAG_enumerator)
{
@@ -11851,8 +11772,6 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
}
else
new_symbol (child_die, this_type, cu);
-
- child_die = child_die->sibling;
}
}
@@ -12033,9 +11952,7 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu,
int bounds_offset = -1;
int max_align = -1;
std::vector<struct field> range_fields;
- for (struct die_info *child_die = die->child;
- child_die;
- child_die = child_die->sibling)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag == DW_TAG_subrange_type)
{
@@ -12136,7 +12053,6 @@ static struct type *
read_array_type (struct die_info *die, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->per_objfile->objfile;
- struct die_info *child_die;
struct type *type;
struct type *element_type, *range_type, *index_type;
struct attribute *attr;
@@ -12191,8 +12107,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
}
std::vector<struct type *> range_types;
- child_die = die->child;
- while (child_die && child_die->tag)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag == DW_TAG_subrange_type
|| child_die->tag == DW_TAG_generic_subrange)
@@ -12206,7 +12121,6 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
range_types.push_back (child_type);
}
}
- child_die = child_die->sibling;
}
if (range_types.empty ())
@@ -12473,15 +12387,12 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
if (die->child != NULL)
{
struct objfile *objfile = cu->per_objfile->objfile;
- struct die_info *child_die;
- size_t n_entries = 0, size;
+ size_t size;
struct common_block *common_block;
struct symbol *sym;
- for (child_die = die->child;
- child_die && child_die->tag;
- child_die = child_die->sibling)
- ++n_entries;
+ auto range = die->children ();
+ size_t n_entries = std::distance (range.begin (), range.end ());
size = (sizeof (struct common_block)
+ (n_entries - 1) * sizeof (struct symbol *));
@@ -12491,9 +12402,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
memset (common_block->contents, 0, n_entries * sizeof (struct symbol *));
common_block->n_entries = 0;
- for (child_die = die->child;
- child_die && child_die->tag;
- child_die = child_die->sibling)
+ for (die_info *child_die : die->children ())
{
/* Create the symbol in the DW_TAG_common_block block in the current
symbol scope. */
@@ -12616,13 +12525,8 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu)
if (die->child != NULL)
{
- struct die_info *child_die = die->child;
-
- while (child_die && child_die->tag)
- {
- process_die (child_die, cu);
- child_die = child_die->sibling;
- }
+ for (die_info *child_die : die->children ())
+ process_die (child_die, cu);
}
}
@@ -12660,17 +12564,13 @@ read_module_type (struct die_info *die, struct dwarf2_cu *cu)
static void
read_module (struct die_info *die, struct dwarf2_cu *cu)
{
- struct die_info *child_die = die->child;
struct type *type;
type = read_type_die (die, cu);
new_symbol (die, type, cu);
- while (child_die && child_die->tag)
- {
- process_die (child_die, cu);
- child_die = child_die->sibling;
- }
+ for (die_info *child_die : die->children ())
+ process_die (child_die, cu);
}
/* Return the name of the namespace represented by DIE. Set
@@ -13168,22 +13068,18 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
if (die->child != NULL)
{
struct type *void_type = builtin_type (objfile)->builtin_void;
- struct die_info *child_die;
int nparams, iparams;
/* Count the number of parameters.
FIXME: GDB currently ignores vararg functions, but knows about
vararg member functions. */
nparams = 0;
- child_die = die->child;
- while (child_die && child_die->tag)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag == DW_TAG_formal_parameter)
nparams++;
else if (child_die->tag == DW_TAG_unspecified_parameters)
ftype->set_has_varargs (true);
-
- child_die = child_die->sibling;
}
/* Allocate storage for parameters and fill them in. */
@@ -13195,8 +13091,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
ftype->field (iparams).set_type (void_type);
iparams = 0;
- child_die = die->child;
- while (child_die && child_die->tag)
+ for (die_info *child_die : die->children ())
{
if (child_die->tag == DW_TAG_formal_parameter)
{
@@ -13253,7 +13148,6 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
ftype->field (iparams).set_type (arg_type);
iparams++;
}
- child_die = child_die->sibling;
}
}
@@ -14350,7 +14244,7 @@ read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu)
return set_die_type (die, type, cu);
}
-/* Read a single die and all its descendents. Set the die's sibling
+/* Read a single die and all its descendents. Set the die's next
field to NULL; set other fields in the die correctly, and set all
of the descendents' fields correctly. PARENT is the parent of the
die in question. */
@@ -14371,7 +14265,7 @@ cutu_reader::read_die_and_children (die_info *parent)
else
die->child = nullptr;
- die->sibling = nullptr;
+ die->next = nullptr;
die->parent = parent;
return die;
}
@@ -14396,7 +14290,7 @@ cutu_reader::read_die_and_siblings (die_info *parent)
if (first_die == nullptr)
first_die = die;
else
- last_sibling->sibling = die;
+ last_sibling->next = die;
last_sibling = die;
}
@@ -14435,7 +14329,7 @@ cutu_reader::read_all_dies ()
and updating die_info::num_attrs.
Return a newly allocated die with its information, except for its
- child, sibling, and parent fields. */
+ child, next, and parent fields. */
die_info *
cutu_reader::read_full_die (int num_extra_attrs, bool allow_reprocess)
@@ -14479,7 +14373,7 @@ cutu_reader::read_full_die (int num_extra_attrs, bool allow_reprocess)
/* Read a die and all its attributes.
Return a newly allocated die with its information, except for its
- child, sibling, and parent fields. */
+ child, next, and parent fields. */
die_info *
cutu_reader::read_toplevel_die (gdb::array_view<attribute *> extra_attrs)
@@ -15423,7 +15317,7 @@ dwarf2_read_addr_index (dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile,
}
else
{
- cutu_reader reader (per_cu, per_objfile, nullptr, nullptr, false,
+ cutu_reader reader (*per_cu, *per_objfile, nullptr, nullptr, false,
language_minimal);
addr_base = reader.cu ()->addr_base;
addr_size = reader.cu ()->header.addr_size;
@@ -17767,7 +17661,6 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu)
{
struct die_info *spec_die;
struct dwarf2_cu *spec_cu;
- struct die_info *child;
struct objfile *objfile = cu->per_objfile->objfile;
spec_cu = cu;
@@ -17778,9 +17671,7 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu)
cu = spec_cu;
}
- for (child = die->child;
- child != NULL;
- child = child->sibling)
+ for (die_info *child : die->children ())
{
if (child->tag == DW_TAG_subprogram)
{
@@ -18106,18 +17997,19 @@ unnamed_template_tag_name (die_info *die, dwarf2_cu *cu)
arrive at our entry. */
size_t nth_unnamed = 0;
- die_info *child = die->parent->child;
- while (child != die)
- {
- gdb_assert (child != nullptr);
- if (child->tag == DW_TAG_template_type_param
- || child->tag == DW_TAG_template_value_param)
- {
- if (dwarf2_attr (child, DW_AT_name, cu) == nullptr)
- ++nth_unnamed;
- }
- child = child->sibling;
- }
+ for (die_info *child : die->parent->children ())
+ {
+ if (child == die)
+ break;
+
+ gdb_assert (child != nullptr);
+ if (child->tag == DW_TAG_template_type_param
+ || child->tag == DW_TAG_template_value_param)
+ {
+ if (dwarf2_attr (child, DW_AT_name, cu) == nullptr)
+ ++nth_unnamed;
+ }
+ }
const std::string name_str = "<unnamed" + std::to_string (nth_unnamed) + ">";
return cu->per_objfile->objfile->intern (name_str.c_str ());
@@ -18925,7 +18817,7 @@ read_signatured_type (signatured_type *sig_type,
gdb_assert (sig_type->is_debug_types);
gdb_assert (per_objfile->get_cu (sig_type) == nullptr);
- cutu_reader reader (sig_type, per_objfile, nullptr, nullptr, false,
+ cutu_reader reader (*sig_type, *per_objfile, nullptr, nullptr, false,
language_minimal);
if (!reader.is_dummy ())
@@ -19438,7 +19330,7 @@ dwarf2_per_cu::ensure_lang (dwarf2_per_objfile *per_objfile)
/* Constructing this object will set the language as a side
effect. */
- cutu_reader reader (this, per_objfile, nullptr, per_objfile->get_cu (this),
+ cutu_reader reader (*this, *per_objfile, nullptr, per_objfile->get_cu (this),
true, language_minimal, nullptr);
}
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index ba2dd07..7f56dac 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -921,19 +921,19 @@ class cutu_reader
{
public:
- cutu_reader (dwarf2_per_cu *this_cu,
- dwarf2_per_objfile *per_objfile,
+ cutu_reader (dwarf2_per_cu &this_cu,
+ dwarf2_per_objfile &per_objfile,
const struct abbrev_table *abbrev_table,
dwarf2_cu *existing_cu,
bool skip_partial,
enum language pretend_language,
const abbrev_table_cache *cache = nullptr);
- cutu_reader (dwarf2_per_cu *this_cu,
- dwarf2_per_objfile *per_objfile,
+ cutu_reader (dwarf2_per_cu &this_cu,
+ dwarf2_per_objfile &per_objfile,
enum language pretend_language,
- struct dwarf2_cu *parent_cu,
- struct dwo_file *dwo_file);
+ struct dwarf2_cu &parent_cu,
+ struct dwo_file &dwo_file);
DISABLE_COPY_AND_ASSIGN (cutu_reader);
@@ -1003,8 +1003,7 @@ private:
void read_cutu_die_from_dwo (dwarf2_cu *cu, dwo_unit *dwo_unit,
die_info *stub_comp_unit_die,
- const char *stub_comp_dir,
- abbrev_table_up *result_dwo_abbrev_table);
+ const char *stub_comp_dir);
void prepare_one_comp_unit (struct dwarf2_cu *cu,
enum language pretend_language);