explicit dwarf2_queue_guard (dwarf2_per_objfile *per_objfile)
: m_per_objfile (per_objfile)
{
+ gdb_assert (!m_per_objfile->per_bfd->queue.has_value ());
+
+ m_per_objfile->per_bfd->queue.emplace ();
}
/* Free any entries remaining on the queue. There should only be
entries left if we hit an error while processing the dwarf. */
~dwarf2_queue_guard ()
{
- /* Ensure that no memory is allocated by the queue. */
- std::queue<dwarf2_queue_item> empty;
- std::swap (m_per_objfile->per_bfd->queue, empty);
+ gdb_assert (m_per_objfile->per_bfd->queue.has_value ());
+
+ m_per_objfile->per_bfd->queue.reset ();
}
DISABLE_COPY_AND_ASSIGN (dwarf2_queue_guard);
void
dwarf2_per_objfile::remove_all_cus ()
{
+ gdb_assert (!this->per_bfd->queue.has_value ());
+
for (auto pair : m_dwarf2_cus)
delete pair.second;
if (per_cu->type_unit_group_p ())
return;
- /* The destructor of dwarf2_queue_guard frees any entries left on
- the queue. After this point we're guaranteed to leave this function
- with the dwarf queue empty. */
- dwarf2_queue_guard q_guard (per_objfile);
-
- if (!per_objfile->symtab_set_p (per_cu))
- {
- queue_comp_unit (per_cu, per_objfile, language_minimal);
- dwarf2_cu *cu = load_cu (per_cu, per_objfile, skip_partial);
+ {
+ /* The destructor of dwarf2_queue_guard frees any entries left on
+ the queue. After this point we're guaranteed to leave this function
+ with the dwarf queue empty. */
+ dwarf2_queue_guard q_guard (per_objfile);
- /* 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
- && cu != NULL
- && cu->dwo_unit != NULL
- && per_objfile->per_bfd->index_table != NULL
- && per_objfile->per_bfd->index_table->version <= 7
- /* DWP files aren't supported yet. */
- && get_dwp_file (per_objfile) == NULL)
- queue_and_load_all_dwo_tus (cu);
- }
+ if (!per_objfile->symtab_set_p (per_cu))
+ {
+ queue_comp_unit (per_cu, per_objfile, language_minimal);
+ dwarf2_cu *cu = load_cu (per_cu, 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
+ && cu != NULL
+ && cu->dwo_unit != NULL
+ && per_objfile->per_bfd->index_table != NULL
+ && per_objfile->per_bfd->index_table->version <= 7
+ /* DWP files aren't supported yet. */
+ && get_dwp_file (per_objfile) == NULL)
+ queue_and_load_all_dwo_tus (cu);
+ }
- process_queue (per_objfile);
+ process_queue (per_objfile);
+ }
/* Age the cache, releasing compilation units that have not
been used recently. */
enum language pretend_language)
{
per_cu->queued = 1;
- per_cu->per_bfd->queue.emplace (per_cu, per_objfile, pretend_language);
+
+ gdb_assert (per_objfile->per_bfd->queue.has_value ());
+ per_cu->per_bfd->queue->emplace (per_cu, per_objfile, pretend_language);
}
/* If PER_CU is not yet expanded of queued for expansion, add it to the queue.
/* The queue starts out with one item, but following a DIE reference
may load a new CU, adding it to the end of the queue. */
- while (!per_objfile->per_bfd->queue.empty ())
+ while (!per_objfile->per_bfd->queue->empty ())
{
- dwarf2_queue_item &item = per_objfile->per_bfd->queue.front ();
+ dwarf2_queue_item &item = per_objfile->per_bfd->queue->front ();
dwarf2_per_cu_data *per_cu = item.per_cu;
if (!per_objfile->symtab_set_p (per_cu))
}
per_cu->queued = 0;
- per_objfile->per_bfd->queue.pop ();
+ per_objfile->per_bfd->queue->pop ();
}
dwarf_read_debug_printf ("Done expanding symtabs of %s.",
{
dwarf_read_debug_printf_v ("running");
+ /* This is not expected to be called in the middle of CU expansion. There is
+ an invariant that if a CU is in the CUs-to-expand queue, its DIEs are
+ loaded in memory. Calling age_comp_units while the queue is in use could
+ make us free the DIEs for a CU that is in the queue and therefore break
+ that invariant. */
+ gdb_assert (!this->per_bfd->queue.has_value ());
+
/* Start by clearing all marks. */
for (auto pair : m_dwarf2_cus)
pair.second->mark = false;