diff options
author | Felipe de Azevedo Piovezan <fpiovezan@apple.com> | 2025-04-04 18:43:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-04 18:43:31 -0700 |
commit | 6272e1f37e0710b51d38cb98b905a3f2ffea7966 (patch) | |
tree | ea03eff1d967a8ee92ed4f7b94c38b78a07ba4c3 | |
parent | 78905ce6cbd3fa8f8b467e7cad0e9a093c1b1c44 (diff) | |
download | llvm-6272e1f37e0710b51d38cb98b905a3f2ffea7966.zip llvm-6272e1f37e0710b51d38cb98b905a3f2ffea7966.tar.gz llvm-6272e1f37e0710b51d38cb98b905a3f2ffea7966.tar.bz2 |
[lldb] Make `RegisterContextThreadMemory` thread safe (#134469)
The UpdateRegisterContext method can be called from multiple threads.
-rw-r--r-- | lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp index 7543855..29927e3 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp @@ -25,6 +25,8 @@ RegisterContextThreadMemory::RegisterContextThreadMemory( RegisterContextThreadMemory::~RegisterContextThreadMemory() = default; void RegisterContextThreadMemory::UpdateRegisterContext() { + std::lock_guard<std::mutex> lock(m_update_register_ctx_lock); + ThreadSP thread_sp(m_thread_wp.lock()); if (thread_sp) { ProcessSP process_sp(thread_sp->GetProcess()); diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h index 23f67550..1df32bb 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h +++ b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h @@ -99,6 +99,8 @@ private: RegisterContextThreadMemory(const RegisterContextThreadMemory &) = delete; const RegisterContextThreadMemory & operator=(const RegisterContextThreadMemory &) = delete; + + std::mutex m_update_register_ctx_lock; }; } // namespace lldb_private |