Don't set the thread when adopting selected execution context entries, and use the "lldb_private::StateIsStoppedState(StateType, bool)" function to tell if the state is stopped.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@161000 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/ExecutionContext.cpp b/source/Target/ExecutionContext.cpp
index 2c0a146..300e879 100644
--- a/source/Target/ExecutionContext.cpp
+++ b/source/Target/ExecutionContext.cpp
@@ -8,6 +8,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/Target/ExecutionContext.h"
+
+#include "lldb/Core/State.h"
 #include "lldb/Target/ExecutionContextScope.h"
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Target/Process.h"
@@ -639,18 +641,22 @@
                     m_process_wp = process_sp;
                     if (process_sp)
                     {
-                        lldb::ThreadSP thread_sp (process_sp->GetThreadList().GetSelectedThread());
-                        if (!thread_sp)
-                            thread_sp = process_sp->GetThreadList().GetThreadAtIndex(0);
-                        
-                        if (thread_sp && process_sp->GetState() == lldb::eStateStopped)
+                        // Only fill in the thread and frame if our process is stopped
+                        if (StateIsStoppedState (process_sp->GetState(), true))
                         {
-                            SetThreadSP (thread_sp);
-                            lldb::StackFrameSP frame_sp (thread_sp->GetSelectedFrame());
-                            if (!frame_sp)
-                                frame_sp = thread_sp->GetStackFrameAtIndex(0);
-                            if (frame_sp)
-                                SetFrameSP (frame_sp);
+                            lldb::ThreadSP thread_sp (process_sp->GetThreadList().GetSelectedThread());
+                            if (!thread_sp)
+                                thread_sp = process_sp->GetThreadList().GetThreadAtIndex(0);
+                            
+                            if (thread_sp)
+                            {
+                                SetThreadSP (thread_sp);
+                                lldb::StackFrameSP frame_sp (thread_sp->GetSelectedFrame());
+                                if (!frame_sp)
+                                    frame_sp = thread_sp->GetStackFrameAtIndex(0);
+                                if (frame_sp)
+                                    SetFrameSP (frame_sp);
+                            }
                         }
                     }
                 }