diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs index 0bfb4640c8..2ac7d7218f 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs @@ -63,6 +63,12 @@ namespace Debugger } } + public bool IsAtSafePoint { + get { + return corThread.UserState != CorDebugUserState.USER_UNSAFE_POINT; + } + } + public ICorDebugThread CorThread { get { return corThread; diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs index 0a874c79c9..4bdf19136e 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs @@ -153,6 +153,9 @@ namespace Debugger if (targetThread.IsLastFunctionNative) { throw new EvalSetupException("Can not evaluate because native frame is on top of stack"); } + if (!targetThread.IsAtSafePoint) { + throw new EvalSetupException("Can not evaluate because thread is not at a safe point"); + } // TODO: What if this thread is not suitable? corEval = targetThread.CorThread.CreateEval();