/* See read.h. */
dwarf2_per_cu_data_up
-dwarf2_per_bfd::allocate_per_cu ()
+dwarf2_per_bfd::allocate_per_cu (sect_offset sect_off)
{
- dwarf2_per_cu_data_up result (new dwarf2_per_cu_data (this));
+ dwarf2_per_cu_data_up result (new dwarf2_per_cu_data (this, sect_off));
result->index = all_units.size ();
return result;
}
/* See read.h. */
signatured_type_up
-dwarf2_per_bfd::allocate_signatured_type (ULONGEST signature)
+dwarf2_per_bfd::allocate_signatured_type (sect_offset sect_off, ULONGEST signature)
{
- signatured_type_up result (new signatured_type (this, signature));
+ signatured_type_up result (new signatured_type (this, sect_off, signature));
result->index = all_units.size ();
result->is_debug_types = true;
tu_stats.nr_tus++;
int is_dwz,
sect_offset sect_off, ULONGEST length)
{
- dwarf2_per_cu_data_up the_cu = per_bfd->allocate_per_cu ();
- the_cu->sect_off = sect_off;
+ dwarf2_per_cu_data_up the_cu = per_bfd->allocate_per_cu (sect_off);
the_cu->set_length (length);
the_cu->section = section;
the_cu->is_dwz = is_dwz;
Otherwise we find one. */
static struct signatured_type *
-add_type_unit (dwarf2_per_bfd *per_bfd, ULONGEST sig, void **slot)
+add_type_unit (dwarf2_per_bfd *per_bfd, sect_offset sect_off, ULONGEST sig,
+ void **slot)
{
if (per_bfd->all_units.size () == per_bfd->all_units.capacity ())
++per_bfd->tu_stats.nr_all_type_units_reallocs;
- signatured_type_up sig_type_holder = per_bfd->allocate_signatured_type (sig);
+ signatured_type_up sig_type_holder
+ = per_bfd->allocate_signatured_type (sect_off, sig);
signatured_type *sig_type = sig_type_holder.get ();
per_bfd->all_units.emplace_back (sig_type_holder.release ());
struct signatured_type *sig_entry,
struct dwo_unit *dwo_entry)
{
- dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
-
/* Make sure we're not clobbering something we don't expect to. */
gdb_assert (! sig_entry->queued);
gdb_assert (per_objfile->get_cu (sig_entry) == NULL);
|| sig_entry->dwo_unit == dwo_entry);
sig_entry->section = dwo_entry->section;
- sig_entry->sect_off = dwo_entry->sect_off;
sig_entry->set_length (dwo_entry->length, false);
sig_entry->reading_dwo_directly = 1;
sig_entry->type_offset_in_tu = dwo_entry->type_offset_in_tu;
the TU has an entry in .gdb_index, replace the recorded data from
.gdb_index with this TU. */
- signatured_type find_sig_entry (nullptr, sig);
+ signatured_type find_sig_entry (nullptr, sect_offset {}, sig);
slot = htab_find_slot (per_bfd->signatured_types.get (), &find_sig_entry,
INSERT);
signatured_type *sig_entry = (struct signatured_type *) *slot;
/* If the global table doesn't have an entry for this TU, add one. */
if (sig_entry == NULL)
- sig_entry = add_type_unit (per_bfd, sig, slot);
+ sig_entry = add_type_unit (per_bfd, dwo_entry->sect_off, sig, slot);
if (sig_entry->dwo_unit == nullptr)
fill_in_sig_entry_from_dwo_entry (per_objfile, sig_entry, dwo_entry);
if (per_bfd->signatured_types == NULL)
per_bfd->signatured_types = allocate_signatured_type_table ();
- signatured_type find_sig_entry (nullptr, sig);
+ signatured_type find_sig_entry (nullptr, sect_offset {}, sig);
slot = htab_find_slot (per_bfd->signatured_types.get (), &find_sig_entry,
INSERT);
signatured_type *sig_entry = (struct signatured_type *) *slot;
if (dwo_entry == NULL)
return NULL;
- sig_entry = add_type_unit (per_bfd, sig, slot);
+ sig_entry = add_type_unit (per_bfd, dwo_entry->sect_off, sig, slot);
fill_in_sig_entry_from_dwo_entry (per_objfile, sig_entry, dwo_entry);
return sig_entry;
{
if (per_objfile->per_bfd->signatured_types == NULL)
return NULL;
- signatured_type find_entry (nullptr, sig);
+ signatured_type find_entry (nullptr, sect_offset {}, sig);
return ((struct signatured_type *)
htab_find (per_objfile->per_bfd->signatured_types.get (),
&find_entry));
if (per_bfd->signatured_types == NULL)
per_bfd->signatured_types = allocate_signatured_type_table ();
- signatured_type find_entry (nullptr, dwo_unit->signature);
+ signatured_type find_entry (nullptr, sect_offset {}, dwo_unit->signature);
slot = htab_find_slot (per_bfd->signatured_types.get (), &find_entry, INSERT);
/* If we've already seen this type there's nothing to do. What's happening
/* This does the job that create_all_units would have done for
this TU. */
- signatured_type *entry = add_type_unit (per_bfd, dwo_unit->signature, slot);
+ signatured_type *entry
+ = add_type_unit (per_bfd, dwo_unit->sect_off, dwo_unit->signature, slot);
fill_in_sig_entry_from_dwo_entry (per_objfile, entry, dwo_unit);
*slot = entry;
/* Save the compilation unit for later lookup. */
if (cu_header.unit_type != DW_UT_type)
- this_cu = per_objfile->per_bfd->allocate_per_cu ();
+ this_cu = per_objfile->per_bfd->allocate_per_cu (sect_off);
else
{
if (types_htab == nullptr)
types_htab = allocate_signatured_type_table ();
auto sig_type = per_objfile->per_bfd->allocate_signatured_type
- (cu_header.signature);
+ (sect_off, cu_header.signature);
signatured_type *sig_ptr = sig_type.get ();
sig_type->type_offset_in_tu = cu_header.type_cu_offset_in_tu;
this_cu.reset (sig_type.release ());
hex_string (sig_ptr->signature));
*slot = sig_ptr;
}
- this_cu->sect_off = sect_off;
+
this_cu->set_length (cu_header.get_length_with_initial ());
this_cu->is_dwz = is_dwz;
this_cu->section = section;
void **slot;
sect_offset sect_off = (sect_offset) (info_ptr - section.buffer);
- dwarf2_per_cu_data per_cu (per_bfd);
+ dwarf2_per_cu_data per_cu (per_bfd, sect_off);
per_cu.is_debug_types = 0;
- per_cu.sect_off = sect_offset (info_ptr - section.buffer);
per_cu.section = §ion;
cutu_reader reader (&per_cu, per_objfile, cu, &dwo_file);
static void
run_test ()
{
- dwarf2_per_cu_data_up one (new dwarf2_per_cu_data (nullptr));
+ const auto create_dummy_per_cu = [] ()
+ {
+ return (dwarf2_per_cu_data_up
+ (new dwarf2_per_cu_data (nullptr,sect_offset {})));
+ };
+
+ dwarf2_per_cu_data_up one = create_dummy_per_cu ();
dwarf2_per_cu_data *one_ptr = one.get ();
- dwarf2_per_cu_data_up two (new dwarf2_per_cu_data (nullptr));
+ dwarf2_per_cu_data_up two = create_dummy_per_cu ();
dwarf2_per_cu_data *two_ptr = two.get ();
- dwarf2_per_cu_data_up three (new dwarf2_per_cu_data (nullptr));
+ dwarf2_per_cu_data_up three = create_dummy_per_cu ();
dwarf2_per_cu_data *three_ptr = three.get ();
- dwarf2_per_cu_data_up four (new dwarf2_per_cu_data (nullptr));
+ dwarf2_per_cu_data_up four = create_dummy_per_cu ();
dwarf2_per_cu_data *four_ptr = four.get ();
one->set_length (5);
struct dwarf2_per_cu_data
{
- dwarf2_per_cu_data (dwarf2_per_bfd *per_bfd)
- : is_debug_types (false),
+ dwarf2_per_cu_data (dwarf2_per_bfd *per_bfd, sect_offset sect_off)
+ : sect_off (sect_off),
+ is_debug_types (false),
is_dwz (false),
reading_dwo_directly (false),
tu_read (false),
initial_length_size.
If the DIE refers to a DWO file, this is always of the original die,
not the DWO file. */
- sect_offset sect_off {};
+ sect_offset sect_off;
private:
unsigned int m_length = 0;
struct signatured_type : public dwarf2_per_cu_data
{
- signatured_type (dwarf2_per_bfd *per_bfd, ULONGEST signature)
- : dwarf2_per_cu_data (per_bfd),
+ signatured_type (dwarf2_per_bfd *per_bfd, sect_offset sect_off,
+ ULONGEST signature)
+ : dwarf2_per_cu_data (per_bfd, sect_off),
signature (signature)
{}
/* A convenience function to allocate a dwarf2_per_cu_data. The
returned object has its "index" field set properly. The object
is allocated on the dwarf2_per_bfd obstack. */
- dwarf2_per_cu_data_up allocate_per_cu ();
+ dwarf2_per_cu_data_up allocate_per_cu (sect_offset sect_off);
/* A convenience function to allocate a signatured_type. The
returned object has its "index" field set properly. The object
is allocated on the dwarf2_per_bfd obstack. */
- signatured_type_up allocate_signatured_type (ULONGEST signature);
+ signatured_type_up allocate_signatured_type (sect_offset sect_off,
+ ULONGEST signature);
/* Map all the DWARF section data needed when scanning
.debug_info. */