[07/15] Change how cooked index waits for threads

Message ID 20231029173839.471514-8-tom@tromey.com
State New
Headers
Series Index DWARF in the background |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Testing failed
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Testing failed

Commit Message

Tom Tromey Oct. 29, 2023, 5:35 p.m. UTC
  This changes the cooked index code to wait for threads in its
public-facing API.  That is, the waits are done in cooked_index now,
and never in the cooked_index_shard.  Centralizing this decision makes
it easier to wait for other events here as well.
---
 gdb/dwarf2/cooked-index.c | 3 +--
 gdb/dwarf2/cooked-index.h | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
  

Patch

diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 58ea541a5c9..a474691cfb4 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -405,8 +405,6 @@  cooked_index_shard::do_finalize ()
 cooked_index_shard::range
 cooked_index_shard::find (const std::string &name, bool completing) const
 {
-  wait ();
-
   cooked_index_entry::comparison_mode mode = (completing
 					      ? cooked_index_entry::COMPLETE
 					      : cooked_index_entry::MATCH);
@@ -529,6 +527,7 @@  cooked_index::get_addrmaps () const
 cooked_index::range
 cooked_index::find (const std::string &name, bool completing) const
 {
+  wait ();
   std::vector<cooked_index_shard::range> result_range;
   result_range.reserve (m_vector.size ());
   for (auto &entry : m_vector)
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index 0db6e8003b9..14352c1e139 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -287,7 +287,6 @@  class cooked_index_shard
   /* Return a range of all the entries.  */
   range all_entries () const
   {
-    wait ();
     return { m_entries.cbegin (), m_entries.cend () };
   }
 
@@ -460,6 +459,7 @@  class cooked_index : public dwarf_scanner_base
   /* Return a range of all the entries.  */
   range all_entries () const
   {
+    wait ();
     std::vector<cooked_index_shard::range> result_range;
     result_range.reserve (m_vector.size ());
     for (auto &entry : m_vector)