diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
index e4c8f78aac..d8d7939f14 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
@@ -230,8 +230,7 @@ namespace Debugger
// this will also remove the eval form PendingEvals collection
Eval eval = debugger.GetEval(corEval);
if (eval != null) {
- eval.Successful = !exception;
- eval.OnEvalComplete(new EvalEventArgs(eval));
+ eval.OnEvalComplete(!exception);
}
if (debugger.PendingEvals.Count > 0) {
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 3135c8125d..811353b259 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
@@ -17,6 +17,8 @@ namespace Debugger
{
delegate ICorDebugValue[] CorValuesGetter();
+ public enum EvalState {Pending, Evaluating, EvaluatedSuccessfully, EvaluatedException, EvaluatedNoResult, Error, Expired};
+
///
/// This class holds information about function evaluation.
///
@@ -30,10 +32,9 @@ namespace Debugger
ICorDebugFunction corFunction;
CorValuesGetter getArgs;
- bool evaluating = false;
- bool evaluated = false;
- bool successful = false;
+ EvalState evalState = EvalState.Pending;
Value result;
+ string error;
public event EventHandler EvalStarted;
public event EventHandler EvalComplete;
@@ -44,43 +45,29 @@ namespace Debugger
}
}
- ///
- /// True if the evaluation has been completed.
- ///
- public bool Evaluated {
+ public EvalState EvalState {
get {
- return evaluated;
- }
- }
-
- ///
- /// True if the eval is being evaluated at the moment.
- ///
- public bool Evaluating {
- get {
- return evaluating;
- }
- set {
- evaluating = value;
+ if (result != null && result.IsExpired) {
+ return EvalState.Expired;
+ } else {
+ return evalState;
+ }
}
}
///
- /// True if the evaluation was successful, false if it thown an exception (which is presented as the result)
+ /// True if the evaluation has been completed.
///
- public bool Successful {
+ public bool Evaluated {
get {
- return successful;
- }
- internal set {
- successful = value;
+ return this.EvalState != EvalState.Pending &&
+ this.EvalState != EvalState.Evaluating;
}
}
public bool HasExpired {
get {
- return debugeeStateIDatCreation != debugger.DebugeeStateID ||
- Result.IsExpired;
+ return this.EvalState == EvalState.Expired;
}
}
@@ -89,26 +76,18 @@ namespace Debugger
///
public Value Result {
get {
- if (Evaluated) {
- if (Successful) {
- if (result != null) {
- return result;
- } else {
- return new UnavailableValue(debugger, "No return value");
- }
- } else {
+ switch(this.EvalState) {
+ case EvalState.Pending: return new UnavailableValue(debugger, "Evaluation pending");
+ case EvalState.Evaluating: return new UnavailableValue(debugger, "Evaluating...");
+ case EvalState.EvaluatedSuccessfully: return result;
+ case EvalState.EvaluatedException:
ObjectValue exception = (ObjectValue)result;
- while (exception.Type != "System.Exception") {
- exception = exception.BaseClass;
- }
+ while (exception.Type != "System.Exception") exception = exception.BaseClass;
return new UnavailableValue(debugger, result.Type + ": " + exception["_message"].Value.AsString);
- }
- } else {
- if (Evaluating) {
- return new UnavailableValue(debugger, "Evaluating...");
- } else {
- return new UnavailableValue(debugger, "Evaluation pending");
- }
+ case EvalState.EvaluatedNoResult: return new UnavailableValue(debugger, "No return value");
+ case EvalState.Error: return new UnavailableValue(debugger, error);
+ case EvalState.Expired: return new UnavailableValue(debugger, "Result has expired");
+ default: throw new DebuggerException("Unknown state");
}
}
}
@@ -147,10 +126,9 @@ namespace Debugger
corEval.CallFunction(corFunction, (uint)args.Length, args);
- evaluating = true;
-
OnEvalStarted(new EvalEventArgs(this));
+ evalState = EvalState.Evaluating;
return true;
}
@@ -161,17 +139,24 @@ namespace Debugger
}
}
- protected internal virtual void OnEvalComplete(EvalEventArgs e)
+ protected internal virtual void OnEvalComplete(bool successful)
{
- evaluating = false;
- evaluated = true;
-
ICorDebugValue corValue;
corEval.GetResult(out corValue);
result = Value.CreateValue(debugger, corValue);
-
+
+ if (result == null) {
+ evalState = EvalState.EvaluatedNoResult;
+ } else {
+ if (successful) {
+ evalState = EvalState.EvaluatedSuccessfully;
+ } else {
+ evalState = EvalState.EvaluatedException;
+ }
+ }
+
if (EvalComplete != null) {
- EvalComplete(this, e);
+ EvalComplete(this, new EvalEventArgs(this));
}
}
}