<rdar://problem/13643315> 

Fixed performance issues that arose after changing SBTarget, SBProcess, SBThread and SBFrame over to using a std::shared_ptr to a ExecutionContextRef. The ExecutionContextRef doesn't store a std::weak_ptr to a stack frame because stack frames often get replaced with new version, so it held onto a StackID object that would allow us to ask the thread each time for the frame for the StackID. The linear function was too slow for large recursive stacks. We also fixed an issue where anytime the std::shared_ptr<ExecutionContextRef> in any SBTarget, SBProcess, SBThread objects was turned into an ExecutionContext object, it would try to resolve all items in the ExecutionContext which are shared pointers. Even if the StackID in the ExecutionContextRef was invalid, it was looking through all frames in every thread. This causes a lot of unnecessary frame accesses.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@182627 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/ExecutionContext.cpp b/source/Target/ExecutionContext.cpp
index 6ab0355..8b5731e 100644
--- a/source/Target/ExecutionContext.cpp
+++ b/source/Target/ExecutionContext.cpp
@@ -806,9 +806,12 @@
 lldb::StackFrameSP
 ExecutionContextRef::GetFrameSP () const
 {
-    lldb::ThreadSP thread_sp (GetThreadSP());
-    if (thread_sp)
-        return thread_sp->GetFrameWithStackID (m_stack_id);
+    if (m_stack_id.IsValid())
+    {
+        lldb::ThreadSP thread_sp (GetThreadSP());
+        if (thread_sp)
+            return thread_sp->GetFrameWithStackID (m_stack_id);
+    }
     return lldb::StackFrameSP();
 }