Browse Source

"null" value survives Continue

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5306 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
David Srbecký 17 years ago
parent
commit
602dc8c4dc
  1. 1
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Utils/DebuggerHelpers.cs
  2. 20
      src/AddIns/Debugger/Debugger.Core/Value.cs
  3. 15
      src/AddIns/Debugger/Debugger.Tests/Tests/StackFrame_VariablesLifetime.cs

1
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Utils/DebuggerHelpers.cs

@ -39,6 +39,7 @@ namespace Debugger.AddIn.Visualizers.Utils
/// </summary> /// </summary>
public static ulong GetObjectAddress(this Value val) public static ulong GetObjectAddress(this Value val)
{ {
if (val.IsNull) return 0;
ICorDebugReferenceValue refVal = val.CorReferenceValue; ICorDebugReferenceValue refVal = val.CorReferenceValue;
return refVal.GetValue(); return refVal.GetValue();
} }

20
src/AddIns/Debugger/Debugger.Core/Value.cs

@ -30,6 +30,9 @@ namespace Debugger
PauseSession corValue_pauseSession; PauseSession corValue_pauseSession;
DebugType type; DebugType type;
// Permanently stored as convinience so that it survives Continue
bool isNull;
/// <summary> The appdomain that owns the value </summary> /// <summary> The appdomain that owns the value </summary>
public AppDomain AppDomain { public AppDomain AppDomain {
get { return appDomain; } get { return appDomain; }
@ -51,8 +54,11 @@ namespace Debugger
[Debugger.Tests.Ignore] [Debugger.Tests.Ignore]
public ICorDebugReferenceValue CorReferenceValue { public ICorDebugReferenceValue CorReferenceValue {
get { get {
if (IsNull) throw new GetValueException("Value is null");
if (!(this.CorValue is ICorDebugReferenceValue)) if (!(this.CorValue is ICorDebugReferenceValue))
throw new DebuggerException("Reference value expected"); throw new DebuggerException("Reference value expected");
return (ICorDebugReferenceValue)this.CorValue; return (ICorDebugReferenceValue)this.CorValue;
} }
} }
@ -78,6 +84,7 @@ namespace Debugger
public ICorDebugArrayValue CorArrayValue { public ICorDebugArrayValue CorArrayValue {
get { get {
if (IsNull) throw new GetValueException("Value is null"); if (IsNull) throw new GetValueException("Value is null");
if (!this.Type.IsArray) throw new DebuggerException("Value is not an array"); if (!this.Type.IsArray) throw new DebuggerException("Value is not an array");
return (ICorDebugArrayValue)this.CorReferenceValue.Dereference(); return (ICorDebugArrayValue)this.CorReferenceValue.Dereference();
@ -125,10 +132,7 @@ namespace Debugger
/// <summary> Returns true if the value is null </summary> /// <summary> Returns true if the value is null </summary>
public bool IsNull { public bool IsNull {
get { get { return isNull; }
return this.CorValue is ICorDebugReferenceValue &&
((ICorDebugReferenceValue)this.CorValue).IsNull() != 0;
}
} }
/// <summary> /// <summary>
@ -166,6 +170,8 @@ namespace Debugger
this.corValue = corValue; this.corValue = corValue;
this.corValue_pauseSession = this.Process.PauseSession; this.corValue_pauseSession = this.Process.PauseSession;
this.isNull = corValue is ICorDebugReferenceValue && ((ICorDebugReferenceValue)corValue).IsNull() != 0;
if (corValue is ICorDebugReferenceValue && if (corValue is ICorDebugReferenceValue &&
((ICorDebugReferenceValue)corValue).GetValue() == 0 && ((ICorDebugReferenceValue)corValue).GetValue() == 0 &&
((ICorDebugValue2)corValue).GetExactType() == null) ((ICorDebugValue2)corValue).GetExactType() == null)
@ -200,8 +206,8 @@ namespace Debugger
if (this.CorValue is ICorDebugHandleValue) { if (this.CorValue is ICorDebugHandleValue) {
return this; return this;
} else if (this.CorValue is ICorDebugReferenceValue) { } else if (this.CorValue is ICorDebugReferenceValue) {
if (this.CorReferenceValue.IsNull() > 0) if (this.IsNull)
return this; // ("null" expression) TODO: It isn't permanent return this; // ("null" expression) It isn't permanent
ICorDebugValue deRef = this.CorReferenceValue.Dereference(); ICorDebugValue deRef = this.CorReferenceValue.Dereference();
if (deRef is ICorDebugHeapValue2) { if (deRef is ICorDebugHeapValue2) {
return new Value(appDomain, ((ICorDebugHeapValue2)deRef).CreateHandle(CorDebugHandleType.HANDLE_STRONG)); return new Value(appDomain, ((ICorDebugHeapValue2)deRef).CreateHandle(CorDebugHandleType.HANDLE_STRONG));
@ -236,7 +242,7 @@ namespace Debugger
if (this.CorValue is ICorDebugReferenceValue) { if (this.CorValue is ICorDebugReferenceValue) {
if (!(newCorValue is ICorDebugReferenceValue)) if (!(newCorValue is ICorDebugReferenceValue))
newCorValue = newValue.Box().CorValue; newCorValue = newValue.Box().CorValue;
this.CorReferenceValue.SetValue(((ICorDebugReferenceValue)newCorValue).GetValue()); ((ICorDebugReferenceValue)this.CorValue).SetValue(((ICorDebugReferenceValue)newCorValue).GetValue());
} else { } else {
this.CorGenericValue.SetRawValue(newValue.CorGenericValue.GetRawValue()); this.CorGenericValue.SetRawValue(newValue.CorGenericValue.GetRawValue());
} }

15
src/AddIns/Debugger/Debugger.Tests/Tests/StackFrame_VariablesLifetime.cs

@ -122,7 +122,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />
@ -131,7 +130,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />
@ -140,7 +138,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />
@ -156,7 +153,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />
@ -165,7 +161,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />
@ -174,7 +169,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />
@ -183,7 +177,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />
@ -193,7 +186,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />
@ -202,7 +194,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />
@ -211,7 +202,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />
@ -220,7 +210,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />
@ -236,7 +225,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />
@ -245,7 +233,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />
@ -254,7 +241,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />
@ -263,7 +249,6 @@ namespace Debugger.Tests {
<Value <Value
AsString="{Exception: Value is no longer valid}" AsString="{Exception: Value is no longer valid}"
IsInvalid="True" IsInvalid="True"
IsNull="{Exception: Value is no longer valid}"
IsReference="{Exception: Value is no longer valid}" IsReference="{Exception: Value is no longer valid}"
PrimitiveValue="{Exception: Value is no longer valid}" PrimitiveValue="{Exception: Value is no longer valid}"
Type="System.Int32" /> Type="System.Int32" />

Loading…
Cancel
Save