sig_type->type_offset_in_section =
this_cu->sect_off + to_underlying (sig_type->type_offset_in_tu);
- this_cu->dwarf_version = cu->header.version;
+ this_cu->set_version (cu->header.version);
}
else
{
this_cu->length = cu->header.get_length ();
else
gdb_assert (this_cu->length == cu->header.get_length ());
- this_cu->dwarf_version = cu->header.version;
+ this_cu->set_version (cu->header.version);
}
}
this_cu->length = cu_header.length + cu_header.initial_length_size;
this_cu->is_dwz = is_dwz;
this_cu->section = section;
+ /* Init this asap, to avoid a data race in the set_version in
+ cutu_reader::cutu_reader (which may be run in parallel for the cooked
+ index case). */
+ this_cu->set_version (cu_header.version);
info_ptr = info_ptr + this_cu->length;
per_objfile->per_bfd->all_comp_units.push_back (std::move (this_cu));
create_cus_hash_table (per_objfile, cu, *dwo_file, dwo_file->sections.info,
dwo_file->cus);
- if (cu->per_cu->dwarf_version < 5)
+ if (cu->per_cu->version () < 5)
{
create_debug_types_hash_table (per_objfile, dwo_file.get (),
dwo_file->sections.types, dwo_file->tus);
sect_offset sect_off {};
unsigned int length = 0;
+private:
/* DWARF standard version this data has been read from (such as 4 or 5). */
- unsigned char dwarf_version = 0;
+ unsigned char m_dwarf_version = 0;
+public:
/* Flag indicating this compilation unit will be read in before
any of the current compilation units are processed. */
unsigned int queued : 1;
/* Return DWARF version number of this CU. */
short version () const
{
- return dwarf_version;
+ /* Make sure it's set already. */
+ gdb_assert (m_dwarf_version != 0);
+ return m_dwarf_version;
+ }
+
+ void set_version (short version)
+ {
+ if (m_dwarf_version == 0)
+ /* Set if not set already. */
+ m_dwarf_version = version;
+ else
+ /* If already set, verify that it's the same value. */
+ gdb_assert (m_dwarf_version == version);
}
/* Free any cached file names. */