diff options
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/source/API/SBFrame.cpp | 15 | ||||
-rw-r--r-- | lldb/source/API/SBThread.cpp | 14 |
2 files changed, 27 insertions, 2 deletions
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index 5c491eb4e22..7ca7c16c2ad 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -105,7 +105,20 @@ SBFrame::SetFrameSP (const StackFrameSP &lldb_object_sp) bool SBFrame::IsValid() const { - return GetFrameSP().get() != nullptr; + Mutex::Locker api_locker; + ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + + Target *target = exe_ctx.GetTargetPtr(); + Process *process = exe_ctx.GetProcessPtr(); + if (target && process) + { + Process::StopLocker stop_locker; + if (stop_locker.TryLock(&process->GetRunLock())) + return GetFrameSP().get() != nullptr; + } + + // Without a target & process we can't have a valid stack frame. + return false; } SBSymbolContext diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 43fb96d6677..1fc0fdc5075 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -130,7 +130,19 @@ SBThread::GetQueue () const bool SBThread::IsValid() const { - return m_opaque_sp->GetThreadSP().get() != NULL; + Mutex::Locker api_locker; + ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + + Target *target = exe_ctx.GetTargetPtr(); + Process *process = exe_ctx.GetProcessPtr(); + if (target && process) + { + Process::StopLocker stop_locker; + if (stop_locker.TryLock(&process->GetRunLock())) + return m_opaque_sp->GetThreadSP().get() != NULL; + } + // Without a valid target & process, this thread can't be valid. + return false; } void |