Browse Source

Lazy getting of function arguments and local variables

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@830 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
41b3368ee2
  1. 16
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  2. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs
  3. 29
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs
  4. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs

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

@ -456,7 +456,11 @@ namespace Debugger
public Variable GetArgumentVariable(int index) public Variable GetArgumentVariable(int index)
{ {
return new Variable(debugger, GetArgumentValue(index), GetParameterName(index)); return new Variable(debugger,
GetParameterName(index),
delegate {
return Value.CreateValue(debugger, GetArgumentValue(index));
});
} }
public IEnumerable<Variable> ArgumentVariables { public IEnumerable<Variable> ArgumentVariables {
@ -515,9 +519,13 @@ namespace Debugger
Variable GetLocalVariable(ISymbolVariable symVar) Variable GetLocalVariable(ISymbolVariable symVar)
{ {
ICorDebugValue runtimeVar; return new Variable(debugger,
CorILFrame.GetLocalVariable((uint)symVar.AddressField1, out runtimeVar); symVar.Name,
return new Variable(debugger, runtimeVar, symVar.Name); delegate {
ICorDebugValue corValue;
CorILFrame.GetLocalVariable((uint)symVar.AddressField1, out corValue);
return Value.CreateValue(debugger, corValue);
});
} }
} }
} }

3
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs

@ -254,7 +254,7 @@ namespace Debugger
if (skipCount < 0) throw new ArgumentException("Chain index too big", "firstChainIndex"); if (skipCount < 0) throw new ArgumentException("Chain index too big", "firstChainIndex");
corChainEnum.Skip((uint)skipCount); corChainEnum.Skip((uint)skipCount);
chainIndex -= (uint)skipCount; chainIndex -= (uint)skipCount;
firstChainIndex = chainIndex; firstChainIndex = chainIndex - 1;
} }
while (true) { while (true) {
@ -282,7 +282,6 @@ namespace Debugger
if (skipCount < 0) throw new ArgumentException("Frame index too big", "firstFrameIndex"); if (skipCount < 0) throw new ArgumentException("Frame index too big", "firstFrameIndex");
corFrameEnum.Skip((uint)skipCount); corFrameEnum.Skip((uint)skipCount);
frameIndex -= (uint)skipCount; frameIndex -= (uint)skipCount;
firstFrameIndex = frameIndex;
} }
while (true) { while (true) {

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

@ -11,6 +11,8 @@ using Debugger.Interop.CorDebug;
namespace Debugger namespace Debugger
{ {
public delegate Value ValueUpdatingEventHandler();
public class Variable: RemotingObjectBase public class Variable: RemotingObjectBase
{ {
protected NDebugger debugger; protected NDebugger debugger;
@ -19,6 +21,8 @@ namespace Debugger
Value val; Value val;
VariableCollection subVariables; VariableCollection subVariables;
event ValueUpdatingEventHandler updating;
public event EventHandler<VariableEventArgs> ValueChanged; public event EventHandler<VariableEventArgs> ValueChanged;
public event EventHandler<VariableCollectionEventArgs> ValueRemovedFromCollection; public event EventHandler<VariableCollectionEventArgs> ValueRemovedFromCollection;
@ -40,6 +44,9 @@ namespace Debugger
public Value Value { public Value Value {
get { get {
Value v = GetValue(); Value v = GetValue();
if (v == null) {
return new UnavailableValue(debugger);
}
if (v.IsExpired) { if (v.IsExpired) {
return new UnavailableValue(debugger, "The value has expired"); return new UnavailableValue(debugger, "The value has expired");
} else { } else {
@ -55,6 +62,9 @@ namespace Debugger
protected virtual Value GetValue() protected virtual Value GetValue()
{ {
if ((val == null || val.IsExpired) && updating != null) {
val = updating();
}
return val; return val;
} }
@ -97,16 +107,29 @@ namespace Debugger
} }
} }
public Variable(NDebugger debugger, ICorDebugValue corValue, string name):this(Value.CreateValue(debugger, corValue), name) public Variable(NDebugger debugger, ICorDebugValue corValue, string name):this(debugger, Value.CreateValue(debugger, corValue), name, null)
{ {
} }
public Variable(Value val, string name) public Variable(NDebugger debugger, string name, ValueUpdatingEventHandler updating):this(debugger, null, name, updating)
{ {
this.debugger = val.Debugger;
}
public Variable(Value val, string name):this(val.Debugger, val, name, null)
{
}
Variable(NDebugger debugger, Value val, string name, ValueUpdatingEventHandler updating)
{
this.debugger = debugger;
if (val != null) {
this.Value = val; this.Value = val;
}
this.name = name; this.name = name;
this.updating = updating;
this.subVariables = new VariableCollection(debugger); this.subVariables = new VariableCollection(debugger);
this.subVariables.Updating += OnSubVariablesUpdating; this.subVariables.Updating += OnSubVariablesUpdating;
} }

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs

@ -159,14 +159,14 @@ namespace Debugger
if (this.Contains(newVariable.Name)) { if (this.Contains(newVariable.Name)) {
Variable oldVariable = this[newVariable.Name]; Variable oldVariable = this[newVariable.Name];
// Update existing variable // Update existing variable
if (oldVariable.Value is ObjectValue && newVariable.Value is ObjectValue && debugger.PausedReason == PausedReason.AllEvalsComplete) { /*if (oldVariable.Value is ObjectValue && newVariable.Value is ObjectValue && debugger.PausedReason == PausedReason.AllEvalsComplete) {
((ObjectValue)newVariable.Value).toString = ((ObjectValue)oldVariable.Value).toString; ((ObjectValue)newVariable.Value).toString = ((ObjectValue)oldVariable.Value).toString;
} }
if (oldVariable is PropertyVariable) { if (oldVariable is PropertyVariable) {
((PropertyVariable)oldVariable).Eval = ((PropertyVariable)newVariable).Eval; ((PropertyVariable)oldVariable).Eval = ((PropertyVariable)newVariable).Eval;
} else { } else {
oldVariable.Value = newVariable.Value; oldVariable.Value = newVariable.Value;
} }*/
// Keep the variable in the list // Keep the variable in the list
toBeRemoved.Remove(oldVariable); toBeRemoved.Remove(oldVariable);
} else { } else {

Loading…
Cancel
Save