From: Tom Tromey Date: Wed, 8 Jun 2022 00:55:51 +0000 (-0600) Subject: Move CU queue to dwarf2_per_objfile X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5ca5b31d6381ba6d0309e6ae0b1527a852d08a4b;p=binutils-gdb.git Move CU queue to dwarf2_per_objfile The CU queue is a member of dwarf2_per_bfd, but it is only used when expanding CUs. Also, the dwarf2_per_objfile destructor checks the queue -- however, if the per-BFD object is destroyed first, this will not work. This was pointed out Lancelot as fallout from the patch to rewrite the registry system. This patch avoids this problem by moving the queue to the per-objfile object. --- diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index d279e729db9..696277d931a 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1231,18 +1231,18 @@ public: explicit dwarf2_queue_guard (dwarf2_per_objfile *per_objfile) : m_per_objfile (per_objfile) { - gdb_assert (!m_per_objfile->per_bfd->queue.has_value ()); + gdb_assert (!m_per_objfile->queue.has_value ()); - m_per_objfile->per_bfd->queue.emplace (); + m_per_objfile->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 () { - gdb_assert (m_per_objfile->per_bfd->queue.has_value ()); + gdb_assert (m_per_objfile->queue.has_value ()); - m_per_objfile->per_bfd->queue.reset (); + m_per_objfile->queue.reset (); } DISABLE_COPY_AND_ASSIGN (dwarf2_queue_guard); @@ -1474,7 +1474,7 @@ dwarf2_per_bfd::~dwarf2_per_bfd () void dwarf2_per_objfile::remove_all_cus () { - gdb_assert (!this->per_bfd->queue.has_value ()); + gdb_assert (!queue.has_value ()); m_dwarf2_cus.clear (); } @@ -7491,8 +7491,8 @@ queue_comp_unit (dwarf2_per_cu_data *per_cu, { per_cu->queued = 1; - gdb_assert (per_objfile->per_bfd->queue.has_value ()); - per_cu->per_bfd->queue->emplace (per_cu, per_objfile, pretend_language); + gdb_assert (per_objfile->queue.has_value ()); + per_objfile->queue->emplace (per_cu, per_objfile, pretend_language); } /* If PER_CU is not yet expanded of queued for expansion, add it to the queue. @@ -7575,9 +7575,9 @@ process_queue (dwarf2_per_objfile *per_objfile) /* 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->queue->empty ()) { - dwarf2_queue_item &item = per_objfile->per_bfd->queue->front (); + dwarf2_queue_item &item = per_objfile->queue->front (); dwarf2_per_cu_data *per_cu = item.per_cu; if (!per_objfile->symtab_set_p (per_cu)) @@ -7623,7 +7623,7 @@ process_queue (dwarf2_per_objfile *per_objfile) } per_cu->queued = 0; - per_objfile->per_bfd->queue->pop (); + per_objfile->queue->pop (); } dwarf_read_debug_printf ("Done expanding symtabs of %s.", @@ -23558,7 +23558,7 @@ dwarf2_per_objfile::age_comp_units () 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 ()); + gdb_assert (!queue.has_value ()); /* Start by clearing all marks. */ for (const auto &pair : m_dwarf2_cus) diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 75dd38c0b73..51e02dfc457 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -467,9 +467,6 @@ public: gdb::hash_enum> abstract_to_concrete; - /* CUs that are queued to be read. */ - gdb::optional> queue; - /* The address map that is used by the DWARF index code. */ struct addrmap *index_addrmap = nullptr; }; @@ -578,6 +575,9 @@ struct dwarf2_per_objfile /* The CU containing the m_builder in scope. */ dwarf2_cu *sym_cu = nullptr; + /* CUs that are queued to be read. */ + gdb::optional> queue; + private: /* Hold the corresponding compunit_symtab for each CU or TU. This is indexed by dwarf2_per_cu_data::index. A NULL value means