Remove symtab links from dwarf2_psymtab and dwarf2_per_cu_quick_data

The dwarf2_psymtab and dwarf2_per_cu_quick_data types contain a pointer
to a compunit_symtab, which is a pointer to the corresponding full
symtab.  The dwarf2_psymtab and dwarf2_per_cu_quick_data objects are
going to become objfile-independent, and possibly shared by multiple
objfiles, whereas compunit_symtab will stay objfile-dependent.  This
backlink to the compunit_symtab must therefore be removed.

This patch replaces them with a vector in the dwarf2_per_objfile type,
that serves as a mapping from dwarf2_per_cu_data objects to
compunit_symtab objects, for this particular objfile.  The vector is
indexed using the index assigned to the dwarf2_per_cu_data at its
creation.

I removed the get_compunit_symtab, as it appears to bring not much value
over calling dwarf2_per_objfile::get_symtab directly.

YYYY-MM-DD  Tom Tromey  <tom@tromey.com>
YYYY-MM-DD  Simon Marchi  <simon.marchi@efficios.com>

	* dwarf2/read.h (struct dwarf2_per_bfd) <num_psymtabs>: New
	method.
	(struct dwarf2_per_objfile) <resize_symtabs, symtab_set_p,
	get_symtab, set_symtab>: New methods.
	<m_symtabs>: New field.
	(struct dwarf2_psymtab): Derive from partial_symtab.
	<readin_p, get_compunit_symtab>: Declare methods.
	* dwarf2/read.c (dwarf2_per_objfile::symtab_set_p,
	dwarf2_per_objfile::get_symtab, dwarf2_per_objfile::set_symtab):
	New methods.
	(struct dwarf2_per_cu_quick_data) <compunit_symtab>: Remove.
	(dw2_do_instantiate_symtab, dw2_instantiate_symtab)
	(dw2_map_expand_apply, dw2_map_symtabs_matching_filename)
	(dw2_symtab_iter_next, dw2_print_stats)
	(dw2_expand_symtabs_with_fullname)
	(dw2_expand_symtabs_matching_one)
	(dw_expand_symtabs_matching_file_matcher)
	(dw2_find_pc_sect_compunit_symtab, dw2_map_symbol_filenames)
	(dw2_debug_names_iterator::next)
	(dw2_debug_names_map_matching_symbols)
	(fill_in_sig_entry_from_dwo_entry, dwarf2_psymtab::read_symtab)
	(process_queue, dwarf2_psymtab::expand_psymtab): Update.
	(dwarf2_psymtab::readin_p, dwarf2_psymtab::get_compunit_symtab):
	New methods.
	(get_compunit_symtab, process_full_comp_unit)
	(process_full_type_unit): Update.
	(dwarf2_build_psymtabs, dwarf2_initialize_objfile, add_type_unit): Call
This commit is contained in:
Simon Marchi
2020-04-07 18:05:22 -04:00
committed by Simon Marchi
parent a309b520ba
commit 60684704c1
2 changed files with 129 additions and 70 deletions

View File

