aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/cooked-index-worker.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/dwarf2/cooked-index-worker.h')
-rw-r--r--gdb/dwarf2/cooked-index-worker.h30
1 files changed, 24 insertions, 6 deletions
diff --git a/gdb/dwarf2/cooked-index-worker.h b/gdb/dwarf2/cooked-index-worker.h
index df5c31d..8b9766c 100644
--- a/gdb/dwarf2/cooked-index-worker.h
+++ b/gdb/dwarf2/cooked-index-worker.h
@@ -25,6 +25,8 @@
#include "dwarf2/cooked-index-shard.h"
#include "dwarf2/types.h"
#include "dwarf2/read.h"
+#include "maint.h"
+#include "run-on-main-thread.h"
#if CXX_STD_THREAD
#include <mutex>
@@ -107,11 +109,20 @@ public:
return &m_parent_map;
}
- /* Add an exception to the list of exceptions caught while reading.
- These are passed forward and printed by the main thread. */
- void note_error (gdb_exception &&except)
+ /* Catch exceptions from calling F (), and add them to the list of caught
+ exceptions. These are passed forward and printed by the main thread. */
+ template <typename F>
+ void
+ catch_error (F &&f)
{
- m_exceptions.push_back (std::move (except));
+ try
+ {
+ f ();
+ }
+ catch (gdb_exception &ex)
+ {
+ m_exceptions.push_back (std::move (ex));
+ }
}
/* Called when the thread using this object is done with its work.
@@ -207,8 +218,12 @@ public:
explicit cooked_index_worker (dwarf2_per_objfile *per_objfile)
: m_per_objfile (per_objfile),
- m_cache_store (global_index_cache, per_objfile->per_bfd)
- { }
+ m_cache_store (global_index_cache, per_objfile->per_bfd),
+ m_per_command_time (per_command_time)
+ {
+ /* Make sure we capture per_command_time from the main thread. */
+ gdb_assert (is_main_thread ());
+ }
virtual ~cooked_index_worker ()
{ }
DISABLE_COPY_AND_ASSIGN (cooked_index_worker);
@@ -298,6 +313,9 @@ protected:
std::optional<gdb_exception> m_failed;
/* An object used to write to the index cache. */
index_cache_store_context m_cache_store;
+
+ /* Captured value of per_command_time. */
+ bool m_per_command_time;
};
using cooked_index_worker_up = std::unique_ptr<cooked_index_worker>;