aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-12-06 08:05:28 -0700
committerTom Tromey <tromey@adacore.com>2023-02-09 07:21:52 -0700
commit307733cc0fa864fcb92f4c308a0a27d17552df37 (patch)
treeb32eac4482aed5cc43cef92f65509f7cabd258b6 /gdb/dwarf2
parentc920e5cc604c5b20f9af7c75402eea94aa1e11c6 (diff)
downloadgdb-307733cc0fa864fcb92f4c308a0a27d17552df37.zip
gdb-307733cc0fa864fcb92f4c308a0a27d17552df37.tar.gz
gdb-307733cc0fa864fcb92f4c308a0a27d17552df37.tar.bz2
Let user C-c when waiting for DWARF index finalization
In PR gdb/29854, Simon pointed out that it would be good to be able to use C-c when the DWARF cooked index is waiting for finalization. The idea here is to be able to interrupt a command like "break" -- not to stop the finalization process itself, which runs in a worker thread. This patch implements this idea, by changing the index wait functions to, by default, allow a quit. Polling is done, because there doesn't seem to be a better way to interrupt a wait on a std::future. For v2, I realized that the thread compatibility code in thread-pool.h also needed an update. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29854
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/cooked-index.c16
-rw-r--r--gdb/dwarf2/cooked-index.h11
2 files changed, 21 insertions, 6 deletions
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index f253a42..3d23a65 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -28,6 +28,7 @@
#include <algorithm>
#include "safe-ctype.h"
#include "gdbsupport/selftest.h"
+#include <chrono>
/* See cooked-index.h. */
@@ -404,6 +405,21 @@ cooked_index_shard::find (const std::string &name, bool completing) const
return range (lower, upper);
}
+/* See cooked-index.h. */
+
+void
+cooked_index_shard::wait (bool allow_quit) const
+{
+ if (allow_quit)
+ {
+ std::chrono::milliseconds duration { 15 };
+ while (m_future.wait_for (duration) == gdb::future_status::timeout)
+ QUIT;
+ }
+ else
+ m_future.wait ();
+}
+
cooked_index::cooked_index (vec_type &&vec)
: m_vector (std::move (vec))
{
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index 7a8216a..dc26956 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -259,10 +259,7 @@ public:
void finalize ();
/* Wait for this index's finalization to be complete. */
- void wait () const
- {
- m_future.wait ();
- }
+ void wait (bool allow_quit = true) const;
friend class cooked_index;
@@ -373,8 +370,10 @@ public:
end up writing to freed memory. Waiting for finalization to
complete avoids this problem; and the cost seems ignorable
because creating and immediately destroying the debug info is a
- relatively rare thing to do. */
- wait ();
+ relatively rare thing to do. Do not allow quitting from this
+ wait. */
+ for (auto &item : m_vector)
+ item->wait (false);
}
/* A range over a vector of subranges. */