@@ -1811,6 +1811,38 @@ private:
dwarf2_per_objfile *m_per_objfile; 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 /* Try to locate the sections we need for DWARF 2 debugging
information and return true if we have enough to do something. information and return true if we have enough to do something.
NAMES points to the dwarf2 section names, or is NULL if the standard 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. */ NOTE: This points into dwarf2_per_objfile->per_bfd->quick_file_names_table. */
struct quick_file_names *file_names; 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 /* A temporary mark bit used when iterating over all CUs in
expand_symtabs_matching. */ expand_symtabs_matching. */
unsigned int mark : 1; 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. */ with the dwarf queue empty. */
dwarf2_queue_guard q_guard (dwarf2_per_objfile); dwarf2_queue_guard q_guard (dwarf2_per_objfile);
if (dwarf2_per_objfile->per_bfd->using_index if (!dwarf2_per_objfile->symtab_set_p (per_cu))
? per_cu->v.quick->compunit_symtab == NULL
: (per_cu->v.psymtab == NULL || !per_cu->v.psymtab->readin))
{ {
queue_comp_unit (per_cu, language_minimal); queue_comp_unit (per_cu, language_minimal);
load_cu (per_cu, skip_partial); 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; struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
gdb_assert (dwarf2_per_objfile->per_bfd->using_index); 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); free_cached_comp_units freer (dwarf2_per_objfile);
scoped_restore decrementer = increment_reading_symtab (); 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); process_cu_includes (dwarf2_per_objfile);
} }
return per_cu->v.quick->compunit_symtab; return dwarf2_per_objfile->get_symtab (per_cu);
} }
/* See declaration. */ /* See declaration. */
@@ -3274,7 +3301,8 @@ dw2_map_expand_apply (struct objfile *objfile,
struct compunit_symtab *last_made = objfile->compunit_symtabs; struct compunit_symtab *last_made = objfile->compunit_symtabs;
/* Don't visit already-expanded CUs. */ /* 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; return 0;
/* This may expand more than one symtab, and we want to iterate over /* 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) 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. */ /* 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; continue;
quick_file_names *file_data = dw2_get_file_names (per_cu); 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); dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->per_bfd->get_cutu (cu_index);
/* Skip if already read in. */ /* Skip if already read in. */
if (per_cu->v.quick->compunit_symtab) if (dwarf2_per_objfile->symtab_set_p (per_cu))
continue; continue;
/* Check static vs global. */ /* 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); 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; ++count;
} }
printf_filtered (_(" Number of read CUs: %d\n"), total - 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) 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. */ /* 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; continue;
quick_file_names *file_data = dw2_get_file_names (per_cu); quick_file_names *file_data = dw2_get_file_names (per_cu);
@@ -4467,15 +4495,14 @@ dw2_expand_symtabs_matching_one
{ {
if (file_matcher == NULL || per_cu->v.quick->mark) if (file_matcher == NULL || per_cu->v.quick->mark)
{ {
bool symtab_was_null dwarf2_per_objfile *per_objfile = per_cu->dwarf2_per_objfile;
= (per_cu->v.quick->compunit_symtab == NULL); 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 if (expansion_notify != NULL && symtab_was_null)
&& symtab_was_null expansion_notify (symtab);
&& per_cu->v.quick->compunit_symtab != NULL)
expansion_notify (per_cu->v.quick->compunit_symtab);
} }
} }
@@ -4593,7 +4620,7 @@ dw_expand_symtabs_matching_file_matcher
per_cu->v.quick->mark = 0; per_cu->v.quick->mark = 0;
/* We only need to look at symtabs not already expanded. */ /* 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; continue;
quick_file_names *file_data = dw2_get_file_names (per_cu); quick_file_names *file_data = dw2_get_file_names (per_cu);
@@ -4731,7 +4758,8 @@ dw2_find_pc_sect_compunit_symtab (struct objfile *objfile,
if (!data) if (!data)
return NULL; 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.)"), warning (_("(Internal error: pc %s in read in CU, but not in symtab.)"),
paddress (objfile->arch (), pc)); paddress (objfile->arch (), pc));
@@ -4764,7 +4792,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) 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 (), void **slot = htab_find_slot (visited.get (),
per_cu->v.quick->file_names, per_cu->v.quick->file_names,
@@ -4777,7 +4805,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) 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. */ /* 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; continue;
quick_file_names *file_data = dw2_get_file_names (per_cu); quick_file_names *file_data = dw2_get_file_names (per_cu);
@@ -5448,7 +5476,7 @@ dw2_debug_names_iterator::next ()
} }
/* Skip if already read in. */ /* Skip if already read in. */
if (per_cu->v.quick->compunit_symtab) if (dwarf2_per_objfile->symtab_set_p (per_cu))
goto again; goto again;
/* Check static vs global. */ /* Check static vs global. */
@@ -5689,11 +5717,11 @@ dw2_debug_names_map_matching_symbols
the psymtab code does. */ the psymtab code does. */
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units) 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; compunit_symtab *symtab = dwarf2_per_objfile->get_symtab (per_cu);
if (cust != nullptr) if (symtab != nullptr)
{ {
const struct block *block 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, if (!iterate_over_symbols_terminated (block, name,
domain, callback)) domain, callback))
break; break;
@@ -5843,6 +5871,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind)
dwarf2_per_objfile->per_bfd->quick_file_names_table dwarf2_per_objfile->per_bfd->quick_file_names_table
= create_quick_file_names_table = create_quick_file_names_table
(dwarf2_per_objfile->per_bfd->all_comp_units.size ()); (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 () for (int i = 0; i < (dwarf2_per_objfile->per_bfd->all_comp_units.size ()
+ dwarf2_per_objfile->per_bfd->all_type_units.size ()); ++i) + dwarf2_per_objfile->per_bfd->all_type_units.size ()); ++i)
@@ -5863,6 +5892,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind)
if (dwarf2_read_debug_names (dwarf2_per_objfile)) if (dwarf2_read_debug_names (dwarf2_per_objfile))
{ {
*index_kind = dw_index_kind::DEBUG_NAMES; *index_kind = dw_index_kind::DEBUG_NAMES;
dwarf2_per_objfile->resize_symtabs ();
return true; return true;
} }
@@ -5871,6 +5901,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind)
get_gdb_index_contents_from_section<dwz_file>)) get_gdb_index_contents_from_section<dwz_file>))
{ {
*index_kind = dw_index_kind::GDB_INDEX; *index_kind = dw_index_kind::GDB_INDEX;
dwarf2_per_objfile->resize_symtabs ();
return true; return true;
} }
@@ -5881,6 +5912,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind)
{ {
global_index_cache.hit (); global_index_cache.hit ();
*index_kind = dw_index_kind::GDB_INDEX; *index_kind = dw_index_kind::GDB_INDEX;
dwarf2_per_objfile->resize_symtabs ();
return true; return true;
} }
@@ -5909,6 +5941,8 @@ dwarf2_build_psymtabs (struct objfile *objfile)
dwarf2_build_psymtabs_hard (dwarf2_per_objfile); dwarf2_build_psymtabs_hard (dwarf2_per_objfile);
psymtabs.keep (); psymtabs.keep ();
dwarf2_per_objfile->resize_symtabs ();
/* (maybe) store an index in the cache. */ /* (maybe) store an index in the cache. */
global_index_cache.store (dwarf2_per_objfile); global_index_cache.store (dwarf2_per_objfile);
} }
@@ -6339,6 +6373,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 (); 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); dwarf2_per_objfile->per_bfd->all_type_units.push_back (sig_type);
sig_type->signature = sig; sig_type->signature = sig;
sig_type->per_cu.is_debug_types = 1; sig_type->per_cu.is_debug_types = 1;
@@ -6374,7 +6410,7 @@ fill_in_sig_entry_from_dwo_entry (struct dwarf2_per_objfile *dwarf2_per_objfile,
if (dwarf2_per_objfile->per_bfd->using_index) 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 != 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 else
gdb_assert (sig_entry->per_cu.v.psymtab == NULL); gdb_assert (sig_entry->per_cu.v.psymtab == NULL);
@@ -8801,7 +8837,8 @@ dwarf2_psymtab::read_symtab (struct objfile *objfile)
struct dwarf2_per_objfile *dwarf2_per_objfile struct dwarf2_per_objfile *dwarf2_per_objfile
= get_dwarf2_per_objfile (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 /* If this psymtab is constructed from a debug-only objfile, the
has_section_at_zero flag will not necessarily be correct. We has_section_at_zero flag will not necessarily be correct. We
can get the correct value for this flag by looking at the data can get the correct value for this flag by looking at the data
@@ -8897,9 +8934,7 @@ process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile)
{ {
dwarf2_queue_item &item = dwarf2_per_objfile->per_bfd->queue.front (); dwarf2_queue_item &item = dwarf2_per_objfile->per_bfd->queue.front ();
if ((dwarf2_per_objfile->per_bfd->using_index if (!dwarf2_per_objfile->symtab_set_p (item.per_cu)
? !item.per_cu->v.quick->compunit_symtab
: (item.per_cu->v.psymtab && !item.per_cu->v.psymtab->readin))
/* Skip dummy CUs. */ /* Skip dummy CUs. */
&& item.per_cu->cu != NULL) && item.per_cu->cu != NULL)
{ {
@@ -8954,7 +8989,7 @@ process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile)
void void
dwarf2_psymtab::expand_psymtab (struct objfile *objfile) dwarf2_psymtab::expand_psymtab (struct objfile *objfile)
{ {
gdb_assert (!readin); gdb_assert (!readin_p (objfile));
expand_dependencies (objfile); expand_dependencies (objfile);
@@ -8962,6 +8997,24 @@ dwarf2_psymtab::expand_psymtab (struct objfile *objfile)
gdb_assert (get_compunit_symtab (objfile) != nullptr); 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 /* Trivial hash function for die_info: the hash value of a DIE
is its offset in .debug_info for this objfile. */ is its offset in .debug_info for this objfile. */
@@ -9499,17 +9552,6 @@ rust_union_quirks (struct dwarf2_cu *cu)
cu->rust_unions.clear (); 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 /* A helper function for computing the list of all symbol tables
included by PER_CU. */ included by PER_CU. */
@@ -9519,10 +9561,7 @@ recursively_compute_inclusions (std::vector<compunit_symtab *> *result,
struct dwarf2_per_cu_data *per_cu, struct dwarf2_per_cu_data *per_cu,
struct compunit_symtab *immediate_parent) struct compunit_symtab *immediate_parent)
{ {
void **slot; void **slot = htab_find_slot (all_children, per_cu, INSERT);
struct compunit_symtab *cust;
slot = htab_find_slot (all_children, per_cu, INSERT);
if (*slot != NULL) if (*slot != NULL)
{ {
/* This inclusion and its children have been processed. */ /* This inclusion and its children have been processed. */
@@ -9530,8 +9569,9 @@ recursively_compute_inclusions (std::vector<compunit_symtab *> *result,
} }
*slot = per_cu; *slot = per_cu;
/* Only add a CU if it has a symbol table. */ /* 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 (cust != NULL)
{ {
/* If this is a type unit only add its symbol table if we haven't /* If this is a type unit only add its symbol table if we haven't
@@ -9576,7 +9616,7 @@ compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu)
int len; int len;
std::vector<compunit_symtab *> result_symtabs; std::vector<compunit_symtab *> result_symtabs;
htab_t all_children, all_type_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 we don't have a symtab, we can just skip this case. */
if (cust == NULL) if (cust == NULL)
@@ -9713,14 +9753,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
cust->call_site_htab = cu->call_site_htab; cust->call_site_htab = cu->call_site_htab;
} }
if (dwarf2_per_objfile->per_bfd->using_index) dwarf2_per_objfile->set_symtab (per_cu, cust);
per_cu->v.quick->compunit_symtab = cust;
else
{
dwarf2_psymtab *pst = per_cu->v.psymtab;
pst->compunit_symtab = cust;
pst->readin = true;
}
/* Push it for inclusion processing later. */ /* 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 (per_cu);
@@ -9793,14 +9826,7 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
cust = sig_type->type_unit_group->compunit_symtab; cust = sig_type->type_unit_group->compunit_symtab;
} }
if (dwarf2_per_objfile->per_bfd->using_index) dwarf2_per_objfile->set_symtab (per_cu, cust);
per_cu->v.quick->compunit_symtab = cust;
else
{
dwarf2_psymtab *pst = per_cu->v.psymtab;
pst->compunit_symtab = cust;
pst->readin = true;
}
/* Not needed any more. */ /* Not needed any more. */
cu->reset_builder (); cu->reset_builder ();

View File

@@ -123,6 +123,11 @@ struct dwarf2_per_bfd
is allocated on the dwarf2_per_bfd obstack. */ is allocated on the dwarf2_per_bfd obstack. */
signatured_type *allocate_signatured_type (); 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: private:
/* This function is mapped across the sections and remembers the /* This function is mapped across the sections and remembers the
offset and size of each of the debugging sections we are offset and size of each of the debugging sections we are
@@ -278,12 +283,38 @@ struct dwarf2_per_objfile
const struct comp_unit_head *cu_header, const struct comp_unit_head *cu_header,
unsigned int *bytes_read_ptr); 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. */ /* Back link. */
struct objfile *objfile; struct objfile *objfile;
/* Pointer to the data that is (possibly) shared between this objfile and /* Pointer to the data that is (possibly) shared between this objfile and
other objfiles backed by the same BFD. */ other objfiles backed by the same BFD. */
struct dwarf2_per_bfd *per_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. */ /* Get the dwarf2_per_objfile associated to OBJFILE. */
@@ -291,17 +322,19 @@ struct dwarf2_per_objfile
dwarf2_per_objfile *get_dwarf2_per_objfile (struct objfile *objfile); dwarf2_per_objfile *get_dwarf2_per_objfile (struct objfile *objfile);
/* A partial symtab specialized for DWARF. */ /* 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_psymtab (const char *filename, struct objfile *objfile,
dwarf2_per_cu_data *per_cu) dwarf2_per_cu_data *per_cu)
: standard_psymtab (filename, objfile, 0), : partial_symtab (filename, objfile, 0),
per_cu_data (per_cu) per_cu_data (per_cu)
{ {
} }
void read_symtab (struct objfile *) override; void read_symtab (struct objfile *) override;
void expand_psymtab (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; struct dwarf2_per_cu_data *per_cu_data;
}; };