diff options
Diffstat (limited to 'source/Target/ExecutionContext.cpp')
-rw-r--r-- | source/Target/ExecutionContext.cpp | 63 |
1 files changed, 26 insertions, 37 deletions
diff --git a/source/Target/ExecutionContext.cpp b/source/Target/ExecutionContext.cpp index ff584361c296..41f076a205e9 100644 --- a/source/Target/ExecutionContext.cpp +++ b/source/Target/ExecutionContext.cpp @@ -7,8 +7,11 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/Target/ExecutionContext.h" - #include "lldb/Core/State.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/StackFrame.h" @@ -183,18 +186,17 @@ ExecutionContext::ExecutionContext (const ExecutionContextRef *exe_ctx_ref_ptr, } } -ExecutionContext::ExecutionContext (const ExecutionContextRef *exe_ctx_ref_ptr, Mutex::Locker &locker) : - m_target_sp (), - m_process_sp (), - m_thread_sp (), - m_frame_sp () +ExecutionContext::ExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr, + std::unique_lock<std::recursive_mutex> &lock) + : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() { if (exe_ctx_ref_ptr) { - m_target_sp = exe_ctx_ref_ptr->GetTargetSP(); + m_target_sp = exe_ctx_ref_ptr->GetTargetSP(); if (m_target_sp) { - locker.Lock(m_target_sp->GetAPIMutex()); + lock = std::unique_lock<std::recursive_mutex>(m_target_sp->GetAPIMutex()); + m_process_sp = exe_ctx_ref_ptr->GetProcessSP(); m_thread_sp = exe_ctx_ref_ptr->GetThreadSP(); m_frame_sp = exe_ctx_ref_ptr->GetFrameSP(); @@ -202,18 +204,16 @@ ExecutionContext::ExecutionContext (const ExecutionContextRef *exe_ctx_ref_ptr, } } -ExecutionContext::ExecutionContext (const ExecutionContextRef &exe_ctx_ref, Mutex::Locker &locker) : - m_target_sp (exe_ctx_ref.GetTargetSP()), - m_process_sp (), - m_thread_sp (), - m_frame_sp () +ExecutionContext::ExecutionContext(const ExecutionContextRef &exe_ctx_ref, std::unique_lock<std::recursive_mutex> &lock) + : m_target_sp(exe_ctx_ref.GetTargetSP()), m_process_sp(), m_thread_sp(), m_frame_sp() { if (m_target_sp) { - locker.Lock(m_target_sp->GetAPIMutex()); + lock = std::unique_lock<std::recursive_mutex>(m_target_sp->GetAPIMutex()); + m_process_sp = exe_ctx_ref.GetProcessSP(); - m_thread_sp = exe_ctx_ref.GetThreadSP(); - m_frame_sp = exe_ctx_ref.GetFrameSP(); + m_thread_sp = exe_ctx_ref.GetThreadSP(); + m_frame_sp = exe_ctx_ref.GetFrameSP(); } } @@ -241,9 +241,7 @@ ExecutionContext::Clear() m_frame_sp.reset(); } -ExecutionContext::~ExecutionContext() -{ -} +ExecutionContext::~ExecutionContext() = default; uint32_t ExecutionContext::GetAddressByteSize() const @@ -272,7 +270,7 @@ ExecutionContext::GetRegisterContext () const return m_frame_sp->GetRegisterContext().get(); else if (m_thread_sp) return m_thread_sp->GetRegisterContext().get(); - return NULL; + return nullptr; } Target * @@ -282,7 +280,7 @@ ExecutionContext::GetTargetPtr () const return m_target_sp.get(); if (m_process_sp) return &m_process_sp->GetTarget(); - return NULL; + return nullptr; } Process * @@ -292,7 +290,7 @@ ExecutionContext::GetProcessPtr () const return m_process_sp.get(); if (m_target_sp) return m_target_sp->GetProcessSP().get(); - return NULL; + return nullptr; } ExecutionContextScope * @@ -311,7 +309,7 @@ Target & ExecutionContext::GetTargetRef () const { #if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE) - assert (m_target_sp.get()); + assert (m_target_sp); #endif return *m_target_sp; } @@ -320,7 +318,7 @@ Process & ExecutionContext::GetProcessRef () const { #if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE) - assert (m_process_sp.get()); + assert (m_process_sp); #endif return *m_process_sp; } @@ -329,7 +327,7 @@ Thread & ExecutionContext::GetThreadRef () const { #if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE) - assert (m_thread_sp.get()); + assert (m_thread_sp); #endif return *m_thread_sp; } @@ -338,7 +336,7 @@ StackFrame & ExecutionContext::GetFrameRef () const { #if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE) - assert (m_frame_sp.get()); + assert (m_frame_sp); #endif return *m_frame_sp; } @@ -572,7 +570,6 @@ ExecutionContextRef::ExecutionContextRef (const ExecutionContext &exe_ctx) : *this = exe_ctx; } - ExecutionContextRef::ExecutionContextRef (Target *target, bool adopt_selected) : m_target_wp(), m_process_wp(), @@ -583,9 +580,6 @@ ExecutionContextRef::ExecutionContextRef (Target *target, bool adopt_selected) : SetTargetPtr (target, adopt_selected); } - - - ExecutionContextRef::ExecutionContextRef (const ExecutionContextRef &rhs) : m_target_wp (rhs.m_target_wp), m_process_wp(rhs.m_process_wp), @@ -637,9 +631,7 @@ ExecutionContextRef::Clear() ClearFrame(); } -ExecutionContextRef::~ExecutionContextRef() -{ -} +ExecutionContextRef::~ExecutionContextRef() = default; void ExecutionContextRef::SetTargetSP (const lldb::TargetSP &target_sp) @@ -694,7 +686,6 @@ ExecutionContextRef::SetFrameSP (const lldb::StackFrameSP &frame_sp) m_process_wp.reset(); m_target_wp.reset(); } - } void @@ -820,7 +811,7 @@ ExecutionContextRef::GetThreadSP () const } } - // Check that we aren't about to return an invalid thread sp. We might return a NULL thread_sp, + // Check that we aren't about to return an invalid thread sp. We might return a nullptr thread_sp, // but don't return an invalid one. if (thread_sp && !thread_sp->IsValid()) @@ -846,5 +837,3 @@ ExecutionContextRef::Lock (bool thread_and_frame_only_if_stopped) const { return ExecutionContext(this, thread_and_frame_only_if_stopped); } - - |