aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/read.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/dwarf2/read.c')
-rw-r--r--gdb/dwarf2/read.c162
1 files changed, 94 insertions, 68 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index b2734db..a7409b5 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1811,6 +1811,38 @@ private:
dwarf2_per_objfile *m_per_objfile;
};
+/* See read.h. */
+
+bool
+dwarf2_per_objfile::symtab_set_p (const dwarf2_per_cu_data *per_cu) const
+{
+ gdb_assert (per_cu->index < this->m_symtabs.size ());
+
+ return this->m_symtabs[per_cu->index] != nullptr;
+}
+
+/* See read.h. */
+
+compunit_symtab *
+dwarf2_per_objfile::get_symtab (const dwarf2_per_cu_data *per_cu) const
+{
+ gdb_assert (per_cu->index < this->m_symtabs.size ());
+
+ return this->m_symtabs[per_cu->index];
+}
+
+/* See read.h. */
+
+void
+dwarf2_per_objfile::set_symtab (const dwarf2_per_cu_data *per_cu,
+ compunit_symtab *symtab)
+{
+ gdb_assert (per_cu->index < this->m_symtabs.size ());
+ gdb_assert (this->m_symtabs[per_cu->index] == nullptr);
+
+ this->m_symtabs[per_cu->index] = symtab;
+}
+
/* Try to locate the sections we need for DWARF 2 debugging
information and return true if we have enough to do something.
NAMES points to the dwarf2 section names, or is NULL if the standard
@@ -2198,10 +2230,6 @@ struct dwarf2_per_cu_quick_data
NOTE: This points into dwarf2_per_objfile->per_bfd->quick_file_names_table. */
struct quick_file_names *file_names;
- /* The corresponding symbol table. This is NULL if symbols for this
- CU have not yet been read. */
- struct compunit_symtab *compunit_symtab;
-
/* A temporary mark bit used when iterating over all CUs in
expand_symtabs_matching. */
unsigned int mark : 1;
@@ -2325,9 +2353,7 @@ dw2_do_instantiate_symtab (struct dwarf2_per_cu_data *per_cu, bool skip_partial)
with the dwarf queue empty. */
dwarf2_queue_guard q_guard (dwarf2_per_objfile);
- if (dwarf2_per_objfile->per_bfd->using_index
- ? per_cu->v.quick->compunit_symtab == NULL
- : (per_cu->v.psymtab == NULL || !per_cu->v.psymtab->readin))
+ if (!dwarf2_per_objfile->symtab_set_p (per_cu))
{
queue_comp_unit (per_cu, language_minimal);
load_cu (per_cu, skip_partial);
@@ -2362,7 +2388,8 @@ dw2_instantiate_symtab (struct dwarf2_per_cu_data *per_cu, bool skip_partial)
struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
gdb_assert (dwarf2_per_objfile->per_bfd->using_index);
- if (!per_cu->v.quick->compunit_symtab)
+
+ if (!dwarf2_per_objfile->symtab_set_p (per_cu))
{
free_cached_comp_units freer (dwarf2_per_objfile);
scoped_restore decrementer = increment_reading_symtab ();
@@ -2370,7 +2397,7 @@ dw2_instantiate_symtab (struct dwarf2_per_cu_data *per_cu, bool skip_partial)
process_cu_includes (dwarf2_per_objfile);
}
- return per_cu->v.quick->compunit_symtab;
+ return dwarf2_per_objfile->get_symtab (per_cu);
}
/* See declaration. */
@@ -3274,7 +3301,8 @@ dw2_map_expand_apply (struct objfile *objfile,
struct compunit_symtab *last_made = objfile->compunit_symtabs;
/* Don't visit already-expanded CUs. */
- if (per_cu->v.quick->compunit_symtab)
+ dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+ if (per_objfile->symtab_set_p (per_cu))
return 0;
/* This may expand more than one symtab, and we want to iterate over
@@ -3302,7 +3330,7 @@ dw2_map_symtabs_matching_filename
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units)
{
/* We only need to look at symtabs not already expanded. */
- if (per_cu->v.quick->compunit_symtab)
+ if (dwarf2_per_objfile->symtab_set_p (per_cu))
continue;
quick_file_names *file_data = dw2_get_file_names (per_cu);
@@ -3444,7 +3472,7 @@ dw2_symtab_iter_next (struct dw2_symtab_iterator *iter)
dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->per_bfd->get_cutu (cu_index);
/* Skip if already read in. */
- if (per_cu->v.quick->compunit_symtab)
+ if (dwarf2_per_objfile->symtab_set_p (per_cu))
continue;
/* Check static vs global. */
@@ -3559,7 +3587,7 @@ dw2_print_stats (struct objfile *objfile)
{
dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->per_bfd->get_cutu (i);
- if (!per_cu->v.quick->compunit_symtab)
+ if (!dwarf2_per_objfile->symtab_set_p (per_cu))
++count;
}
printf_filtered (_(" Number of read CUs: %d\n"), total - count);
@@ -3642,7 +3670,7 @@ dw2_expand_symtabs_with_fullname (struct objfile *objfile,
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units)
{
/* We only need to look at symtabs not already expanded. */
- if (per_cu->v.quick->compunit_symtab)
+ if (dwarf2_per_objfile->symtab_set_p (per_cu))
continue;
quick_file_names *file_data = dw2_get_file_names (per_cu);
@@ -4503,15 +4531,14 @@ dw2_expand_symtabs_matching_one
{
if (file_matcher == NULL || per_cu->v.quick->mark)
{
- bool symtab_was_null
- = (per_cu->v.quick->compunit_symtab == NULL);
+ dwarf2_per_objfile *per_objfile = per_cu->dwarf2_per_objfile;
+ bool symtab_was_null = !per_objfile->symtab_set_p (per_cu);
- dw2_instantiate_symtab (per_cu, false);
+ compunit_symtab *symtab = dw2_instantiate_symtab (per_cu, false);
+ gdb_assert (symtab != nullptr);
- if (expansion_notify != NULL
- && symtab_was_null
- && per_cu->v.quick->compunit_symtab != NULL)
- expansion_notify (per_cu->v.quick->compunit_symtab);
+ if (expansion_notify != NULL && symtab_was_null)
+ expansion_notify (symtab);
}
}
@@ -4629,7 +4656,7 @@ dw_expand_symtabs_matching_file_matcher
per_cu->v.quick->mark = 0;
/* We only need to look at symtabs not already expanded. */
- if (per_cu->v.quick->compunit_symtab)
+ if (dwarf2_per_objfile->symtab_set_p (per_cu))
continue;
quick_file_names *file_data = dw2_get_file_names (per_cu);
@@ -4767,7 +4794,8 @@ dw2_find_pc_sect_compunit_symtab (struct objfile *objfile,
if (!data)
return NULL;
- if (warn_if_readin && data->v.quick->compunit_symtab)
+ dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+ if (warn_if_readin && per_objfile->symtab_set_p (data))
warning (_("(Internal error: pc %s in read in CU, but not in symtab.)"),
paddress (objfile->arch (), pc));
@@ -4800,7 +4828,7 @@ dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units)
{
- if (per_cu->v.quick->compunit_symtab)
+ if (dwarf2_per_objfile->symtab_set_p (per_cu))
{
void **slot = htab_find_slot (visited.get (),
per_cu->v.quick->file_names,
@@ -4813,7 +4841,7 @@ dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units)
{
/* We only need to look at symtabs not already expanded. */
- if (per_cu->v.quick->compunit_symtab)
+ if (dwarf2_per_objfile->symtab_set_p (per_cu))
continue;
quick_file_names *file_data = dw2_get_file_names (per_cu);
@@ -5484,7 +5512,7 @@ dw2_debug_names_iterator::next ()
}
/* Skip if already read in. */
- if (per_cu->v.quick->compunit_symtab)
+ if (dwarf2_per_objfile->symtab_set_p (per_cu))
goto again;
/* Check static vs global. */
@@ -5725,11 +5753,11 @@ dw2_debug_names_map_matching_symbols
the psymtab code does. */
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units)
{
- struct compunit_symtab *cust = per_cu->v.quick->compunit_symtab;
- if (cust != nullptr)
+ compunit_symtab *symtab = dwarf2_per_objfile->get_symtab (per_cu);
+ if (symtab != nullptr)
{
const struct block *block
- = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), block_kind);
+ = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (symtab), block_kind);
if (!iterate_over_symbols_terminated (block, name,
domain, callback))
break;
@@ -5879,6 +5907,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind)
dwarf2_per_objfile->per_bfd->quick_file_names_table
= create_quick_file_names_table
(dwarf2_per_objfile->per_bfd->all_comp_units.size ());
+ dwarf2_per_objfile->resize_symtabs ();
for (int i = 0; i < (dwarf2_per_objfile->per_bfd->all_comp_units.size ()
+ dwarf2_per_objfile->per_bfd->all_type_units.size ()); ++i)
@@ -5899,6 +5928,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind)
if (dwarf2_read_debug_names (dwarf2_per_objfile))
{
*index_kind = dw_index_kind::DEBUG_NAMES;
+ dwarf2_per_objfile->resize_symtabs ();
return true;
}
@@ -5907,6 +5937,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind)
get_gdb_index_contents_from_section<dwz_file>))
{
*index_kind = dw_index_kind::GDB_INDEX;
+ dwarf2_per_objfile->resize_symtabs ();
return true;
}
@@ -5917,6 +5948,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind)
{
global_index_cache.hit ();
*index_kind = dw_index_kind::GDB_INDEX;
+ dwarf2_per_objfile->resize_symtabs ();
return true;
}
@@ -5945,6 +5977,8 @@ dwarf2_build_psymtabs (struct objfile *objfile)
dwarf2_build_psymtabs_hard (dwarf2_per_objfile);
psymtabs.keep ();
+ dwarf2_per_objfile->resize_symtabs ();
+
/* (maybe) store an index in the cache. */
global_index_cache.store (dwarf2_per_objfile);
}
@@ -6375,6 +6409,8 @@ add_type_unit (struct dwarf2_per_objfile *dwarf2_per_objfile, ULONGEST sig,
signatured_type *sig_type = dwarf2_per_objfile->per_bfd->allocate_signatured_type ();
+ dwarf2_per_objfile->resize_symtabs ();
+
dwarf2_per_objfile->per_bfd->all_type_units.push_back (sig_type);
sig_type->signature = sig;
sig_type->per_cu.is_debug_types = 1;
@@ -6410,7 +6446,7 @@ fill_in_sig_entry_from_dwo_entry (struct dwarf2_per_objfile *dwarf2_per_objfile,
if (dwarf2_per_objfile->per_bfd->using_index)
{
gdb_assert (sig_entry->per_cu.v.quick != NULL);
- gdb_assert (sig_entry->per_cu.v.quick->compunit_symtab == NULL);
+ gdb_assert (!dwarf2_per_objfile->symtab_set_p (&sig_entry->per_cu));
}
else
gdb_assert (sig_entry->per_cu.v.psymtab == NULL);
@@ -8837,7 +8873,8 @@ dwarf2_psymtab::read_symtab (struct objfile *objfile)
struct dwarf2_per_objfile *dwarf2_per_objfile
= get_dwarf2_per_objfile (objfile);
- gdb_assert (!readin);
+ gdb_assert (!dwarf2_per_objfile->symtab_set_p (per_cu_data));
+
/* If this psymtab is constructed from a debug-only objfile, the
has_section_at_zero flag will not necessarily be correct. We
can get the correct value for this flag by looking at the data
@@ -8933,9 +8970,7 @@ process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
dwarf2_queue_item &item = dwarf2_per_objfile->per_bfd->queue.front ();
- if ((dwarf2_per_objfile->per_bfd->using_index
- ? !item.per_cu->v.quick->compunit_symtab
- : (item.per_cu->v.psymtab && !item.per_cu->v.psymtab->readin))
+ if (!dwarf2_per_objfile->symtab_set_p (item.per_cu)
/* Skip dummy CUs. */
&& item.per_cu->cu != NULL)
{
@@ -8990,7 +9025,7 @@ process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile)
void
dwarf2_psymtab::expand_psymtab (struct objfile *objfile)
{
- gdb_assert (!readin);
+ gdb_assert (!readin_p (objfile));
expand_dependencies (objfile);
@@ -8998,6 +9033,24 @@ dwarf2_psymtab::expand_psymtab (struct objfile *objfile)
gdb_assert (get_compunit_symtab (objfile) != nullptr);
}
+/* See psympriv.h. */
+
+bool
+dwarf2_psymtab::readin_p (struct objfile *objfile) const
+{
+ dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+ return per_objfile->symtab_set_p (per_cu_data);
+}
+
+/* See psympriv.h. */
+
+compunit_symtab *
+dwarf2_psymtab::get_compunit_symtab (struct objfile *objfile) const
+{
+ dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+ return per_objfile->get_symtab (per_cu_data);
+}
+
/* Trivial hash function for die_info: the hash value of a DIE
is its offset in .debug_info for this objfile. */
@@ -9535,17 +9588,6 @@ rust_union_quirks (struct dwarf2_cu *cu)
cu->rust_unions.clear ();
}
-/* Return the symtab for PER_CU. This works properly regardless of
- whether we're using the index or psymtabs. */
-
-static struct compunit_symtab *
-get_compunit_symtab (struct dwarf2_per_cu_data *per_cu)
-{
- return (per_cu->dwarf2_per_objfile->per_bfd->using_index
- ? per_cu->v.quick->compunit_symtab
- : per_cu->v.psymtab->compunit_symtab);
-}
-
/* A helper function for computing the list of all symbol tables
included by PER_CU. */
@@ -9555,10 +9597,7 @@ recursively_compute_inclusions (std::vector<compunit_symtab *> *result,
struct dwarf2_per_cu_data *per_cu,
struct compunit_symtab *immediate_parent)
{
- void **slot;
- struct compunit_symtab *cust;
-
- slot = htab_find_slot (all_children, per_cu, INSERT);
+ void **slot = htab_find_slot (all_children, per_cu, INSERT);
if (*slot != NULL)
{
/* This inclusion and its children have been processed. */
@@ -9566,8 +9605,9 @@ recursively_compute_inclusions (std::vector<compunit_symtab *> *result,
}
*slot = per_cu;
+
/* Only add a CU if it has a symbol table. */
- cust = get_compunit_symtab (per_cu);
+ compunit_symtab *cust = per_cu->dwarf2_per_objfile->get_symtab (per_cu);
if (cust != NULL)
{
/* If this is a type unit only add its symbol table if we haven't
@@ -9612,7 +9652,7 @@ compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu)
int len;
std::vector<compunit_symtab *> result_symtabs;
htab_t all_children, all_type_symtabs;
- struct compunit_symtab *cust = get_compunit_symtab (per_cu);
+ compunit_symtab *cust = per_cu->dwarf2_per_objfile->get_symtab (per_cu);
/* If we don't have a symtab, we can just skip this case. */
if (cust == NULL)
@@ -9749,14 +9789,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
cust->call_site_htab = cu->call_site_htab;
}
- if (dwarf2_per_objfile->per_bfd->using_index)
- per_cu->v.quick->compunit_symtab = cust;
- else
- {
- dwarf2_psymtab *pst = per_cu->v.psymtab;
- pst->compunit_symtab = cust;
- pst->readin = true;
- }
+ dwarf2_per_objfile->set_symtab (per_cu, cust);
/* Push it for inclusion processing later. */
dwarf2_per_objfile->per_bfd->just_read_cus.push_back (per_cu);
@@ -9829,14 +9862,7 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
cust = sig_type->type_unit_group->compunit_symtab;
}
- if (dwarf2_per_objfile->per_bfd->using_index)
- per_cu->v.quick->compunit_symtab = cust;
- else
- {
- dwarf2_psymtab *pst = per_cu->v.psymtab;
- pst->compunit_symtab = cust;
- pst->readin = true;
- }
+ dwarf2_per_objfile->set_symtab (per_cu, cust);
/* Not needed any more. */
cu->reset_builder ();