public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Remove cooked_index_worker::start_reading
@ 2024-01-18 20:37 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2024-01-18 20:37 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=36cde74bd8ba912604dd675bc5046c20fb8c5d68

commit 36cde74bd8ba912604dd675bc5046c20fb8c5d68
Author: Tom Tromey <tom@tromey.com>
Date:   Sun Dec 3 12:40:06 2023 -0700

    Remove cooked_index_worker::start_reading
    
    I noticed that cooked_index_worker::start_reading isn't really needed.
    This patch removes it, and also removes the SCOPED_EXIT, in favor of a
    direct call.

Diff:
---
 gdb/dwarf2/cooked-index.c | 32 ++++++++++++--------------------
 gdb/dwarf2/cooked-index.h | 15 +++++----------
 2 files changed, 17 insertions(+), 30 deletions(-)

diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 97a749f97e8..d5a21ee9dec 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -449,26 +449,18 @@ cooked_index_worker::start ()
 {
   gdb::thread_pool::g_thread_pool->post_task ([=] ()
   {
-    this->start_reading ();
-  });
-}
-
-/* See cooked-index.h.  */
-
-void
-cooked_index_worker::start_reading ()
-{
-  SCOPE_EXIT { bfd_thread_cleanup (); };
+    try
+      {
+	do_reading ();
+      }
+    catch (const gdb_exception &exc)
+      {
+	m_failed = exc;
+	set (cooked_state::CACHE_DONE);
+      }
 
-  try
-    {
-      do_reading ();
-    }
-  catch (const gdb_exception &exc)
-    {
-      m_failed = exc;
-      set (cooked_state::CACHE_DONE);
-    }
+    bfd_thread_cleanup ();
+  });
 }
 
 /* See cooked-index.h.  */
@@ -520,7 +512,7 @@ cooked_index_worker::wait (cooked_state desired_state, bool allow_quit)
 
   if (m_failed.has_value ())
     {
-      /* start_reading failed -- report it.  */
+      /* do_reading failed -- report it.  */
       exception_print (gdb_stderr, *m_failed);
       m_failed.reset ();
       return done;
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index f063fe088e8..86fbb8ffac4 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -534,13 +534,8 @@ protected:
   friend class cooked_index;
   void set (cooked_state desired_state);
 
-  /* Start reading DWARF.  This can be run in a worker thread without
-     problems.  */
-  void start_reading ();
-
-  /* Helper function that does most of the work for start_reading.
-     This must be able to be run in a worker thread without
-     problems.  */
+  /* Helper function that does the work of reading.  This must be able
+     to be run in a worker thread without problems.  */
   virtual void do_reading () = 0;
 
   /* A callback that can print stats, if needed.  This is called when
@@ -579,9 +574,9 @@ protected:
      arose during scanning have been reported by 'wait'.  This may
      only be modified on the main thread.  */
   bool m_reported = false;
-  /* If set, an exception occurred during start_reading; in this case
-     the scanning is stopped and this exception will later be reported
-     by the 'wait' method.  */
+  /* If set, an exception occurred during reading; in this case the
+     scanning is stopped and this exception will later be reported by
+     the 'wait' method.  */
   std::optional<gdb_exception> m_failed;
 };

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-18 20:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-18 20:37 [binutils-gdb] Remove cooked_index_worker::start_reading Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).