};
/* Each element of dwarf2_per_bfd->type_unit_groups is a pointer to
- an object of this type. */
+ an object of this type. This contains elements of type unit groups
+ that can be shared across objfiles. The non-shareable parts are in
+ type_unit_group_unshareable. */
struct type_unit_group
{
and is deleted afterwards and not used again. */
std::vector<signatured_type *> *tus;
- /* The compunit symtab.
- Type units in a group needn't all be defined in the same source file,
- so we create an essentially anonymous symtab as the compunit symtab. */
- struct compunit_symtab *compunit_symtab;
-
/* The data used to construct the hash key. */
struct stmt_list_hash hash;
-
- /* The symbol tables for this TU (obtained from the files listed in
- DW_AT_stmt_list).
- WARNING: The order of entries here must match the order of entries
- in the line header. After the first TU using this type_unit_group, the
- line header for the subsequent TUs is recreated from this. This is done
- because we need to use the same symtabs for each TU using the same
- DW_AT_stmt_list value. Also note that symtabs may be repeated here,
- there's no guarantee the line header doesn't have duplicate entries. */
- struct symtab **symtabs;
};
/* These sections are what may appear in a (real or virtual) DWO file. */
static void age_cached_comp_units (struct dwarf2_per_objfile *dwarf2_per_objfile);
-static void free_one_cached_comp_unit (struct dwarf2_per_cu_data *);
+static void free_one_cached_comp_unit (dwarf2_per_cu_data *target_per_cu,
+ dwarf2_per_objfile *per_objfile);
static struct type *set_die_type (struct die_info *, struct type *,
struct dwarf2_cu *);
bool skip_partial,
enum language pretend_language);
-static void process_full_comp_unit (dwarf2_per_cu_data *per_cu,
- dwarf2_per_objfile *per_objfile,
+static void process_full_comp_unit (dwarf2_cu *cu,
enum language pretend_language);
-static void process_full_type_unit (dwarf2_per_cu_data *per_cu,
- dwarf2_per_objfile *per_objfile,
+static void process_full_type_unit (dwarf2_cu *cu,
enum language pretend_language);
static void dwarf2_add_dependence (struct dwarf2_cu *,
static void dwarf2_clear_marks (struct dwarf2_per_cu_data *);
static struct type *get_die_type_at_offset (sect_offset,
- struct dwarf2_per_cu_data *);
+ dwarf2_per_cu_data *per_cu,
+ dwarf2_per_objfile *per_objfile);
static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu);
-static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
+static void queue_comp_unit (dwarf2_per_cu_data *per_cu,
+ dwarf2_per_objfile *per_objfile,
enum language pretend_language);
static void process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile);
if (per_cu->queued)
{
if (per_cu->cu != NULL)
- free_one_cached_comp_unit (per_cu);
+ free_one_cached_comp_unit (per_cu, per_objfile);
per_cu->queued = 0;
}
}
static struct dwo_unit *lookup_dwo_type_unit
(dwarf2_cu *cu, const char *dwo_name, const char *comp_dir);
-static void queue_and_load_all_dwo_tus (struct dwarf2_per_cu_data *);
+static void queue_and_load_all_dwo_tus (dwarf2_cu *cu);
/* A unique pointer to a dwo_file. */
function is unrelated to symtabs, symtab would have to be created afterwards.
You should call age_cached_comp_units after processing the CU. */
-static void
+static dwarf2_cu *
load_cu (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile,
bool skip_partial)
{
else
load_full_comp_unit (per_cu, per_objfile, skip_partial, language_minimal);
- if (per_cu->cu == NULL)
- return; /* Dummy CU. */
+ if (per_cu->cu == nullptr)
+ return nullptr; /* Dummy CU. */
dwarf2_find_base_address (per_cu->cu->dies, per_cu->cu);
+
+ return per_cu->cu;
}
/* Read in the symbols for PER_CU in the context of DWARF"_PER_OBJFILE. */
if (!dwarf2_per_objfile->symtab_set_p (per_cu))
{
- queue_comp_unit (per_cu, language_minimal);
- load_cu (per_cu, dwarf2_per_objfile, skip_partial);
+ queue_comp_unit (per_cu, dwarf2_per_objfile, language_minimal);
+ dwarf2_cu *cu = load_cu (per_cu, dwarf2_per_objfile, skip_partial);
/* If we just loaded a CU from a DWO, and we're working with an index
that may badly handle TUs, load all the TUs in that DWO as well.
http://sourceware.org/bugzilla/show_bug.cgi?id=15021 */
if (!per_cu->is_debug_types
- && per_cu->cu != NULL
- && per_cu->cu->dwo_unit != NULL
+ && cu != NULL
+ && cu->dwo_unit != NULL
&& dwarf2_per_objfile->per_bfd->index_table != NULL
&& dwarf2_per_objfile->per_bfd->index_table->version <= 7
/* DWP files aren't supported yet. */
&& get_dwp_file (dwarf2_per_objfile) == NULL)
- queue_and_load_all_dwo_tus (per_cu);
+ queue_and_load_all_dwo_tus (cu);
}
process_queue (dwarf2_per_objfile);
return result;
}
-/* Return a new dwarf2_per_cu_data allocated on the dwarf2_per_objfile
+/* Return a new dwarf2_per_cu_data allocated on the per-bfd
obstack, and constructed with the specified field values. */
static dwarf2_per_cu_data *
-create_cu_from_index_list (struct dwarf2_per_objfile *dwarf2_per_objfile,
- struct dwarf2_section_info *section,
- int is_dwz,
- sect_offset sect_off, ULONGEST length)
+create_cu_from_index_list (dwarf2_per_bfd *per_bfd,
+ struct dwarf2_section_info *section,
+ int is_dwz,
+ sect_offset sect_off, ULONGEST length)
{
- dwarf2_per_cu_data *the_cu = dwarf2_per_objfile->per_bfd->allocate_per_cu ();
+ dwarf2_per_cu_data *the_cu = per_bfd->allocate_per_cu ();
the_cu->sect_off = sect_off;
the_cu->length = length;
- the_cu->dwarf2_per_objfile = dwarf2_per_objfile;
the_cu->section = section;
- the_cu->v.quick = OBSTACK_ZALLOC (&dwarf2_per_objfile->per_bfd->obstack,
+ the_cu->v.quick = OBSTACK_ZALLOC (&per_bfd->obstack,
struct dwarf2_per_cu_quick_data);
the_cu->is_dwz = is_dwz;
return the_cu;
CUs. */
static void
-create_cus_from_index_list (struct dwarf2_per_objfile *dwarf2_per_objfile,
+create_cus_from_index_list (dwarf2_per_bfd *per_bfd,
const gdb_byte *cu_list, offset_type n_elements,
struct dwarf2_section_info *section,
int is_dwz)
cu_list += 2 * 8;
dwarf2_per_cu_data *per_cu
- = create_cu_from_index_list (dwarf2_per_objfile, section, is_dwz,
- sect_off, length);
- dwarf2_per_objfile->per_bfd->all_comp_units.push_back (per_cu);
+ = create_cu_from_index_list (per_bfd, section, is_dwz, sect_off,
+ length);
+ per_bfd->all_comp_units.push_back (per_cu);
}
}
/* Read the CU list from the mapped index, and use it to create all
- the CU objects for this objfile. */
+ the CU objects for PER_BFD. */
static void
-create_cus_from_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
+create_cus_from_index (dwarf2_per_bfd *per_bfd,
const gdb_byte *cu_list, offset_type cu_list_elements,
const gdb_byte *dwz_list, offset_type dwz_elements)
{
- gdb_assert (dwarf2_per_objfile->per_bfd->all_comp_units.empty ());
- dwarf2_per_objfile->per_bfd->all_comp_units.reserve
- ((cu_list_elements + dwz_elements) / 2);
+ gdb_assert (per_bfd->all_comp_units.empty ());
+ per_bfd->all_comp_units.reserve ((cu_list_elements + dwz_elements) / 2);
- create_cus_from_index_list (dwarf2_per_objfile, cu_list, cu_list_elements,
- &dwarf2_per_objfile->per_bfd->info, 0);
+ create_cus_from_index_list (per_bfd, cu_list, cu_list_elements,
+ &per_bfd->info, 0);
if (dwz_elements == 0)
return;
- dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
- create_cus_from_index_list (dwarf2_per_objfile, dwz_list, dwz_elements,
+ dwz_file *dwz = dwarf2_get_dwz_file (per_bfd);
+ create_cus_from_index_list (per_bfd, dwz_list, dwz_elements,
&dwz->info, 1);
}
static void
create_signatured_type_table_from_index
- (struct dwarf2_per_objfile *dwarf2_per_objfile,
- struct dwarf2_section_info *section,
- const gdb_byte *bytes,
- offset_type elements)
+ (dwarf2_per_bfd *per_bfd, struct dwarf2_section_info *section,
+ const gdb_byte *bytes, offset_type elements)
{
- gdb_assert (dwarf2_per_objfile->per_bfd->all_type_units.empty ());
- dwarf2_per_objfile->per_bfd->all_type_units.reserve (elements / 3);
+ gdb_assert (per_bfd->all_type_units.empty ());
+ per_bfd->all_type_units.reserve (elements / 3);
htab_up sig_types_hash = allocate_signatured_type_table ();
signature = extract_unsigned_integer (bytes + 16, 8, BFD_ENDIAN_LITTLE);
bytes += 3 * 8;
- sig_type = dwarf2_per_objfile->per_bfd->allocate_signatured_type ();
+ sig_type = per_bfd->allocate_signatured_type ();
sig_type->signature = signature;
sig_type->type_offset_in_tu = type_offset_in_tu;
sig_type->per_cu.is_debug_types = 1;
sig_type->per_cu.section = section;
sig_type->per_cu.sect_off = sect_off;
- sig_type->per_cu.dwarf2_per_objfile = dwarf2_per_objfile;
sig_type->per_cu.v.quick
- = OBSTACK_ZALLOC (&dwarf2_per_objfile->per_bfd->obstack,
+ = OBSTACK_ZALLOC (&per_bfd->obstack,
struct dwarf2_per_cu_quick_data);
slot = htab_find_slot (sig_types_hash.get (), sig_type, INSERT);
*slot = sig_type;
- dwarf2_per_objfile->per_bfd->all_type_units.push_back (sig_type);
+ per_bfd->all_type_units.push_back (sig_type);
}
- dwarf2_per_objfile->per_bfd->signatured_types = std::move (sig_types_hash);
+ per_bfd->signatured_types = std::move (sig_types_hash);
}
/* Create the signatured type hash table from .debug_names. */
sig_type->per_cu.is_debug_types = 1;
sig_type->per_cu.section = section;
sig_type->per_cu.sect_off = sect_off;
- sig_type->per_cu.dwarf2_per_objfile = dwarf2_per_objfile;
sig_type->per_cu.v.quick
= OBSTACK_ZALLOC (&dwarf2_per_objfile->per_bfd->obstack,
struct dwarf2_per_cu_quick_data);
}
}
- create_cus_from_index (dwarf2_per_objfile, cu_list, cu_list_elements,
+ create_cus_from_index (dwarf2_per_objfile->per_bfd, cu_list, cu_list_elements,
dwz_list, dwz_list_elements);
if (types_list_elements)
dwarf2_section_info *section = &dwarf2_per_objfile->per_bfd->types[0];
- create_signatured_type_table_from_index (dwarf2_per_objfile, section,
- types_list, types_list_elements);
+ create_signatured_type_table_from_index (dwarf2_per_objfile->per_bfd,
+ section, types_list,
+ types_list_elements);
}
create_addrmap_from_index (dwarf2_per_objfile, map.get ());
list. */
static void
-create_cus_from_debug_names_list (struct dwarf2_per_objfile *dwarf2_per_objfile,
+create_cus_from_debug_names_list (dwarf2_per_bfd *per_bfd,
const mapped_debug_names &map,
dwarf2_section_info §ion,
bool is_dwz)
the next CU as end of this CU. We create the CUs here with length 0,
and in cutu_reader::cutu_reader we'll fill in the actual length. */
dwarf2_per_cu_data *per_cu
- = create_cu_from_index_list (dwarf2_per_objfile, §ion, is_dwz,
- sect_off, 0);
- dwarf2_per_objfile->per_bfd->all_comp_units.push_back (per_cu);
+ = create_cu_from_index_list (per_bfd, §ion, is_dwz, sect_off, 0);
+ per_bfd->all_comp_units.push_back (per_cu);
}
}
{
const ULONGEST length = sect_off_next - sect_off_prev;
dwarf2_per_cu_data *per_cu
- = create_cu_from_index_list (dwarf2_per_objfile, §ion, is_dwz,
+ = create_cu_from_index_list (per_bfd, §ion, is_dwz,
sect_off_prev, length);
- dwarf2_per_objfile->per_bfd->all_comp_units.push_back (per_cu);
+ per_bfd->all_comp_units.push_back (per_cu);
}
sect_off_prev = sect_off_next;
}
the CU objects for this dwarf2_per_objfile. */
static void
-create_cus_from_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
+create_cus_from_debug_names (dwarf2_per_bfd *per_bfd,
const mapped_debug_names &map,
const mapped_debug_names &dwz_map)
{
- gdb_assert (dwarf2_per_objfile->per_bfd->all_comp_units.empty ());
- dwarf2_per_objfile->per_bfd->all_comp_units.reserve (map.cu_count + dwz_map.cu_count);
+ gdb_assert (per_bfd->all_comp_units.empty ());
+ per_bfd->all_comp_units.reserve (map.cu_count + dwz_map.cu_count);
- create_cus_from_debug_names_list (dwarf2_per_objfile, map,
- dwarf2_per_objfile->per_bfd->info,
+ create_cus_from_debug_names_list (per_bfd, map, per_bfd->info,
false /* is_dwz */);
if (dwz_map.cu_count == 0)
return;
- dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
- create_cus_from_debug_names_list (dwarf2_per_objfile, dwz_map, dwz->info,
+ dwz_file *dwz = dwarf2_get_dwz_file (per_bfd);
+ create_cus_from_debug_names_list (per_bfd, dwz_map, dwz->info,
true /* is_dwz */);
}
}
}
- create_cus_from_debug_names (dwarf2_per_objfile, *map, dwz_map);
+ create_cus_from_debug_names (dwarf2_per_objfile->per_bfd, *map, dwz_map);
if (map->tu_count != 0)
{
sig_type = dwarf2_per_objfile->per_bfd->allocate_signatured_type ();
sig_type->signature = header.signature;
sig_type->type_offset_in_tu = header.type_cu_offset_in_tu;
- sig_type->per_cu.dwarf2_per_objfile = dwarf2_per_objfile;
sig_type->per_cu.is_debug_types = 1;
sig_type->per_cu.section = section;
sig_type->per_cu.sect_off = sect_off;
sig_entry->per_cu.sect_off = dwo_entry->sect_off;
sig_entry->per_cu.length = dwo_entry->length;
sig_entry->per_cu.reading_dwo_directly = 1;
- sig_entry->per_cu.dwarf2_per_objfile = dwarf2_per_objfile;
sig_entry->per_cu.per_bfd = per_bfd;
sig_entry->type_offset_in_tu = dwo_entry->type_offset_in_tu;
sig_entry->dwo_unit = dwo_entry;
tu_group = OBSTACK_ZALLOC (&dwarf2_per_objfile->per_bfd->obstack,
struct type_unit_group);
per_cu = &tu_group->per_cu;
- per_cu->dwarf2_per_objfile = dwarf2_per_objfile;
per_cu->per_bfd = per_bfd;
if (per_bfd->using_index)
read in the compilation unit (see load_partial_dies).
This problem could be avoided, but the benefit is unclear. */
if (this_cu->cu != NULL)
- free_one_cached_comp_unit (this_cu);
+ free_one_cached_comp_unit (this_cu, per_objfile);
cutu_reader reader (this_cu, per_objfile, NULL, 0, false);
this_cu->lang = this_cu->cu->language;
/* Age out any secondary CUs. */
- age_cached_comp_units (this_cu->dwarf2_per_objfile);
+ age_cached_comp_units (per_objfile);
}
/* Reader function for build_type_psymtabs. */
this_cu->sect_off = sect_off;
this_cu->length = cu_header.length + cu_header.initial_length_size;
this_cu->is_dwz = is_dwz;
- this_cu->dwarf2_per_objfile = dwarf2_per_objfile;
this_cu->section = section;
dwarf2_per_objfile->per_bfd->all_comp_units.push_back (this_cu);
/* Add PER_CU to the queue. */
static void
-queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
+queue_comp_unit (dwarf2_per_cu_data *per_cu,
+ dwarf2_per_objfile *per_objfile,
enum language pretend_language)
{
per_cu->queued = 1;
- per_cu->per_bfd->queue.emplace (per_cu, pretend_language);
+ per_cu->per_bfd->queue.emplace (per_cu, per_objfile, pretend_language);
}
/* If PER_CU is not yet queued, add it to the queue.
static int
maybe_queue_comp_unit (struct dwarf2_cu *dependent_cu,
- struct dwarf2_per_cu_data *per_cu,
+ dwarf2_per_cu_data *per_cu,
+ dwarf2_per_objfile *per_objfile,
enum language pretend_language)
{
/* We may arrive here during partial symbol reading, if we need full
}
/* Add it to the queue. */
- queue_comp_unit (per_cu, pretend_language);
+ queue_comp_unit (per_cu, per_objfile, pretend_language);
return 1;
}
fprintf_unfiltered (gdb_stdlog, "Expanding symtab of %s\n", buf);
if (per_cu->is_debug_types)
- process_full_type_unit (per_cu, dwarf2_per_objfile,
- item.pretend_language);
+ process_full_type_unit (per_cu->cu, item.pretend_language);
else
- process_full_comp_unit (per_cu, dwarf2_per_objfile,
- item.pretend_language);
+ process_full_comp_unit (per_cu->cu, item.pretend_language);
if (dwarf_read_debug >= debug_print_threshold)
fprintf_unfiltered (gdb_stdlog, "Done expanding %s\n", buf);
cu->rust_unions.clear ();
}
+/* See read.h. */
+
+type_unit_group_unshareable *
+dwarf2_per_objfile::get_type_unit_group_unshareable (type_unit_group *tu_group)
+{
+ auto iter = this->m_type_units.find (tu_group);
+ if (iter != this->m_type_units.end ())
+ return iter->second.get ();
+
+ type_unit_group_unshareable_up uniq (new type_unit_group_unshareable);
+ type_unit_group_unshareable *result = uniq.get ();
+ this->m_type_units[tu_group] = std::move (uniq);
+ return result;
+}
+
+struct type *
+dwarf2_per_objfile::get_type_for_signatured_type
+ (signatured_type *sig_type) const
+{
+ auto iter = this->m_type_map.find (sig_type);
+ if (iter == this->m_type_map.end ())
+ return nullptr;
+
+ return iter->second;
+}
+
+void dwarf2_per_objfile::set_type_for_signatured_type
+ (signatured_type *sig_type, struct type *type)
+{
+ gdb_assert (this->m_type_map.find (sig_type) == this->m_type_map.end ());
+
+ this->m_type_map[sig_type] = type;
+}
+
/* A helper function for computing the list of all symbol tables
included by PER_CU. */
/* Now we have a transitive closure of all the included symtabs. */
len = result_symtabs.size ();
cust->includes
- = XOBNEWVEC (&per_cu->dwarf2_per_objfile->objfile->objfile_obstack,
+ = XOBNEWVEC (&per_objfile->objfile->objfile_obstack,
struct compunit_symtab *, len + 1);
memcpy (cust->includes, result_symtabs.data (),
len * sizeof (compunit_symtab *));
dwarf2_per_objfile->per_bfd->just_read_cus.clear ();
}
-/* Generate full symbol information for PER_CU, whose DIEs have
+/* Generate full symbol information for CU, whose DIEs have
already been loaded into memory. */
static void
-process_full_comp_unit (dwarf2_per_cu_data *per_cu,
- dwarf2_per_objfile *dwarf2_per_objfile,
- enum language pretend_language)
+process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language)
{
- struct dwarf2_cu *cu = per_cu->cu;
+ dwarf2_per_objfile *dwarf2_per_objfile = cu->per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct gdbarch *gdbarch = objfile->arch ();
CORE_ADDR lowpc, highpc;
cust->call_site_htab = cu->call_site_htab;
}
- dwarf2_per_objfile->set_symtab (per_cu, cust);
+ dwarf2_per_objfile->set_symtab (cu->per_cu, cust);
/* Push it for inclusion processing later. */
- dwarf2_per_objfile->per_bfd->just_read_cus.push_back (per_cu);
+ dwarf2_per_objfile->per_bfd->just_read_cus.push_back (cu->per_cu);
/* Not needed any more. */
cu->reset_builder ();
}
-/* Generate full symbol information for type unit PER_CU, whose DIEs have
+/* Generate full symbol information for type unit CU, whose DIEs have
already been loaded into memory. */
static void
-process_full_type_unit (dwarf2_per_cu_data *per_cu,
- dwarf2_per_objfile *dwarf2_per_objfile,
+process_full_type_unit (dwarf2_cu *cu,
enum language pretend_language)
{
- struct dwarf2_cu *cu = per_cu->cu;
+ dwarf2_per_objfile *dwarf2_per_objfile = cu->per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct compunit_symtab *cust;
struct signatured_type *sig_type;
- gdb_assert (per_cu->is_debug_types);
- sig_type = (struct signatured_type *) per_cu;
+ gdb_assert (cu->per_cu->is_debug_types);
+ sig_type = (struct signatured_type *) cu->per_cu;
/* Clear the list here in case something was left over. */
cu->method_list.clear ();
If this is the first TU to use this symtab, complete the construction
of it with end_expandable_symtab. Otherwise, complete the addition of
this TU's symbols to the existing symtab. */
- if (sig_type->type_unit_group->compunit_symtab == NULL)
+ type_unit_group_unshareable *tug_unshare =
+ dwarf2_per_objfile->get_type_unit_group_unshareable (sig_type->type_unit_group);
+ if (tug_unshare->compunit_symtab == NULL)
{
buildsym_compunit *builder = cu->get_builder ();
cust = builder->end_expandable_symtab (0, SECT_OFF_TEXT (objfile));
- sig_type->type_unit_group->compunit_symtab = cust;
+ tug_unshare->compunit_symtab = cust;
if (cust != NULL)
{
else
{
cu->get_builder ()->augment_type_symtab ();
- cust = sig_type->type_unit_group->compunit_symtab;
+ cust = tug_unshare->compunit_symtab;
}
- dwarf2_per_objfile->set_symtab (per_cu, cust);
+ dwarf2_per_objfile->set_symtab (cu->per_cu, cust);
/* Not needed any more. */
cu->reset_builder ();
return;
/* If necessary, add it to the queue and load its DIEs. */
- if (maybe_queue_comp_unit (cu, per_cu, cu->language))
+ if (maybe_queue_comp_unit (cu, per_cu, per_objfile, cu->language))
load_full_comp_unit (per_cu, per_objfile, false, cu->language);
cu->per_cu->imported_symtabs_push (per_cu);
v = dwarf2_evaluate_loc_desc (type, NULL,
baton->data,
baton->size,
- baton->per_cu);
+ baton->per_cu,
+ baton->per_objfile);
else if (bytes != NULL)
{
v = allocate_value (type);
struct type *type;
sect_offset sect_off = attr->get_ref_die_offset ();
- type = get_die_type_at_offset (sect_off, cu->per_cu);
+ type = get_die_type_at_offset (sect_off, cu->per_cu, cu->per_objfile);
if (type != NULL && type->code () == TYPE_CODE_NAMESPACE)
{
/* This declaration is a global namespace alias. Add
do it again, we could fake it and just recreate the part we need
(file name,index -> symtab mapping). If data shows this optimization
is useful we can do it then. */
- first_time = tu_group->compunit_symtab == NULL;
+ type_unit_group_unshareable *tug_unshare
+ = per_objfile->get_type_unit_group_unshareable (tu_group);
+ first_time = tug_unshare->compunit_symtab == NULL;
/* We have to handle the case of both a missing DW_AT_stmt_list or bad
debug info. */
start_symtab ("", NULL, 0);
else
{
- gdb_assert (tu_group->symtabs == NULL);
+ gdb_assert (tug_unshare->symtabs == NULL);
gdb_assert (m_builder == nullptr);
- struct compunit_symtab *cust = tu_group->compunit_symtab;
+ struct compunit_symtab *cust = tug_unshare->compunit_symtab;
m_builder.reset (new struct buildsym_compunit
(COMPUNIT_OBJFILE (cust), "",
COMPUNIT_DIRNAME (cust),
process_full_type_unit still needs to know if this is the first
time. */
- tu_group->symtabs
+ tug_unshare->symtabs
= XOBNEWVEC (&COMPUNIT_OBJFILE (cust)->objfile_obstack,
struct symtab *, line_header->file_names_size ());
}
fe.symtab = b->get_current_subfile ()->symtab;
- tu_group->symtabs[i] = fe.symtab;
+ tug_unshare->symtabs[i] = fe.symtab;
}
}
else
{
gdb_assert (m_builder == nullptr);
- struct compunit_symtab *cust = tu_group->compunit_symtab;
+ struct compunit_symtab *cust = tug_unshare->compunit_symtab;
m_builder.reset (new struct buildsym_compunit
(COMPUNIT_OBJFILE (cust), "",
COMPUNIT_DIRNAME (cust),
for (i = 0; i < file_names.size (); ++i)
{
file_entry &fe = file_names[i];
- fe.symtab = tu_group->symtabs[i];
+ fe.symtab = tug_unshare->symtabs[i];
}
}
sect_offset sect_off = (sect_offset) (info_ptr - section.buffer);
memset (&per_cu, 0, sizeof (per_cu));
- per_cu.dwarf2_per_objfile = dwarf2_per_objfile;
per_cu.per_bfd = per_bfd;
per_cu.is_debug_types = 0;
per_cu.sect_off = sect_offset (info_ptr - section.buffer);
/* We pass NULL for DEPENDENT_CU because we don't yet know if there's
a real dependency of PER_CU on SIG_TYPE. That is detected later
while processing PER_CU. */
- if (maybe_queue_comp_unit (NULL, sig_cu, cu->language))
+ if (maybe_queue_comp_unit (NULL, sig_cu, cu->per_objfile, cu->language))
load_full_type_unit (sig_cu, cu->per_objfile);
cu->per_cu->imported_symtabs_push (sig_cu);
}
return 1;
}
-/* Queue all TUs contained in the DWO of PER_CU to be read in.
+/* Queue all TUs contained in the DWO of CU to be read in.
The DWO may have the only definition of the type, though it may not be
referenced anywhere in PER_CU. Thus we have to load *all* its TUs.
http://sourceware.org/bugzilla/show_bug.cgi?id=15021 */
static void
-queue_and_load_all_dwo_tus (struct dwarf2_per_cu_data *per_cu)
+queue_and_load_all_dwo_tus (dwarf2_cu *cu)
{
struct dwo_unit *dwo_unit;
struct dwo_file *dwo_file;
- gdb_assert (!per_cu->is_debug_types);
- gdb_assert (per_cu->cu != NULL);
- gdb_assert (get_dwp_file (per_cu->cu->per_objfile) == NULL);
+ gdb_assert (cu != nullptr);
+ gdb_assert (!cu->per_cu->is_debug_types);
+ gdb_assert (get_dwp_file (cu->per_objfile) == nullptr);
- dwo_unit = per_cu->cu->dwo_unit;
+ dwo_unit = cu->dwo_unit;
gdb_assert (dwo_unit != NULL);
dwo_file = dwo_unit->dwo_file;
if (dwo_file->tus != NULL)
- htab_traverse_noresize (dwo_file->tus.get (), queue_and_load_dwo_tu,
- per_cu->cu);
+ htab_traverse_noresize (dwo_file->tus.get (), queue_and_load_dwo_tu, cu);
}
/* Read in various DIEs. */
sect_offset_str (die->sect_off), objfile_name (objfile));
call_site->per_cu = cu->per_cu;
+ call_site->per_objfile = per_objfile;
for (child_die = die->child;
child_die && child_die->tag;
gdb_assert (m_builder == nullptr);
m_builder.reset (new struct buildsym_compunit
- (per_cu->dwarf2_per_objfile->objfile,
+ (this->per_objfile->objfile,
name, comp_dir, language, low_pc));
list_in_scope = get_builder ()->get_file_symbols ();
per_cu = dwarf2_find_containing_comp_unit (sect_off, 1,
dwarf2_per_objfile);
- this_type = get_die_type_at_offset (sect_off, per_cu);
+ this_type = get_die_type_at_offset (sect_off, per_cu, dwarf2_per_objfile);
}
else if (attr->form_is_ref ())
{
sect_offset sect_off = attr->get_ref_die_offset ();
- this_type = get_die_type_at_offset (sect_off, cu->per_cu);
+ this_type = get_die_type_at_offset (sect_off, cu->per_cu,
+ dwarf2_per_objfile);
}
else if (attr->form == DW_FORM_ref_sig8)
{
dwarf2_per_objfile);
/* If necessary, add it to the queue and load its DIEs. */
- if (maybe_queue_comp_unit (cu, per_cu, cu->language))
+ if (maybe_queue_comp_unit (cu, per_cu, dwarf2_per_objfile, cu->language))
load_full_comp_unit (per_cu, dwarf2_per_objfile, false, cu->language);
target_cu = per_cu->cu;
CORE_ADDR (*get_frame_pc) (void *baton),
void *baton, bool resolve_abstract_p)
{
- struct dwarf2_cu *cu;
struct die_info *die;
struct attribute *attr;
struct dwarf2_locexpr_baton retval;
struct objfile *objfile = dwarf2_per_objfile->objfile;
- if (per_cu->cu == NULL)
- load_cu (per_cu, dwarf2_per_objfile, false);
- cu = per_cu->cu;
- if (cu == NULL)
+ dwarf2_cu *cu = per_cu->cu;
+ if (cu == nullptr)
+ cu = load_cu (per_cu, dwarf2_per_objfile, false);
+
+ if (cu == nullptr)
{
/* We shouldn't get here for a dummy CU, but don't crash on the user.
Instead just throw an error, not much else we can do. */
obstack *obstack,
LONGEST *len)
{
- struct dwarf2_cu *cu;
struct die_info *die;
struct attribute *attr;
const gdb_byte *result = NULL;
enum bfd_endian byte_order;
struct objfile *objfile = per_objfile->objfile;
- if (per_cu->cu == NULL)
- load_cu (per_cu, per_objfile, false);
- cu = per_cu->cu;
- if (cu == NULL)
+ dwarf2_cu *cu = per_cu->cu;
+ if (cu == nullptr)
+ cu = load_cu (per_cu, per_objfile, false);
+
+ if (cu == nullptr)
{
/* We shouldn't get here for a dummy CU, but don't crash on the user.
Instead just throw an error, not much else we can do. */
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile)
{
- struct dwarf2_cu *cu;
struct die_info *die;
- if (per_cu->cu == NULL)
- load_cu (per_cu, per_objfile, false);
- cu = per_cu->cu;
- if (!cu)
- return NULL;
+ dwarf2_cu *cu = per_cu->cu;
+ if (cu == nullptr)
+ cu = load_cu (per_cu, per_objfile, false);
+
+ if (cu == nullptr)
+ return nullptr;
die = follow_die_offset (sect_off, per_cu->is_dwz, &cu);
if (!die)
struct type *
dwarf2_get_die_type (cu_offset die_offset,
- struct dwarf2_per_cu_data *per_cu)
+ dwarf2_per_cu_data *per_cu,
+ dwarf2_per_objfile *per_objfile)
{
sect_offset die_offset_sect = per_cu->sect_off + to_underlying (die_offset);
- return get_die_type_at_offset (die_offset_sect, per_cu);
+ return get_die_type_at_offset (die_offset_sect, per_cu, per_objfile);
}
/* Follow type unit SIG_TYPE referenced by SRC_DIE.
struct die_info temp_die;
struct dwarf2_cu *sig_cu, *cu = *ref_cu;
struct die_info *die;
+ dwarf2_per_objfile *dwarf2_per_objfile = (*ref_cu)->per_objfile;
+
/* While it might be nice to assert sig_type->type == NULL here,
we can get here for DW_AT_imported_declaration where we need
/* If necessary, add it to the queue and load its DIEs. */
- if (maybe_queue_comp_unit (*ref_cu, &sig_type->per_cu, language_minimal))
- read_signatured_type (sig_type, (*ref_cu)->per_objfile);
+ if (maybe_queue_comp_unit (*ref_cu, &sig_type->per_cu, dwarf2_per_objfile,
+ language_minimal))
+ read_signatured_type (sig_type, dwarf2_per_objfile);
sig_cu = sig_type->per_cu.cu;
gdb_assert (sig_cu != NULL);
to_underlying (temp_die.sect_off));
if (die)
{
- struct dwarf2_per_objfile *dwarf2_per_objfile = (*ref_cu)->per_objfile;
-
/* For .gdb_index version 7 keep track of included TUs.
http://sourceware.org/bugzilla/show_bug.cgi?id=15021. */
if (dwarf2_per_objfile->per_bfd->index_table != NULL
}
/* If we already know the type we're done. */
- if (sig_type->type != NULL)
- return sig_type->type;
+ type = dwarf2_per_objfile->get_type_for_signatured_type (sig_type);
+ if (type != nullptr)
+ return type;
type_cu = cu;
type_die = follow_die_sig_1 (die, sig_type, &type_cu);
objfile_name (dwarf2_per_objfile->objfile));
type = build_error_marker_type (cu, die);
}
- sig_type->type = type;
+
+ dwarf2_per_objfile->set_type_for_signatured_type (sig_type, type);
return type;
}
}
}
-/* See read.h. */
-
-struct objfile *
-dwarf2_per_cu_data::objfile () const
-{
- struct objfile *objfile = dwarf2_per_objfile->objfile;
-
- /* Return the master objfile, so that we can report and look up the
- correct file containing this variable. */
- if (objfile->separate_debug_objfile_backlink)
- objfile = objfile->separate_debug_objfile_backlink;
-
- return objfile;
-}
-
/* Return comp_unit_head for PER_CU, either already available in PER_CU->CU
(CU_HEADERP is unused in such case) or prepare a temporary copy at
CU_HEADERP first. */
/* Remove a single compilation unit from the cache. */
static void
-free_one_cached_comp_unit (struct dwarf2_per_cu_data *target_per_cu)
+free_one_cached_comp_unit (dwarf2_per_cu_data *target_per_cu,
+ dwarf2_per_objfile *dwarf2_per_objfile)
{
struct dwarf2_per_cu_data *per_cu, **last_chain;
- struct dwarf2_per_objfile *dwarf2_per_objfile
- = target_per_cu->dwarf2_per_objfile;
per_cu = dwarf2_per_objfile->per_bfd->read_in_chain;
last_chain = &dwarf2_per_objfile->per_bfd->read_in_chain;
static struct type *
get_die_type_at_offset (sect_offset sect_off,
- struct dwarf2_per_cu_data *per_cu)
+ dwarf2_per_cu_data *per_cu,
+ dwarf2_per_objfile *dwarf2_per_objfile)
{
struct dwarf2_per_cu_offset_and_type *slot, ofs;
- struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
if (dwarf2_per_objfile->die_type_hash == NULL)
return NULL;
static struct type *
get_die_type (struct die_info *die, struct dwarf2_cu *cu)
{
- return get_die_type_at_offset (die->sect_off, cu->per_cu);
+ return get_die_type_at_offset (die->sect_off, cu->per_cu, cu->per_objfile);
}
/* Add a dependence relationship from CU to REF_PER_CU. */