Browse Source

Lazy getting of property values

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@840 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
48ccbb0065
  1. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs
  2. 34
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  3. 9
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
  4. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs
  5. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs

@ -178,8 +178,6 @@ namespace Debugger
if (IsPaused) { if (IsPaused) {
localVariables.Update(); localVariables.Update();
this.StartEvaluation(); this.StartEvaluation();
// Evaluation loop stoped by Function.GetPropertyVariables not adding evals
// And PropertyVariable not setting new value
} }
if (IsPaused) { if (IsPaused) {

34
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs

@ -486,26 +486,30 @@ namespace Debugger
get { get {
foreach(MethodProps method in module.MetaData.EnumMethods(methodProps.ClassToken)) { foreach(MethodProps method in module.MetaData.EnumMethods(methodProps.ClassToken)) {
if (method.Name.StartsWith("get_") && method.HasSpecialName) { if (method.Name.StartsWith("get_") && method.HasSpecialName) {
ICorDebugValue[] evalArgs;
ICorDebugFunction evalCorFunction;
Module.CorModule.GetFunctionFromToken(method.Token, out evalCorFunction);
if (IsStatic) {
evalArgs = new ICorDebugValue[0];
} else {
evalArgs = new ICorDebugValue[] {ThisValue.CorValue};
}
Eval eval = new Eval(debugger, evalCorFunction, evalArgs);
// Do not add evals if we just evaluated them, otherwise we get infinite loop
if (debugger.PausedReason != PausedReason.AllEvalsComplete) {
debugger.AddEval(eval);
}
yield return new PropertyVariable(debugger, yield return new PropertyVariable(debugger,
method.Name.Remove(0, 4), method.Name.Remove(0, 4),
delegate {return eval;}); delegate {
return CreatePropertyEval(method);
});
} }
} }
} }
} }
Eval CreatePropertyEval(MethodProps method)
{
ICorDebugValue[] evalArgs;
ICorDebugFunction evalCorFunction;
Module.CorModule.GetFunctionFromToken(method.Token, out evalCorFunction);
if (IsStatic) {
evalArgs = new ICorDebugValue[0];
} else {
evalArgs = new ICorDebugValue[] {ThisValue.CorValue};
}
Eval eval = new Eval(debugger, evalCorFunction, evalArgs);
debugger.AddEval(eval);
return eval;
}
IEnumerable<Variable> GetLocalVariablesInScope(ISymbolScope symScope) IEnumerable<Variable> GetLocalVariablesInScope(ISymbolScope symScope)
{ {

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

@ -22,6 +22,8 @@ namespace Debugger
{ {
NDebugger debugger; NDebugger debugger;
object debugeeStateIDatCreation;
ICorDebugEval corEval; ICorDebugEval corEval;
ICorDebugFunction corFunction; ICorDebugFunction corFunction;
ICorDebugValue[] args; ICorDebugValue[] args;
@ -73,6 +75,12 @@ namespace Debugger
} }
} }
public bool HasExpired {
get {
return debugeeStateIDatCreation != debugger.DebugeeStateID;
}
}
/// <summary> /// <summary>
/// The result of the evaluation. Always non-null, but it may be UnavailableValue. /// The result of the evaluation. Always non-null, but it may be UnavailableValue.
/// </summary> /// </summary>
@ -113,6 +121,7 @@ namespace Debugger
this.debugger = debugger; this.debugger = debugger;
this.corFunction = corFunction; this.corFunction = corFunction;
this.args = args; this.args = args;
this.debugeeStateIDatCreation = debugger.DebugeeStateID;
} }
/// <returns>True is setup was successful</returns> /// <returns>True is setup was successful</returns>

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs

@ -35,7 +35,7 @@ namespace Debugger
public Eval Eval { public Eval Eval {
get { get {
if (cachedEval == null || cachedEval.Result.IsExpired) { if (cachedEval == null || cachedEval.HasExpired) {
cachedEval = evalCreator(); cachedEval = evalCreator();
if (cachedEval == null) throw new DebuggerException("EvalGetter returned null"); if (cachedEval == null) throw new DebuggerException("EvalGetter returned null");
cachedEval.EvalStarted += delegate { OnValueChanged(); }; cachedEval.EvalStarted += delegate { OnValueChanged(); };

1
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs

@ -77,6 +77,7 @@ namespace Debugger
protected virtual void OnValueChanged() protected virtual void OnValueChanged()
{ {
cachedValue = null;
if (ValueChanged != null) { if (ValueChanged != null) {
ValueChanged(this, new VariableEventArgs(this)); ValueChanged(this, new VariableEventArgs(this));
} }

Loading…
Cancel
Save