diff options
Diffstat (limited to 'lldb/source/API')
-rw-r--r-- | lldb/source/API/SBAddress.cpp | 3 | ||||
-rw-r--r-- | lldb/source/API/SBBreakpoint.cpp | 66 | ||||
-rw-r--r-- | lldb/source/API/SBBreakpointLocation.cpp | 42 | ||||
-rw-r--r-- | lldb/source/API/SBCommandInterpreter.cpp | 10 | ||||
-rw-r--r-- | lldb/source/API/SBDebugger.cpp | 8 | ||||
-rw-r--r-- | lldb/source/API/SBFrame.cpp | 94 | ||||
-rw-r--r-- | lldb/source/API/SBFunction.cpp | 4 | ||||
-rw-r--r-- | lldb/source/API/SBInstruction.cpp | 15 | ||||
-rw-r--r-- | lldb/source/API/SBProcess.cpp | 68 | ||||
-rw-r--r-- | lldb/source/API/SBSymbol.cpp | 5 | ||||
-rw-r--r-- | lldb/source/API/SBTarget.cpp | 80 | ||||
-rw-r--r-- | lldb/source/API/SBThread.cpp | 109 | ||||
-rw-r--r-- | lldb/source/API/SBValue.cpp | 17 | ||||
-rw-r--r-- | lldb/source/API/SBWatchpoint.cpp | 22 |
14 files changed, 270 insertions, 273 deletions
diff --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp index f95fcb8b398..470ea5659f2 100644 --- a/lldb/source/API/SBAddress.cpp +++ b/lldb/source/API/SBAddress.cpp @@ -15,7 +15,6 @@ #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamString.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Target/Target.h" @@ -125,7 +124,7 @@ SBAddress::GetLoadAddress (const SBTarget &target) const { if (m_opaque_ap->IsValid()) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); addr = m_opaque_ap->GetLoadAddress (target_sp.get()); } } diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp index 1f58ddb7152..ec3a3de4a78 100644 --- a/lldb/source/API/SBBreakpoint.cpp +++ b/lldb/source/API/SBBreakpoint.cpp @@ -149,7 +149,7 @@ SBBreakpoint::ClearAllBreakpointSites () { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->ClearAllBreakpointSites (); } } @@ -163,7 +163,7 @@ SBBreakpoint::FindLocationByAddress (addr_t vm_addr) { if (vm_addr != LLDB_INVALID_ADDRESS) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); Address address; Target &target = m_opaque_sp->GetTarget(); if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) @@ -183,7 +183,7 @@ SBBreakpoint::FindLocationIDByAddress (addr_t vm_addr) if (m_opaque_sp && vm_addr != LLDB_INVALID_ADDRESS) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); Address address; Target &target = m_opaque_sp->GetTarget(); if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) @@ -203,7 +203,7 @@ SBBreakpoint::FindLocationByID (break_id_t bp_loc_id) if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); sb_bp_location.SetLocation (m_opaque_sp->FindLocationByID (bp_loc_id)); } @@ -217,7 +217,7 @@ SBBreakpoint::GetLocationAtIndex (uint32_t index) if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); sb_bp_location.SetLocation (m_opaque_sp->GetLocationAtIndex (index)); } @@ -235,7 +235,7 @@ SBBreakpoint::SetEnabled (bool enable) if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetEnabled (enable); } } @@ -245,7 +245,7 @@ SBBreakpoint::IsEnabled () { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->IsEnabled(); } else @@ -263,7 +263,7 @@ SBBreakpoint::SetOneShot (bool one_shot) if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetOneShot (one_shot); } } @@ -273,7 +273,7 @@ SBBreakpoint::IsOneShot () const { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->IsOneShot(); } else @@ -285,7 +285,7 @@ SBBreakpoint::IsInternal () { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->IsInternal(); } else @@ -303,7 +303,7 @@ SBBreakpoint::SetIgnoreCount (uint32_t count) if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetIgnoreCount (count); } } @@ -313,7 +313,7 @@ SBBreakpoint::SetCondition (const char *condition) { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetCondition (condition); } } @@ -323,7 +323,7 @@ SBBreakpoint::GetCondition () { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetConditionText (); } return nullptr; @@ -335,7 +335,7 @@ SBBreakpoint::GetHitCount () const uint32_t count = 0; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); count = m_opaque_sp->GetHitCount(); } @@ -353,7 +353,7 @@ SBBreakpoint::GetIgnoreCount () const uint32_t count = 0; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); count = m_opaque_sp->GetIgnoreCount(); } @@ -370,7 +370,7 @@ SBBreakpoint::SetThreadID (tid_t tid) { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetThreadID (tid); } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -385,7 +385,7 @@ SBBreakpoint::GetThreadID () tid_t tid = LLDB_INVALID_THREAD_ID; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); tid = m_opaque_sp->GetThreadID(); } @@ -405,7 +405,7 @@ SBBreakpoint::SetThreadIndex (uint32_t index) static_cast<void*>(m_opaque_sp.get()), index); if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex (index); } } @@ -416,7 +416,7 @@ SBBreakpoint::GetThreadIndex() const uint32_t thread_idx = UINT32_MAX; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); if (thread_spec != nullptr) thread_idx = thread_spec->GetIndex(); @@ -439,7 +439,7 @@ SBBreakpoint::SetThreadName (const char *thread_name) if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->GetOptions()->GetThreadSpec()->SetName (thread_name); } } @@ -450,7 +450,7 @@ SBBreakpoint::GetThreadName () const const char *name = nullptr; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); if (thread_spec != nullptr) name = thread_spec->GetName(); @@ -472,7 +472,7 @@ SBBreakpoint::SetQueueName (const char *queue_name) static_cast<void*>(m_opaque_sp.get()), queue_name); if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName (queue_name); } } @@ -483,7 +483,7 @@ SBBreakpoint::GetQueueName () const const char *name = nullptr; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); if (thread_spec) name = thread_spec->GetQueueName(); @@ -502,7 +502,7 @@ SBBreakpoint::GetNumResolvedLocations() const size_t num_resolved = 0; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); num_resolved = m_opaque_sp->GetNumResolvedLocations(); } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -519,7 +519,7 @@ SBBreakpoint::GetNumLocations() const size_t num_locs = 0; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); num_locs = m_opaque_sp->GetNumLocations(); } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -535,7 +535,7 @@ SBBreakpoint::GetDescription (SBStream &s) { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID()); m_opaque_sp->GetResolverDescription (s.get()); m_opaque_sp->GetFilterDescription (s.get()); @@ -598,7 +598,7 @@ SBBreakpoint::SetCallback (BreakpointHitCallback callback, void *baton) if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); BatonSP baton_sp(new SBBreakpointCallbackBaton (callback, baton)); m_opaque_sp->SetCallback (SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, false); } @@ -616,7 +616,7 @@ SBBreakpoint::SetScriptCallbackFunction (const char *callback_function_name) if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); BreakpointOptions *bp_options = m_opaque_sp->GetOptions(); m_opaque_sp->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallbackFunction (bp_options, callback_function_name); @@ -635,7 +635,7 @@ SBBreakpoint::SetScriptCallbackBody (const char *callback_body_text) SBError sb_error; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); BreakpointOptions *bp_options = m_opaque_sp->GetOptions(); Error error = m_opaque_sp->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options, callback_body_text); @@ -659,7 +659,7 @@ SBBreakpoint::AddName (const char *new_name) if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); Error error; // Think I'm just going to swallow the error here, it's probably more annoying to have to provide it. return m_opaque_sp->AddName(new_name, error); } @@ -679,7 +679,7 @@ SBBreakpoint::RemoveName (const char *name_to_remove) if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->RemoveName(name_to_remove); } } @@ -696,7 +696,7 @@ SBBreakpoint::MatchesName (const char *name) if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->MatchesName(name); } @@ -714,7 +714,7 @@ SBBreakpoint::GetNames (SBStringList &names) if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); std::vector<std::string> names_vec; m_opaque_sp->GetNames(names_vec); for (std::string name : names_vec) diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp index 4390e9ad737..631a32bc9dd 100644 --- a/lldb/source/API/SBBreakpointLocation.cpp +++ b/lldb/source/API/SBBreakpointLocation.cpp @@ -92,7 +92,7 @@ SBBreakpointLocation::GetLoadAddress () if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); ret_addr = m_opaque_sp->GetLoadAddress(); } @@ -104,7 +104,7 @@ SBBreakpointLocation::SetEnabled (bool enabled) { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetEnabled (enabled); } } @@ -114,7 +114,7 @@ SBBreakpointLocation::IsEnabled () { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->IsEnabled(); } else @@ -126,7 +126,7 @@ SBBreakpointLocation::GetIgnoreCount () { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetIgnoreCount(); } else @@ -138,7 +138,7 @@ SBBreakpointLocation::SetIgnoreCount (uint32_t n) { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetIgnoreCount (n); } } @@ -148,7 +148,7 @@ SBBreakpointLocation::SetCondition (const char *condition) { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetCondition (condition); } } @@ -158,7 +158,7 @@ SBBreakpointLocation::GetCondition () { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetConditionText (); } return NULL; @@ -176,7 +176,7 @@ SBBreakpointLocation::SetScriptCallbackFunction (const char *callback_function_n if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); BreakpointOptions *bp_options = m_opaque_sp->GetLocationOptions(); m_opaque_sp->GetBreakpoint().GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallbackFunction (bp_options, callback_function_name); @@ -195,7 +195,7 @@ SBBreakpointLocation::SetScriptCallbackBody (const char *callback_body_text) SBError sb_error; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); BreakpointOptions *bp_options = m_opaque_sp->GetLocationOptions(); Error error = m_opaque_sp->GetBreakpoint().GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options, callback_body_text); @@ -212,7 +212,7 @@ SBBreakpointLocation::SetThreadID (tid_t thread_id) { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetThreadID (thread_id); } } @@ -223,7 +223,7 @@ SBBreakpointLocation::GetThreadID () tid_t tid = LLDB_INVALID_THREAD_ID; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetThreadID(); } return tid; @@ -234,7 +234,7 @@ SBBreakpointLocation::SetThreadIndex (uint32_t index) { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetThreadIndex (index); } } @@ -245,7 +245,7 @@ SBBreakpointLocation::GetThreadIndex() const uint32_t thread_idx = UINT32_MAX; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetThreadIndex(); } return thread_idx; @@ -257,7 +257,7 @@ SBBreakpointLocation::SetThreadName (const char *thread_name) { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetThreadName (thread_name); } } @@ -267,7 +267,7 @@ SBBreakpointLocation::GetThreadName () const { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetThreadName(); } return NULL; @@ -278,7 +278,7 @@ SBBreakpointLocation::SetQueueName (const char *queue_name) { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetQueueName (queue_name); } } @@ -288,7 +288,7 @@ SBBreakpointLocation::GetQueueName () const { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->GetQueueName (); } return NULL; @@ -299,7 +299,7 @@ SBBreakpointLocation::IsResolved () { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->IsResolved(); } return false; @@ -319,7 +319,7 @@ SBBreakpointLocation::GetDescription (SBStream &description, DescriptionLevel le if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->GetDescription (&strm, level); strm.EOL(); } @@ -334,7 +334,7 @@ SBBreakpointLocation::GetID () { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetID (); } else @@ -352,7 +352,7 @@ SBBreakpointLocation::GetBreakpoint () SBBreakpoint sb_bp; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex()); *sb_bp = m_opaque_sp->GetBreakpoint ().shared_from_this(); } diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 21f431dac6a..dfa1709a349 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -398,7 +398,7 @@ SBCommandInterpreter::GetProcess () TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); if (target_sp) { - Mutex::Locker api_locker(target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); process_sp = target_sp->GetProcessSP(); sb_process.SetSP(process_sp); } @@ -483,9 +483,9 @@ SBCommandInterpreter::SourceInitFileInHomeDirectory (SBCommandReturnObject &resu if (IsValid()) { TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); - Mutex::Locker api_locker; + std::unique_lock<std::recursive_mutex> lock; if (target_sp) - api_locker.Lock(target_sp->GetAPIMutex()); + lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); m_opaque_ptr->SourceInitFile (false, result.ref()); } else @@ -508,9 +508,9 @@ SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory (SBCommandReturnOb if (IsValid()) { TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); - Mutex::Locker api_locker; + std::unique_lock<std::recursive_mutex> lock; if (target_sp) - api_locker.Lock(target_sp->GetAPIMutex()); + lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); m_opaque_ptr->SourceInitFile (true, result.ref()); } else diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index a1d19d44bad..3493ad507a7 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -411,9 +411,9 @@ SBDebugger::HandleCommand (const char *command) if (m_opaque_sp) { TargetSP target_sp (m_opaque_sp->GetSelectedTarget()); - Mutex::Locker api_locker; + std::unique_lock<std::recursive_mutex> lock; if (target_sp) - api_locker.Lock(target_sp->GetAPIMutex()); + lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); SBCommandInterpreter sb_interpreter(GetCommandInterpreter ()); SBCommandReturnObject result; @@ -474,8 +474,8 @@ SBDebugger::HandleProcessEvent (const SBProcess &process, const SBEvent &event, char stdio_buffer[1024]; size_t len; - Mutex::Locker api_locker (target_sp->GetAPIMutex()); - + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); + if (event_type & (Process::eBroadcastBitSTDOUT | Process::eBroadcastBitStateChanged)) { // Drain stdout when we stop just in case we have any bytes diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index 7ca7c16c2ad..fa686f6d459 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -105,8 +105,8 @@ SBFrame::SetFrameSP (const StackFrameSP &lldb_object_sp) bool SBFrame::IsValid() const { - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); @@ -126,8 +126,8 @@ SBFrame::GetSymbolContext (uint32_t resolve_scope) const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBSymbolContext sb_sym_ctx; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -169,8 +169,8 @@ SBFrame::GetModule () const Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBModule sb_module; ModuleSP module_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -212,8 +212,8 @@ SBFrame::GetCompileUnit () const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBCompileUnit sb_comp_unit; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -253,8 +253,8 @@ SBFrame::GetFunction () const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBFunction sb_function; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -294,8 +294,8 @@ SBFrame::GetSymbol () const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBSymbol sb_symbol; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -334,8 +334,8 @@ SBFrame::GetBlock () const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBlock sb_block; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -374,8 +374,8 @@ SBBlock SBFrame::GetFrameBlock () const { SBBlock sb_block; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -415,8 +415,8 @@ SBFrame::GetLineEntry () const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBLineEntry sb_line_entry; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -482,8 +482,8 @@ SBFrame::GetPC () const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); addr_t addr = LLDB_INVALID_ADDRESS; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -523,8 +523,8 @@ SBFrame::SetPC (addr_t new_pc) { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); bool ret_val = false; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -564,8 +564,8 @@ SBFrame::GetSP () const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); addr_t addr = LLDB_INVALID_ADDRESS; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -604,8 +604,8 @@ SBFrame::GetFP () const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); addr_t addr = LLDB_INVALID_ADDRESS; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -644,8 +644,8 @@ SBFrame::GetPCAddress () const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBAddress sb_addr; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = exe_ctx.GetFramePtr(); Target *target = exe_ctx.GetTargetPtr(); @@ -704,7 +704,6 @@ lldb::SBValue SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dynamic) { SBValue sb_value; - Mutex::Locker api_locker; Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (var_path == nullptr || var_path[0] == '\0') { @@ -712,8 +711,9 @@ SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dyn log->Printf ("SBFrame::GetValueForVariablePath called with empty variable path."); return sb_value; } - - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -780,8 +780,8 @@ SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic) } ValueObjectSP value_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -869,8 +869,8 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy } ValueObjectSP value_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -1048,8 +1048,8 @@ SBFrame::Disassemble () const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); const char *disassembly = nullptr; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -1138,8 +1138,8 @@ SBFrame::GetVariables (const lldb::SBVariablesOptions& options) Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBValueList value_list; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -1253,8 +1253,8 @@ SBFrame::GetRegisters () Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBValueList value_list; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -1305,8 +1305,8 @@ SBFrame::FindRegister (const char *name) SBValue result; ValueObjectSP value_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -1364,8 +1364,8 @@ SBFrame::GetDescription (SBStream &description) Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); Stream &strm = description.ref(); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame; Target *target = exe_ctx.GetTargetPtr(); @@ -1477,8 +1477,8 @@ SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &option ValueObjectSP expr_value_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBFrame()::EvaluateExpression (expr=\"%s\")...", expr); diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp index 2d03d53fd9f..b5983d763be 100644 --- a/lldb/source/API/SBFunction.cpp +++ b/lldb/source/API/SBFunction.cpp @@ -156,12 +156,12 @@ SBFunction::GetInstructions (SBTarget target, const char *flavor) SBInstructionList sb_instructions; if (m_opaque_ptr) { - Mutex::Locker api_locker; ExecutionContext exe_ctx; TargetSP target_sp (target.GetSP()); + std::unique_lock<std::recursive_mutex> lock; if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex()); + lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); target_sp->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target_sp->GetProcessSP()); } diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp index a17f3f8dbd5..75ff88111cf 100644 --- a/lldb/source/API/SBInstruction.cpp +++ b/lldb/source/API/SBInstruction.cpp @@ -75,12 +75,13 @@ SBInstruction::GetMnemonic(SBTarget target) { if (m_opaque_sp) { - Mutex::Locker api_locker; ExecutionContext exe_ctx; TargetSP target_sp (target.GetSP()); + std::unique_lock<std::recursive_mutex> lock; if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex()); + lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); + target_sp->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target_sp->GetProcessSP()); } @@ -94,12 +95,13 @@ SBInstruction::GetOperands(SBTarget target) { if (m_opaque_sp) { - Mutex::Locker api_locker; ExecutionContext exe_ctx; TargetSP target_sp (target.GetSP()); + std::unique_lock<std::recursive_mutex> lock; if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex()); + lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); + target_sp->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target_sp->GetProcessSP()); } @@ -113,12 +115,13 @@ SBInstruction::GetComment(SBTarget target) { if (m_opaque_sp) { - Mutex::Locker api_locker; ExecutionContext exe_ctx; TargetSP target_sp (target.GetSP()); + std::unique_lock<std::recursive_mutex> lock; if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex()); + lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); + target_sp->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target_sp->GetProcessSP()); } diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index eea5fdca2b3..1bf3d768841 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -163,7 +163,7 @@ SBProcess::RemoteLaunch (char const **argv, ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); if (process_sp->GetState() == eStateConnected) { if (stop_at_entry) @@ -209,7 +209,7 @@ SBProcess::RemoteAttachToProcessWithID (lldb::pid_t pid, lldb::SBError& error) ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); if (process_sp->GetState() == eStateConnected) { ProcessAttachInfo attach_info; @@ -251,7 +251,7 @@ SBProcess::GetNumThreads () Process::StopLocker stop_locker; const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); num_threads = process_sp->GetThreadList().GetSize(can_update); } @@ -272,7 +272,7 @@ SBProcess::GetSelectedThread () const ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); thread_sp = process_sp->GetThreadList().GetSelectedThread(); sb_thread.SetThread (thread_sp); } @@ -295,7 +295,7 @@ SBProcess::CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context) ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); thread_sp = process_sp->CreateOSPluginThread(tid, context); sb_thread.SetThread (thread_sp); } @@ -465,7 +465,7 @@ SBProcess::SetSelectedThread (const SBThread &thread) ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); return process_sp->GetThreadList().SetSelectedThreadByID (thread.GetThreadID()); } return false; @@ -480,7 +480,7 @@ SBProcess::SetSelectedThreadByID (lldb::tid_t tid) ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); ret_val = process_sp->GetThreadList().SetSelectedThreadByID (tid); } @@ -501,7 +501,7 @@ SBProcess::SetSelectedThreadByIndexID (uint32_t index_id) ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); ret_val = process_sp->GetThreadList().SetSelectedThreadByIndexID (index_id); } @@ -525,7 +525,7 @@ SBProcess::GetThreadAtIndex (size_t index) { Process::StopLocker stop_locker; const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, can_update); sb_thread.SetThread (thread_sp); } @@ -550,7 +550,7 @@ SBProcess::GetNumQueues () { Process::StopLocker stop_locker; - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); num_queues = process_sp->GetQueueList().GetSize(); } @@ -572,7 +572,7 @@ SBProcess::GetQueueAtIndex (size_t index) if (process_sp) { Process::StopLocker stop_locker; - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); queue_sp = process_sp->GetQueueList().GetQueueAtIndex(index); sb_queue.SetQueue (queue_sp); } @@ -593,7 +593,7 @@ SBProcess::GetStopID(bool include_expression_stops) ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); if (include_expression_stops) return process_sp->GetStopID(); else @@ -612,7 +612,7 @@ SBProcess::GetStopEventForStopID(uint32_t stop_id) ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); event_sp = process_sp->GetStopEventForStopID(stop_id); sb_event.reset(event_sp); } @@ -634,7 +634,7 @@ SBProcess::GetState () ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); ret_val = process_sp->GetState(); } @@ -655,7 +655,7 @@ SBProcess::GetExitStatus () ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); exit_status = process_sp->GetExitStatus (); } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -674,7 +674,7 @@ SBProcess::GetExitDescription () ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); exit_desc = process_sp->GetExitDescription (); } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -760,7 +760,7 @@ SBProcess::Continue () if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); if (process_sp->GetTarget().GetDebugger().GetAsyncExecution ()) sb_error.ref() = process_sp->Resume (); @@ -790,7 +790,7 @@ SBProcess::Destroy () ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); sb_error.SetError(process_sp->Destroy(false)); } else @@ -817,7 +817,7 @@ SBProcess::Stop () ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); sb_error.SetError (process_sp->Halt()); } else @@ -843,7 +843,7 @@ SBProcess::Kill () ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); sb_error.SetError (process_sp->Destroy(true)); } else @@ -877,7 +877,7 @@ SBProcess::Detach (bool keep_stopped) ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); sb_error.SetError (process_sp->Detach(keep_stopped)); } else @@ -893,7 +893,7 @@ SBProcess::Signal (int signo) ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); sb_error.SetError (process_sp->Signal (signo)); } else @@ -939,7 +939,7 @@ SBProcess::GetThreadByID (tid_t tid) { Process::StopLocker stop_locker; const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); thread_sp = process_sp->GetThreadList().FindThreadByID (tid, can_update); sb_thread.SetThread (thread_sp); } @@ -963,7 +963,7 @@ SBProcess::GetThreadByIndexID (uint32_t index_id) { Process::StopLocker stop_locker; const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); thread_sp = process_sp->GetThreadList().FindThreadByIndexID (index_id, can_update); sb_thread.SetThread (thread_sp); } @@ -1080,7 +1080,7 @@ SBProcess::ReadMemory (addr_t addr, void *dst, size_t dst_len, SBError &sb_error Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); bytes_read = process_sp->ReadMemory (addr, dst, dst_len, sb_error.ref()); } else @@ -1120,7 +1120,7 @@ SBProcess::ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBE Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); bytes_read = process_sp->ReadCStringFromMemory (addr, (char *)buf, size, sb_error.ref()); } else @@ -1149,7 +1149,7 @@ SBProcess::ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBErro Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); value = process_sp->ReadUnsignedIntegerFromMemory (addr, byte_size, 0, sb_error.ref()); } else @@ -1178,7 +1178,7 @@ SBProcess::ReadPointerFromMemory (addr_t addr, lldb::SBError &sb_error) Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); ptr = process_sp->ReadPointerFromMemory (addr, sb_error.ref()); } else @@ -1218,7 +1218,7 @@ SBProcess::WriteMemory (addr_t addr, const void *src, size_t src_len, SBError &s Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); bytes_written = process_sp->WriteMemory (addr, src, src_len, sb_error.ref()); } else @@ -1282,7 +1282,7 @@ SBProcess::GetNumSupportedHardwareWatchpoints (lldb::SBError &sb_error) const ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); sb_error.SetError(process_sp->GetWatchpointSupportInfo (num)); if (log) log->Printf ("SBProcess(%p)::GetNumSupportedHardwareWatchpoints () => %u", @@ -1312,7 +1312,7 @@ SBProcess::LoadImage (const lldb::SBFileSpec &sb_local_image_spec, Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); PlatformSP platform_sp = process_sp->GetTarget().GetPlatform(); return platform_sp->LoadImage (process_sp.get(), *sb_local_image_spec, @@ -1341,7 +1341,7 @@ SBProcess::UnloadImage (uint32_t image_token) Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); PlatformSP platform_sp = process_sp->GetTarget().GetPlatform(); sb_error.SetError (platform_sp->UnloadImage (process_sp.get(), image_token)); } @@ -1369,7 +1369,7 @@ SBProcess::SendEventData (const char *event_data) Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); sb_error.SetError (process_sp->SendEventData (event_data)); } else @@ -1459,7 +1459,7 @@ SBProcess::SaveCore(const char *file_name) return error; } - Mutex::Locker api_locker(process_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex()); if (process_sp->GetState() != eStateStopped) { diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp index 22d1e546b5e..0dbed1238b8 100644 --- a/lldb/source/API/SBSymbol.cpp +++ b/lldb/source/API/SBSymbol.cpp @@ -141,12 +141,13 @@ SBSymbol::GetInstructions (SBTarget target, const char *flavor_string) SBInstructionList sb_instructions; if (m_opaque_ptr) { - Mutex::Locker api_locker; ExecutionContext exe_ctx; TargetSP target_sp (target.GetSP()); + std::unique_lock<std::recursive_mutex> lock; if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex()); + lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); + target_sp->CalculateExecutionContext (exe_ctx); } if (m_opaque_ptr->ValueIsAddress()) diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index df3001b6c72..6a5301b0605 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -77,7 +77,7 @@ namespace { Error AttachToProcess (ProcessAttachInfo &attach_info, Target &target) { - Mutex::Locker api_locker (target.GetAPIMutex ()); + std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex()); auto process_sp = target.GetProcessSP (); if (process_sp) @@ -267,7 +267,7 @@ SBTarget::Install() TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); sb_error.ref() = target_sp->Install(NULL); } return sb_error; @@ -307,7 +307,7 @@ SBTarget::Launch if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); if (stop_at_entry) launch_flags |= eLaunchFlagStopAtEntry; @@ -394,7 +394,7 @@ SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error) if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); StateType state = eStateInvalid; { ProcessSP process_sp = target_sp->GetProcessSP(); @@ -622,7 +622,7 @@ SBTarget::ConnectRemote if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); if (listener.IsValid()) process_sp = target_sp->CreateProcess (listener.m_opaque_sp, plugin_name, NULL); else @@ -706,7 +706,7 @@ SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr) TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); if (target_sp->ResolveLoadAddress (vm_addr, addr)) return sb_addr; } @@ -725,7 +725,7 @@ SBTarget::ResolveFileAddress (lldb::addr_t file_addr) TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); if (target_sp->ResolveFileAddress (file_addr, addr)) return sb_addr; } @@ -742,7 +742,7 @@ SBTarget::ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr) TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); if (target_sp->ResolveLoadAddress (vm_addr, addr)) return sb_addr; } @@ -778,7 +778,7 @@ SBTarget::ReadMemory (const SBAddress addr, TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); bytes_read = target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref()); } else @@ -814,7 +814,7 @@ SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, TargetSP target_sp(GetSP()); if (target_sp && line != 0) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); const LazyBool check_inlines = eLazyBoolCalculate; const LazyBool skip_prologue = eLazyBoolCalculate; @@ -856,7 +856,7 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, TargetSP target_sp(GetSP()); if (target_sp.get()) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); const bool internal = false; const bool hardware = false; @@ -916,7 +916,7 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, const bool internal = false; const bool hardware = false; const LazyBool skip_prologue = eLazyBoolCalculate; - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); *sb_bp = target_sp->CreateBreakpoint (module_list.get(), comp_unit_list.get(), symbol_name, @@ -972,7 +972,7 @@ SBTarget::BreakpointCreateByNames (const char *symbol_names[], TargetSP target_sp(GetSP()); if (target_sp && num_names > 0) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); const bool internal = false; const bool hardware = false; const LazyBool skip_prologue = eLazyBoolCalculate; @@ -1045,7 +1045,7 @@ SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, TargetSP target_sp(GetSP()); if (target_sp && symbol_name_regex && symbol_name_regex[0]) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); RegularExpression regexp(symbol_name_regex); const bool internal = false; const bool hardware = false; @@ -1071,7 +1071,7 @@ SBTarget::BreakpointCreateByAddress (addr_t address) TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); const bool hardware = false; *sb_bp = target_sp->CreateBreakpoint (address, false, hardware); } @@ -1102,7 +1102,7 @@ SBTarget::BreakpointCreateBySBAddress (SBAddress &sb_address) if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); const bool hardware = false; *sb_bp = target_sp->CreateBreakpoint (sb_address.ref(), false, hardware); } @@ -1162,7 +1162,7 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, TargetSP target_sp(GetSP()); if (target_sp && source_regex && source_regex[0]) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); const bool hardware = false; const LazyBool move_to_nearest_code = eLazyBoolCalculate; RegularExpression regexp(source_regex); @@ -1200,7 +1200,7 @@ SBTarget::BreakpointCreateForException (lldb::LanguageType language, TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); const bool hardware = false; *sb_bp = target_sp->CreateExceptionBreakpoint (language, catch_bp, throw_bp, hardware); } @@ -1249,7 +1249,7 @@ SBTarget::BreakpointDelete (break_id_t bp_id) TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); result = target_sp->RemoveBreakpointByID (bp_id); } @@ -1270,7 +1270,7 @@ SBTarget::FindBreakpointByID (break_id_t bp_id) TargetSP target_sp(GetSP()); if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); *sb_breakpoint = target_sp->GetBreakpointByID (bp_id); } @@ -1289,7 +1289,7 @@ SBTarget::EnableAllBreakpoints () TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); target_sp->EnableAllBreakpoints (); return true; } @@ -1302,7 +1302,7 @@ SBTarget::DisableAllBreakpoints () TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); target_sp->DisableAllBreakpoints (); return true; } @@ -1315,7 +1315,7 @@ SBTarget::DeleteAllBreakpoints () TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); target_sp->RemoveAllBreakpoints (); return true; } @@ -1356,9 +1356,9 @@ SBTarget::DeleteWatchpoint (watch_id_t wp_id) TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); - Mutex::Locker locker; - target_sp->GetWatchpointList().GetListMutex(locker); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); + std::unique_lock<std::recursive_mutex> lock; + target_sp->GetWatchpointList().GetListMutex(lock); result = target_sp->RemoveWatchpointByID (wp_id); } @@ -1380,9 +1380,9 @@ SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id) TargetSP target_sp(GetSP()); if (target_sp && wp_id != LLDB_INVALID_WATCH_ID) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); - Mutex::Locker locker; - target_sp->GetWatchpointList().GetListMutex(locker); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); + std::unique_lock<std::recursive_mutex> lock; + target_sp->GetWatchpointList().GetListMutex(lock); watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id); sb_watchpoint.SetSP (watchpoint_sp); } @@ -1406,7 +1406,7 @@ SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write, S TargetSP target_sp(GetSP()); if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS && size > 0) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); uint32_t watch_type = 0; if (read) watch_type |= LLDB_WATCH_TYPE_READ; @@ -1442,9 +1442,9 @@ SBTarget::EnableAllWatchpoints () TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); - Mutex::Locker locker; - target_sp->GetWatchpointList().GetListMutex(locker); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); + std::unique_lock<std::recursive_mutex> lock; + target_sp->GetWatchpointList().GetListMutex(lock); target_sp->EnableAllWatchpoints (); return true; } @@ -1457,9 +1457,9 @@ SBTarget::DisableAllWatchpoints () TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); - Mutex::Locker locker; - target_sp->GetWatchpointList().GetListMutex(locker); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); + std::unique_lock<std::recursive_mutex> lock; + target_sp->GetWatchpointList().GetListMutex(lock); target_sp->DisableAllWatchpoints (); return true; } @@ -1551,9 +1551,9 @@ SBTarget::DeleteAllWatchpoints () TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); - Mutex::Locker locker; - target_sp->GetWatchpointList().GetListMutex(locker); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); + std::unique_lock<std::recursive_mutex> lock; + target_sp->GetWatchpointList().GetListMutex(lock); target_sp->RemoveAllWatchpoints (); return true; } @@ -2431,7 +2431,7 @@ SBTarget::EvaluateExpression (const char *expr, const SBExpressionOptions &optio return expr_result; } - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); ExecutionContext exe_ctx (m_opaque_sp.get()); if (log) diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 1fc0fdc5075..0685c17a5a2 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -96,8 +96,8 @@ SBThread::GetQueue () const { SBQueue sb_queue; QueueSP queue_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (exe_ctx.HasThreadScope()) @@ -130,8 +130,8 @@ SBThread::GetQueue () const bool SBThread::IsValid() const { - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); @@ -158,8 +158,8 @@ SBThread::GetStopReason() Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); StopReason reason = eStopReasonInvalid; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -187,8 +187,8 @@ SBThread::GetStopReason() size_t SBThread::GetStopReasonDataCount () { - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -247,8 +247,8 @@ SBThread::GetStopReasonDataCount () uint64_t SBThread::GetStopReasonDataAtIndex (uint32_t idx) { - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -369,8 +369,8 @@ SBThread::GetStopDescription (char *dst, size_t dst_len) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -501,8 +501,8 @@ SBThread::GetStopReturnValue () { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); ValueObjectSP return_valobj_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -562,8 +562,8 @@ SBThread::GetName () const { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); const char *name = NULL; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -592,8 +592,8 @@ const char * SBThread::GetQueueName () const { const char *name = NULL; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (exe_ctx.HasThreadScope()) @@ -623,8 +623,8 @@ lldb::queue_id_t SBThread::GetQueueID () const { queue_id_t id = LLDB_INVALID_QUEUE_ID; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (exe_ctx.HasThreadScope()) @@ -654,8 +654,8 @@ SBThread::GetInfoItemByPathAsString (const char *path, SBStream &strm) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); bool success = false; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -760,9 +760,8 @@ SBThread::StepOver (lldb::RunMode stop_other_threads) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBThread(%p)::StepOver (stop_other_threads='%s')", @@ -819,8 +818,8 @@ SBThread::StepInto (const char *target_name, uint32_t end_line, SBError &error, { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBThread(%p)::StepInto (target_name='%s', stop_other_threads='%s')", @@ -874,8 +873,8 @@ SBThread::StepOut () { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBThread(%p)::StepOut ()", @@ -908,8 +907,8 @@ SBThread::StepOutOfFrame (lldb::SBFrame &sb_frame) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (!sb_frame.IsValid()) { @@ -961,10 +960,8 @@ SBThread::StepInstruction (bool step_over) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - - + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBThread(%p)::StepInstruction (step_over=%i)", @@ -985,9 +982,8 @@ SBThread::RunToAddress (lldb::addr_t addr) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBThread(%p)::RunToAddress (addr=0x%" PRIx64 ")", @@ -1020,8 +1016,8 @@ SBThread::StepOverUntil (lldb::SBFrame &sb_frame, Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); char path[PATH_MAX]; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrameSP frame_sp (sb_frame.GetFrameSP()); @@ -1164,8 +1160,8 @@ SBThread::StepUsingScriptedThreadPlan (const char *script_class_name) Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBError sb_error; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) { @@ -1204,8 +1200,8 @@ SBThread::JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line) Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBError sb_error; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBThread(%p)::JumpToLine (file+line = %s:%u)", @@ -1232,9 +1228,8 @@ SBThread::ReturnFromFrame (SBFrame &frame, SBValue &return_value) Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBThread(%p)::ReturnFromFrame (frame=%d)", @@ -1355,8 +1350,8 @@ SBThread::GetNumFrames () Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); uint32_t num_frames = 0; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -1387,8 +1382,8 @@ SBThread::GetFrameAtIndex (uint32_t idx) SBFrame sb_frame; StackFrameSP frame_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -1426,8 +1421,8 @@ SBThread::GetSelectedFrame () SBFrame sb_frame; StackFrameSP frame_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -1465,8 +1460,8 @@ SBThread::SetSelectedFrame (uint32_t idx) SBFrame sb_frame; StackFrameSP frame_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -1569,8 +1564,8 @@ SBThread SBThread::GetExtendedBacktraceThread (const char *type) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); SBThread sb_origin_thread; if (exe_ctx.HasThreadScope()) diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index a8584c5d38c..383d39f5368 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -127,7 +127,7 @@ public: } lldb::ValueObjectSP - GetSP (Process::StopLocker &stop_locker, Mutex::Locker &api_locker, Error &error) + GetSP(Process::StopLocker &stop_locker, std::unique_lock<std::recursive_mutex> &lock, Error &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (!m_valobj_sp) @@ -139,11 +139,11 @@ public: lldb::ValueObjectSP value_sp = m_valobj_sp; Target *target = value_sp->GetTargetSP().get(); - if (target) - api_locker.Lock(target->GetAPIMutex()); - else + if (!target) return ValueObjectSP(); + lock = std::unique_lock<std::recursive_mutex>(target->GetAPIMutex()); + ProcessSP process_sp(value_sp->GetProcessSP()); if (process_sp && !stop_locker.TryLock (&process_sp->GetRunLock())) { @@ -255,13 +255,13 @@ public: ValueLocker () { } - + ValueObjectSP GetLockedSP(ValueImpl &in_value) { - return in_value.GetSP(m_stop_locker, m_api_locker, m_lock_error); + return in_value.GetSP(m_stop_locker, m_lock, m_lock_error); } - + Error & GetError() { @@ -270,9 +270,8 @@ public: private: Process::StopLocker m_stop_locker; - Mutex::Locker m_api_locker; + std::unique_lock<std::recursive_mutex> m_lock; Error m_lock_error; - }; SBValue::SBValue () : diff --git a/lldb/source/API/SBWatchpoint.cpp b/lldb/source/API/SBWatchpoint.cpp index 1a1a970aaa8..c33d5686b9c 100644 --- a/lldb/source/API/SBWatchpoint.cpp +++ b/lldb/source/API/SBWatchpoint.cpp @@ -115,7 +115,7 @@ SBWatchpoint::GetHardwareIndex () lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex()); hw_index = watchpoint_sp->GetHardwareIndex(); } @@ -130,7 +130,7 @@ SBWatchpoint::GetWatchAddress () lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex()); ret_addr = watchpoint_sp->GetLoadAddress(); } @@ -145,7 +145,7 @@ SBWatchpoint::GetWatchSize () lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex()); watch_size = watchpoint_sp->GetByteSize(); } @@ -158,7 +158,7 @@ SBWatchpoint::SetEnabled (bool enabled) lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex()); watchpoint_sp->GetTarget().DisableWatchpointByID(watchpoint_sp->GetID()); } } @@ -169,7 +169,7 @@ SBWatchpoint::IsEnabled () lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex()); return watchpoint_sp->IsEnabled(); } else @@ -183,7 +183,7 @@ SBWatchpoint::GetHitCount () lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex()); count = watchpoint_sp->GetHitCount(); } @@ -201,7 +201,7 @@ SBWatchpoint::GetIgnoreCount () lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex()); return watchpoint_sp->GetIgnoreCount(); } else @@ -214,7 +214,7 @@ SBWatchpoint::SetIgnoreCount (uint32_t n) lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex()); watchpoint_sp->SetIgnoreCount (n); } } @@ -225,7 +225,7 @@ SBWatchpoint::GetCondition () lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex()); return watchpoint_sp->GetConditionText (); } return NULL; @@ -237,7 +237,7 @@ SBWatchpoint::SetCondition (const char *condition) lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex()); watchpoint_sp->SetCondition (condition); } } @@ -250,7 +250,7 @@ SBWatchpoint::GetDescription (SBStream &description, DescriptionLevel level) lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex()); watchpoint_sp->GetDescription (&strm, level); strm.EOL(); } |