<rdar://problem/13194155>
Fixing an issue where threads and frames could get out of sync and cause ValueObjects to fail to retrieve their values correctly
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@177166 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/ExecutionContext.cpp b/source/Target/ExecutionContext.cpp
index ae3fc20..9ace4c9 100644
--- a/source/Target/ExecutionContext.cpp
+++ b/source/Target/ExecutionContext.cpp
@@ -815,22 +815,20 @@
ExecutionContextRef::GetFrameSP () const
{
lldb::StackFrameSP frame_sp (m_frame_wp.lock());
- if (!frame_sp && m_stack_id.IsValid())
+ if (frame_sp)
{
- lldb::ThreadSP thread_sp (GetThreadSP());
- if (thread_sp)
- {
- frame_sp = thread_sp->GetFrameWithStackID (m_stack_id);
- m_frame_wp = frame_sp;
- }
- else
- {
- // If the thread that this frame was supposed to belong to is not valid, then
- // return a NULL frame_sp.
- frame_sp.reset();
- }
+ lldb::ThreadSP frame_thread_sp(frame_sp->GetThread());
+ if (frame_thread_sp && frame_thread_sp->IsValid())
+ return frame_sp;
}
- return frame_sp;
+ lldb::ThreadSP thread_sp (GetThreadSP());
+ if (thread_sp && thread_sp->IsValid())
+ {
+ frame_sp = thread_sp->GetFrameWithStackID (m_stack_id);
+ m_frame_wp = frame_sp;
+ return frame_sp;
+ }
+ return lldb::StackFrameSP();
}
ExecutionContext
diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp
index 0a45d33..913456d 100644
--- a/source/Target/StackFrameList.cpp
+++ b/source/Target/StackFrameList.cpp
@@ -250,6 +250,10 @@
void
StackFrameList::GetFramesUpTo(uint32_t end_idx)
{
+ // this makes sure we do not fetch frames for an invalid thread
+ if (m_thread.IsValid() == false)
+ return;
+
// We've already gotten more frames than asked for, or we've already finished unwinding, return.
if (m_frames.size() > end_idx || GetAllFramesFetched())
return;