Browse Source

Lazy getting of object values

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@846 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
d80a9340cc
  1. 61
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs

61
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs

@ -126,33 +126,48 @@ namespace Debugger
yield return BaseClassVariable; yield return BaseClassVariable;
} }
// Current frame is necessary to resolve context specific static values (eg. ThreadStatic) foreach(FieldProps field in metaData.EnumFields(classProps.Token)) {
ICorDebugFrame curFrame; if (field.IsStatic && field.IsLiteral) continue; // Skip field
if (debugger.CurrentThread == null || debugger.CurrentThread.LastFunction == null || debugger.CurrentThread.LastFunction.CorILFrame == null) { if (!field.IsStatic && corValue == null) continue; // Skip field
curFrame = null; FieldProps fieldCpy = field; // TODO: Why do we need this!!!!????
} else { yield return new Variable(debugger,
field.Name,
delegate {
Value updatedVal = getter();
if (this.IsEquivalentValue(updatedVal)) {
return GetValue(updatedVal, fieldCpy);
} else {
return new UnavailableValue(debugger, "Object type changed");
}
});
}
}
public override bool IsEquivalentValue(Value val)
{
ObjectValue objVal = val as ObjectValue;
return objVal != null &&
objVal.ClassToken == this.ClassToken;
}
Value GetValue(Value val, FieldProps field)
{
// Current frame is used to resolve context specific static values (eg. ThreadStatic)
ICorDebugFrame curFrame = null;
if (debugger.CurrentThread != null && debugger.CurrentThread.LastFunction != null && debugger.CurrentThread.LastFunction.CorILFrame != null) {
curFrame = debugger.CurrentThread.LastFunction.CorILFrame; curFrame = debugger.CurrentThread.LastFunction.CorILFrame;
} }
foreach(FieldProps field in metaData.EnumFields(classProps.Token)) { try {
Variable var; ICorDebugValue fieldValue;
try { if (field.IsStatic) {
ICorDebugValue fieldValue; corClass.GetStaticFieldValue(field.Token, curFrame, out fieldValue);
if (field.IsStatic) { } else {
if (field.IsLiteral) continue; // Try next field ((ICorDebugObjectValue)val.CorValue).GetFieldValue(corClass, field.Token, out fieldValue);
corClass.GetStaticFieldValue(field.Token, curFrame, out fieldValue);
} else {
if (corValue == null) continue; // Try next field
((ICorDebugObjectValue)corValue).GetFieldValue(corClass, field.Token, out fieldValue);
}
var = new Variable(debugger, fieldValue, field.Name);
} catch {
var = new Variable(new UnavailableValue(debugger), field.Name);
} }
yield return var; return Value.CreateValue(debugger, fieldValue);
} catch {
return new UnavailableValue(debugger);
} }
} }

Loading…
Cancel
Save