diff options
Diffstat (limited to 'lldb/source/Symbol/SymbolFile.cpp')
-rw-r--r-- | lldb/source/Symbol/SymbolFile.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lldb/source/Symbol/SymbolFile.cpp b/lldb/source/Symbol/SymbolFile.cpp index 6b4da9c5300..4bf7e5bacb9 100644 --- a/lldb/source/Symbol/SymbolFile.cpp +++ b/lldb/source/Symbol/SymbolFile.cpp @@ -19,12 +19,18 @@ #include "lldb/Utility/StreamString.h" #include "lldb/lldb-private.h" +#include <future> + using namespace lldb_private; void SymbolFile::PreloadSymbols() { // No-op for most implementations. } +std::recursive_mutex &SymbolFile::GetModuleMutex() const { + return GetObjectFile()->GetModule()->GetMutex(); +} + SymbolFile *SymbolFile::FindPlugin(ObjectFile *obj_file) { std::unique_ptr<SymbolFile> best_symfile_ap; if (obj_file != nullptr) { @@ -150,3 +156,17 @@ size_t SymbolFile::FindTypes(const std::vector<CompilerContext> &context, types.Clear(); return 0; } + +void SymbolFile::AssertModuleLock() { + // The code below is too expensive to leave enabled in release builds. It's + // enabled in debug builds or when the correct macro is set. +#if defined(LLDB_CONFIGURATION_DEBUG) + // We assert that we have to module lock by trying to acquire the lock from a + // different thread. Note that we must abort if the result is true to + // guarantee correctness. + assert(std::async(std::launch::async, + [this] { return this->GetModuleMutex().try_lock(); }) + .get() == false && + "Module is not locked"); +#endif +} |