mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 17:18:55 +00:00
gdb/dwarf: pass section to dwarf2_per_cu_data constructor
Same as the previous patch, but for the containing section. Change-Id: I469147cce21525d61b3cf6edd9a9f4b12027c176 Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
committed by
Simon Marchi
parent
a47e2297fc
commit
c44ab627b0
@@ -1380,9 +1380,9 @@ create_signatured_type_table_from_gdb_index
|
||||
signature = extract_unsigned_integer (bytes + 16, 8, BFD_ENDIAN_LITTLE);
|
||||
bytes += 3 * 8;
|
||||
|
||||
sig_type = per_bfd->allocate_signatured_type (sect_off, signature);
|
||||
sig_type
|
||||
= per_bfd->allocate_signatured_type (section, sect_off, signature);
|
||||
sig_type->type_offset_in_tu = type_offset_in_tu;
|
||||
sig_type->section = section;
|
||||
|
||||
slot = htab_find_slot (sig_types_hash.get (), sig_type.get (), INSERT);
|
||||
*slot = sig_type.get ();
|
||||
|
||||
@@ -1816,9 +1816,11 @@ dw2_instantiate_symtab (dwarf2_per_cu_data *per_cu,
|
||||
/* See read.h. */
|
||||
|
||||
dwarf2_per_cu_data_up
|
||||
dwarf2_per_bfd::allocate_per_cu (sect_offset sect_off)
|
||||
dwarf2_per_bfd::allocate_per_cu (dwarf2_section_info *section,
|
||||
sect_offset sect_off)
|
||||
{
|
||||
dwarf2_per_cu_data_up result (new dwarf2_per_cu_data (this, sect_off));
|
||||
dwarf2_per_cu_data_up result (new dwarf2_per_cu_data (this, section,
|
||||
sect_off));
|
||||
result->index = all_units.size ();
|
||||
return result;
|
||||
}
|
||||
@@ -1826,9 +1828,12 @@ dwarf2_per_bfd::allocate_per_cu (sect_offset sect_off)
|
||||
/* See read.h. */
|
||||
|
||||
signatured_type_up
|
||||
dwarf2_per_bfd::allocate_signatured_type (sect_offset sect_off, ULONGEST signature)
|
||||
dwarf2_per_bfd::allocate_signatured_type (dwarf2_section_info *section,
|
||||
sect_offset sect_off,
|
||||
ULONGEST signature)
|
||||
{
|
||||
signatured_type_up result (new signatured_type (this, sect_off, signature));
|
||||
auto result
|
||||
= std::make_unique<signatured_type> (this, section, sect_off, signature);
|
||||
result->index = all_units.size ();
|
||||
result->is_debug_types = true;
|
||||
tu_stats.nr_tus++;
|
||||
@@ -1843,9 +1848,8 @@ create_cu_from_index_list (dwarf2_per_bfd *per_bfd,
|
||||
int is_dwz,
|
||||
sect_offset sect_off, ULONGEST length)
|
||||
{
|
||||
dwarf2_per_cu_data_up the_cu = per_bfd->allocate_per_cu (sect_off);
|
||||
dwarf2_per_cu_data_up the_cu = per_bfd->allocate_per_cu (section, sect_off);
|
||||
the_cu->set_length (length);
|
||||
the_cu->section = section;
|
||||
the_cu->is_dwz = is_dwz;
|
||||
return the_cu;
|
||||
}
|
||||
@@ -2718,14 +2722,14 @@ create_debug_types_hash_table (dwarf2_per_objfile *per_objfile,
|
||||
Otherwise we find one. */
|
||||
|
||||
static struct signatured_type *
|
||||
add_type_unit (dwarf2_per_bfd *per_bfd, sect_offset sect_off, ULONGEST sig,
|
||||
void **slot)
|
||||
add_type_unit (dwarf2_per_bfd *per_bfd, dwarf2_section_info *section,
|
||||
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 (sect_off, sig);
|
||||
= per_bfd->allocate_signatured_type (section, sect_off, sig);
|
||||
signatured_type *sig_type = sig_type_holder.get ();
|
||||
|
||||
per_bfd->all_units.emplace_back (sig_type_holder.release ());
|
||||
@@ -2759,7 +2763,6 @@ fill_in_sig_entry_from_dwo_entry (dwarf2_per_objfile *per_objfile,
|
||||
gdb_assert (sig_entry->dwo_unit == NULL
|
||||
|| sig_entry->dwo_unit == dwo_entry);
|
||||
|
||||
sig_entry->section = dwo_entry->section;
|
||||
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;
|
||||
@@ -2800,7 +2803,7 @@ lookup_dwo_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
|
||||
the TU has an entry in .gdb_index, replace the recorded data from
|
||||
.gdb_index with this TU. */
|
||||
|
||||
signatured_type find_sig_entry (nullptr, sect_offset {}, sig);
|
||||
signatured_type find_sig_entry (nullptr, 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;
|
||||
@@ -2832,7 +2835,8 @@ lookup_dwo_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
|
||||
|
||||
/* 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, dwo_entry->sect_off, sig, slot);
|
||||
sig_entry = add_type_unit (per_bfd, dwo_entry->section, 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);
|
||||
@@ -2862,7 +2866,7 @@ lookup_dwp_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
|
||||
if (per_bfd->signatured_types == NULL)
|
||||
per_bfd->signatured_types = allocate_signatured_type_table ();
|
||||
|
||||
signatured_type find_sig_entry (nullptr, sect_offset {}, sig);
|
||||
signatured_type find_sig_entry (nullptr, 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;
|
||||
@@ -2880,7 +2884,7 @@ lookup_dwp_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
|
||||
if (dwo_entry == NULL)
|
||||
return NULL;
|
||||
|
||||
sig_entry = add_type_unit (per_bfd, dwo_entry->sect_off, sig, slot);
|
||||
sig_entry = add_type_unit (per_bfd, nullptr, dwo_entry->sect_off, sig, slot);
|
||||
fill_in_sig_entry_from_dwo_entry (per_objfile, sig_entry, dwo_entry);
|
||||
|
||||
return sig_entry;
|
||||
@@ -2908,7 +2912,7 @@ lookup_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
|
||||
{
|
||||
if (per_objfile->per_bfd->signatured_types == NULL)
|
||||
return NULL;
|
||||
signatured_type find_entry (nullptr, sect_offset {}, sig);
|
||||
signatured_type find_entry (nullptr, nullptr, sect_offset {}, sig);
|
||||
return ((struct signatured_type *)
|
||||
htab_find (per_objfile->per_bfd->signatured_types.get (),
|
||||
&find_entry));
|
||||
@@ -4047,7 +4051,8 @@ process_skeletonless_type_unit (void **slot, void *info)
|
||||
if (per_bfd->signatured_types == NULL)
|
||||
per_bfd->signatured_types = allocate_signatured_type_table ();
|
||||
|
||||
signatured_type find_entry (nullptr, sect_offset {}, dwo_unit->signature);
|
||||
signatured_type find_entry (nullptr, 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
|
||||
@@ -4058,7 +4063,8 @@ process_skeletonless_type_unit (void **slot, void *info)
|
||||
/* This does the job that create_all_units would have done for
|
||||
this TU. */
|
||||
signatured_type *entry
|
||||
= add_type_unit (per_bfd, dwo_unit->sect_off, dwo_unit->signature, slot);
|
||||
= add_type_unit (per_bfd, dwo_unit->section, dwo_unit->sect_off,
|
||||
dwo_unit->signature, slot);
|
||||
fill_in_sig_entry_from_dwo_entry (per_objfile, entry, dwo_unit);
|
||||
*slot = entry;
|
||||
|
||||
@@ -4321,14 +4327,14 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile,
|
||||
|
||||
/* Save the compilation unit for later lookup. */
|
||||
if (cu_header.unit_type != DW_UT_type)
|
||||
this_cu = per_objfile->per_bfd->allocate_per_cu (sect_off);
|
||||
this_cu = per_objfile->per_bfd->allocate_per_cu (section, sect_off);
|
||||
else
|
||||
{
|
||||
if (types_htab == nullptr)
|
||||
types_htab = allocate_signatured_type_table ();
|
||||
|
||||
auto sig_type = per_objfile->per_bfd->allocate_signatured_type
|
||||
(sect_off, cu_header.signature);
|
||||
(section, 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 ());
|
||||
@@ -4346,7 +4352,6 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile,
|
||||
|
||||
this_cu->set_length (cu_header.get_length_with_initial ());
|
||||
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). */
|
||||
@@ -7143,9 +7148,8 @@ create_cus_hash_table (dwarf2_per_objfile *per_objfile,
|
||||
void **slot;
|
||||
sect_offset sect_off = (sect_offset) (info_ptr - section.buffer);
|
||||
|
||||
dwarf2_per_cu_data per_cu (per_bfd, sect_off);
|
||||
dwarf2_per_cu_data per_cu (per_bfd, §ion, sect_off);
|
||||
per_cu.is_debug_types = 0;
|
||||
per_cu.section = §ion;
|
||||
|
||||
cutu_reader reader (&per_cu, per_objfile, cu, &dwo_file);
|
||||
if (!reader.dummy_p)
|
||||
@@ -21143,7 +21147,7 @@ run_test ()
|
||||
const auto create_dummy_per_cu = [] ()
|
||||
{
|
||||
return (dwarf2_per_cu_data_up
|
||||
(new dwarf2_per_cu_data (nullptr,sect_offset {})));
|
||||
(new dwarf2_per_cu_data (nullptr, nullptr, sect_offset {})));
|
||||
};
|
||||
|
||||
dwarf2_per_cu_data_up one = create_dummy_per_cu ();
|
||||
|
||||
@@ -96,7 +96,8 @@ using dwarf2_per_cu_data_up
|
||||
|
||||
struct dwarf2_per_cu_data
|
||||
{
|
||||
dwarf2_per_cu_data (dwarf2_per_bfd *per_bfd, sect_offset sect_off)
|
||||
dwarf2_per_cu_data (dwarf2_per_bfd *per_bfd, dwarf2_section_info *section,
|
||||
sect_offset sect_off)
|
||||
: sect_off (sect_off),
|
||||
is_debug_types (false),
|
||||
is_dwz (false),
|
||||
@@ -108,6 +109,7 @@ struct dwarf2_per_cu_data
|
||||
mark (false),
|
||||
files_read (false),
|
||||
scanned (false),
|
||||
section (section),
|
||||
per_bfd (per_bfd)
|
||||
{
|
||||
}
|
||||
@@ -369,9 +371,9 @@ public:
|
||||
|
||||
struct signatured_type : public dwarf2_per_cu_data
|
||||
{
|
||||
signatured_type (dwarf2_per_bfd *per_bfd, sect_offset sect_off,
|
||||
ULONGEST signature)
|
||||
: dwarf2_per_cu_data (per_bfd, sect_off),
|
||||
signatured_type (dwarf2_per_bfd *per_bfd, dwarf2_section_info *section,
|
||||
sect_offset sect_off, ULONGEST signature)
|
||||
: dwarf2_per_cu_data (per_bfd, section, sect_off),
|
||||
signature (signature)
|
||||
{}
|
||||
|
||||
@@ -448,12 +450,14 @@ struct dwarf2_per_bfd
|
||||
/* 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 (sect_offset sect_off);
|
||||
dwarf2_per_cu_data_up allocate_per_cu (dwarf2_section_info *section,
|
||||
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 (sect_offset sect_off,
|
||||
signatured_type_up allocate_signatured_type (dwarf2_section_info *section,
|
||||
sect_offset sect_off,
|
||||
ULONGEST signature);
|
||||
|
||||
/* Map all the DWARF section data needed when scanning
|
||||
|
||||
Reference in New Issue
Block a user