Browse Source

Debugger.Eval rewritten to hold its state in one enum

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@889 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
e05a82005e
  1. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
  2. 93
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs

3
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 // this will also remove the eval form PendingEvals collection
Eval eval = debugger.GetEval(corEval); Eval eval = debugger.GetEval(corEval);
if (eval != null) { if (eval != null) {
eval.Successful = !exception; eval.OnEvalComplete(!exception);
eval.OnEvalComplete(new EvalEventArgs(eval));
} }
if (debugger.PendingEvals.Count > 0) { if (debugger.PendingEvals.Count > 0) {

93
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs

@ -17,6 +17,8 @@ namespace Debugger
{ {
delegate ICorDebugValue[] CorValuesGetter(); delegate ICorDebugValue[] CorValuesGetter();
public enum EvalState {Pending, Evaluating, EvaluatedSuccessfully, EvaluatedException, EvaluatedNoResult, Error, Expired};
/// <summary> /// <summary>
/// This class holds information about function evaluation. /// This class holds information about function evaluation.
/// </summary> /// </summary>
@ -30,10 +32,9 @@ namespace Debugger
ICorDebugFunction corFunction; ICorDebugFunction corFunction;
CorValuesGetter getArgs; CorValuesGetter getArgs;
bool evaluating = false; EvalState evalState = EvalState.Pending;
bool evaluated = false;
bool successful = false;
Value result; Value result;
string error;
public event EventHandler<EvalEventArgs> EvalStarted; public event EventHandler<EvalEventArgs> EvalStarted;
public event EventHandler<EvalEventArgs> EvalComplete; public event EventHandler<EvalEventArgs> EvalComplete;
@ -44,43 +45,29 @@ namespace Debugger
} }
} }
/// <summary> public EvalState EvalState {
/// True if the evaluation has been completed.
/// </summary>
public bool Evaluated {
get { get {
return evaluated; if (result != null && result.IsExpired) {
} return EvalState.Expired;
} } else {
return evalState;
/// <summary> }
/// True if the eval is being evaluated at the moment.
/// </summary>
public bool Evaluating {
get {
return evaluating;
}
set {
evaluating = value;
} }
} }
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
public bool Successful { public bool Evaluated {
get { get {
return successful; return this.EvalState != EvalState.Pending &&
} this.EvalState != EvalState.Evaluating;
internal set {
successful = value;
} }
} }
public bool HasExpired { public bool HasExpired {
get { get {
return debugeeStateIDatCreation != debugger.DebugeeStateID || return this.EvalState == EvalState.Expired;
Result.IsExpired;
} }
} }
@ -89,26 +76,18 @@ namespace Debugger
/// </summary> /// </summary>
public Value Result { public Value Result {
get { get {
if (Evaluated) { switch(this.EvalState) {
if (Successful) { case EvalState.Pending: return new UnavailableValue(debugger, "Evaluation pending");
if (result != null) { case EvalState.Evaluating: return new UnavailableValue(debugger, "Evaluating...");
return result; case EvalState.EvaluatedSuccessfully: return result;
} else { case EvalState.EvaluatedException:
return new UnavailableValue(debugger, "No return value");
}
} else {
ObjectValue exception = (ObjectValue)result; ObjectValue exception = (ObjectValue)result;
while (exception.Type != "System.Exception") { while (exception.Type != "System.Exception") exception = exception.BaseClass;
exception = exception.BaseClass;
}
return new UnavailableValue(debugger, result.Type + ": " + exception["_message"].Value.AsString); return new UnavailableValue(debugger, result.Type + ": " + exception["_message"].Value.AsString);
} case EvalState.EvaluatedNoResult: return new UnavailableValue(debugger, "No return value");
} else { case EvalState.Error: return new UnavailableValue(debugger, error);
if (Evaluating) { case EvalState.Expired: return new UnavailableValue(debugger, "Result has expired");
return new UnavailableValue(debugger, "Evaluating..."); default: throw new DebuggerException("Unknown state");
} else {
return new UnavailableValue(debugger, "Evaluation pending");
}
} }
} }
} }
@ -147,10 +126,9 @@ namespace Debugger
corEval.CallFunction(corFunction, (uint)args.Length, args); corEval.CallFunction(corFunction, (uint)args.Length, args);
evaluating = true;
OnEvalStarted(new EvalEventArgs(this)); OnEvalStarted(new EvalEventArgs(this));
evalState = EvalState.Evaluating;
return true; 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; ICorDebugValue corValue;
corEval.GetResult(out corValue); corEval.GetResult(out corValue);
result = Value.CreateValue(debugger, 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) { if (EvalComplete != null) {
EvalComplete(this, e); EvalComplete(this, new EvalEventArgs(this));
} }
} }
} }

Loading…
Cancel
Save