Browse Source

Working on PersistentValue

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1550 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 19 years ago
parent
commit
c2400a429e
  1. 92
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PersistentValue.cs
  2. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs

92
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PersistentValue.cs

@ -23,21 +23,17 @@ namespace Debugger @@ -23,21 +23,17 @@ namespace Debugger
/// Delegate that is used to get value. This delegate may be called at any time and should never return null.
/// </summary>
public delegate Value ValueGetter();
/// <summary>
/// Delegate that is used to get value. This delegate may be called at any time and should never return null.
/// </summary>
public delegate ICorDebugValue CorValueGetter();
public delegate bool IsExpiredDelegate();
NDebugger debugger;
ValueGetter getter;
ICorDebugValue corValue;
// ICorDebugHandleValue can be used to get corValue back after Continue()
public ICorDebugHandleValue corHandleValue;
PauseSession pauseSessionAtCreation;
DebugeeState debugeeStateAtCreation;
CorValueGetter corValueGetter;
ValueGetter valueGetter;
IsExpiredDelegate isExpired;
public ICorDebugValue initValue;
public NDebugger Debugger {
get {
@ -45,37 +41,25 @@ namespace Debugger @@ -45,37 +41,25 @@ namespace Debugger
}
}
public Value Value {
public ICorDebugValue CorValue {
get {
return getter();
return corValueGetter();
}
}
public bool IsExpired {
public Value Value {
get {
if (corHandleValue == null) {
return pauseSessionAtCreation != debugger.PauseSession;
} else {
return debugeeStateAtCreation != debugger.DebugeeState;
try {
return valueGetter();
} catch (CannotGetValueException e) {
return new UnavailableValue(debugger, e.Message);
}
}
}
public ICorDebugValue CorValue {
public bool IsExpired {
get {
if (this.IsExpired) throw new DebuggerException("CorValue has expired");
if (pauseSessionAtCreation == debugger.PauseSession) {
return corValue;
} else {
if (corHandleValue == null) {
throw new DebuggerException("CorValue has expired");
} else {
corValue = PersistentValue.DereferenceUnbox(corHandleValue.As<ICorDebugValue>());
pauseSessionAtCreation = debugger.PauseSession;
return corValue;
}
}
return isExpired();
}
}
@ -83,44 +67,46 @@ namespace Debugger @@ -83,44 +67,46 @@ namespace Debugger
get {
if (this.IsExpired) throw new DebuggerException("CorValue has expired");
if (corHandleValue != null) return corHandleValue;
ICorDebugHeapValue2 heapValue = this.CorValue.As<ICorDebugHeapValue2>();
if (heapValue == null) { // TODO: Investigate - hmmm, value types are not at heap?
return null;
if (this.initValue != null && this.initValue.Is<ICorDebugHandleValue>()) {
return this.initValue.As<ICorDebugHandleValue>();
} else if (this.initValue != null && this.initValue.Is<ICorDebugHeapValue2>()) {
return this.initValue.As<ICorDebugHeapValue2>().CreateHandle(CorDebugHandleType.HANDLE_WEAK_TRACK_RESURRECTION);
} else {
return heapValue.CreateHandle(CorDebugHandleType.HANDLE_WEAK_TRACK_RESURRECTION);
return null; // Value type
}
}
}
public PersistentValue(ValueGetter getter)
{
this.getter = getter;
this.valueGetter = getter;
}
public PersistentValue(NDebugger debugger, ICorDebugValue corValue)
{
this.debugger = debugger;
if (corValue != null) {
this.corHandleValue = corValue.As<ICorDebugHandleValue>();
this.corValue = PersistentValue.DereferenceUnbox(corValue);
}
this.pauseSessionAtCreation = debugger.PauseSession;
this.debugeeStateAtCreation = debugger.DebugeeState;
this.getter = delegate { return CreateValue(debugger, corValue); };
this.initValue = corValue;
PauseSession pauseSessionAtCreation = debugger.PauseSession;
DebugeeState debugeeStateAtCreation = debugger.DebugeeState;
this.corValueGetter = delegate {
if (this.IsExpired) throw new DebuggerException("CorValue has expired");
return PersistentValue.DereferenceUnbox(this.initValue);
};
this.isExpired = delegate {
if (this.initValue != null && this.initValue.Is<ICorDebugHandleValue>()) {
return debugeeStateAtCreation != debugger.DebugeeState;
} else {
return pauseSessionAtCreation != debugger.PauseSession;
}
};
this.valueGetter = delegate { return CreateValue(debugger, corValue); };
}
public PersistentValue(NDebugger debugger, CorValueGetter corValueGetter)
{
this.getter = delegate {
try {
return CreateValue(debugger, corValueGetter());
} catch (CannotGetValueException e) {
return new UnavailableValue(debugger, e.Message);
}
};
this.valueGetter = delegate { return CreateValue(debugger, corValueGetter()); };
}
internal static ICorDebugValue DereferenceUnbox(ICorDebugValue corValue)

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

@ -28,7 +28,7 @@ namespace Debugger @@ -28,7 +28,7 @@ namespace Debugger
protected ICorDebugHandleValue corHandleValue {
get {
return pValue.corHandleValue;
return pValue.initValue.As<ICorDebugHandleValue>();
}
}

Loading…
Cancel
Save