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
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;
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);
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 ();
process_cu_includes (dwarf2_per_objfile);
}
- return per_cu->v.quick->compunit_symtab;
+ return dwarf2_per_objfile->get_symtab (per_cu);
}
/* See declaration. */
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
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);
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. */
{
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);
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);
{
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);
}
}
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);
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));
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,
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);
}
/* 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. */
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;
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)
if (dwarf2_read_debug_names (dwarf2_per_objfile))
{
*index_kind = dw_index_kind::DEBUG_NAMES;
+ dwarf2_per_objfile->resize_symtabs ();
return true;
}
get_gdb_index_contents_from_section<dwz_file>))
{
*index_kind = dw_index_kind::GDB_INDEX;
+ dwarf2_per_objfile->resize_symtabs ();
return true;
}
{
global_index_cache.hit ();
*index_kind = dw_index_kind::GDB_INDEX;
+ dwarf2_per_objfile->resize_symtabs ();
return true;
}
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);
}
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;
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);
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
{
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)
{
void
dwarf2_psymtab::expand_psymtab (struct objfile *objfile)
{
- gdb_assert (!readin);
+ gdb_assert (!readin_p (objfile));
expand_dependencies (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. */
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. */
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. */
}
*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
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)
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);
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 ();
is allocated on the dwarf2_per_bfd obstack. */
signatured_type *allocate_signatured_type ();
+ /* Return the number of partial symtabs allocated with allocate_per_cu
+ and allocate_signatured_type so far. */
+ int num_psymtabs () const
+ { return m_num_psymtabs; }
+
private:
/* This function is mapped across the sections and remembers the
offset and size of each of the debugging sections we are
const struct comp_unit_head *cu_header,
unsigned int *bytes_read_ptr);
+ /* Resize the M_SYMTABS vector to the needed size (the number of partial
+ symtabs allocated by the per-bfd). */
+ void resize_symtabs ()
+ {
+ /* The symtabs vector should only grow, not shrink. */
+ gdb_assert (per_bfd->num_psymtabs () >= m_symtabs.size ());
+
+ m_symtabs.resize (per_bfd->num_psymtabs ());
+ }
+
+ /* Return true if the symtab corresponding to PER_CU has been set,
+ false otherwise. */
+ bool symtab_set_p (const dwarf2_per_cu_data *per_cu) const;
+
+ /* Return the compunit_symtab associated to PER_CU, if it has been created. */
+ compunit_symtab *get_symtab (const dwarf2_per_cu_data *per_cu) const;
+
+ /* Set the compunit_symtab associated to PER_CU. */
+ void set_symtab (const dwarf2_per_cu_data *per_cu, compunit_symtab *symtab);
+
/* Back link. */
struct objfile *objfile;
/* Pointer to the data that is (possibly) shared between this objfile and
other objfiles backed by the same BFD. */
struct dwarf2_per_bfd *per_bfd;
+
+private:
+ /* Hold the corresponding compunit_symtab for each CU or TU. This
+ is indexed by dwarf2_per_cu_data::index. A NULL value means
+ that the CU/TU has not been expanded yet. */
+ std::vector<compunit_symtab *> m_symtabs;
};
/* Get the dwarf2_per_objfile associated to OBJFILE. */
dwarf2_per_objfile *get_dwarf2_per_objfile (struct objfile *objfile);
/* A partial symtab specialized for DWARF. */
-struct dwarf2_psymtab : public standard_psymtab
+struct dwarf2_psymtab : public partial_symtab
{
dwarf2_psymtab (const char *filename, struct objfile *objfile,
dwarf2_per_cu_data *per_cu)
- : standard_psymtab (filename, objfile, 0),
+ : partial_symtab (filename, objfile, 0),
per_cu_data (per_cu)
{
}
void read_symtab (struct objfile *) override;
void expand_psymtab (struct objfile *) override;
+ bool readin_p (struct objfile *) const override;
+ compunit_symtab *get_compunit_symtab (struct objfile *) const override;
struct dwarf2_per_cu_data *per_cu_data;
};