Skip to content

Commit 5ec4c1e

Browse files
[lldb] Make RegisterContextThreadMemory thread safe (llvm#134469)
The UpdateRegisterContext method can be called from multiple threads. (cherry picked from commit 6272e1f)
1 parent 886d8cc commit 5ec4c1e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ RegisterContextThreadMemory::RegisterContextThreadMemory(
2525
RegisterContextThreadMemory::~RegisterContextThreadMemory() = default;
2626

2727
void RegisterContextThreadMemory::UpdateRegisterContext() {
28+
std::lock_guard<std::mutex> lock(m_update_register_ctx_lock);
29+
2830
ThreadSP thread_sp(m_thread_wp.lock());
2931
if (thread_sp) {
3032
ProcessSP process_sp(thread_sp->GetProcess());

lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ class RegisterContextThreadMemory : public lldb_private::RegisterContext {
9999
RegisterContextThreadMemory(const RegisterContextThreadMemory &) = delete;
100100
const RegisterContextThreadMemory &
101101
operator=(const RegisterContextThreadMemory &) = delete;
102+
103+
std::mutex m_update_register_ctx_lock;
102104
};
103105

104106
} // namespace lldb_private

0 commit comments

Comments
 (0)