diff options
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r-- | gdb/dwarf2/cooked-index.c | 16 | ||||
-rw-r--r-- | gdb/dwarf2/cooked-index.h | 11 |
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. */ |