https://github.com/felipepiovezan created https://github.com/llvm/llvm-project/pull/134469
The UpdateRegisterContext method can be called from multiple threads. >From ef59ad0f6522e5ca35cfeed562fc528b4732fb22 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan <fpiove...@apple.com> Date: Fri, 4 Apr 2025 18:28:00 -0700 Subject: [PATCH] [lldb] Make `RegisterContextThreadMemory` thread safe The UpdateRegisterContext method can be called from multiple threads. --- .../Plugins/Process/Utility/RegisterContextThreadMemory.cpp | 2 ++ .../Plugins/Process/Utility/RegisterContextThreadMemory.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp index 75438550ce914..29927e3b5e4ed 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 23f675508cf38..1df32bbc1f057 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h +++ b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h @@ -99,6 +99,8 @@ class RegisterContextThreadMemory : public lldb_private::RegisterContext { RegisterContextThreadMemory(const RegisterContextThreadMemory &) = delete; const RegisterContextThreadMemory & operator=(const RegisterContextThreadMemory &) = delete; + + std::mutex m_update_register_ctx_lock; }; } // namespace lldb_private _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits