Browse Source

Fixed SD2-1117: Local variables pad throws exception in debugger.

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

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

@ -234,24 +234,32 @@ namespace Debugger
internal static ICorDebugValue DereferenceUnbox(ICorDebugValue corValue) internal static ICorDebugValue DereferenceUnbox(ICorDebugValue corValue)
{ {
if (corValue.Is<ICorDebugReferenceValue>()) { // Method arguments can be passed 'by ref'
int isNull = corValue.CastTo<ICorDebugReferenceValue>().IsNull; if (corValue.Type == (uint)CorElementType.BYREF) {
if (isNull == 0) { corValue = corValue.CastTo<ICorDebugReferenceValue>().Dereference();
ICorDebugValue dereferencedValue; }
// Pointers may be used in 'unsafe' code - CorElementType.PTR
// Classes need to be dereferenced
while (corValue.Is<ICorDebugReferenceValue>()) {
ICorDebugReferenceValue refValue = corValue.CastTo<ICorDebugReferenceValue>();
if (refValue.IsNull != 0) {
return null; // Reference is null
} else {
try { try {
dereferencedValue = (corValue.CastTo<ICorDebugReferenceValue>()).Dereference(); corValue = refValue.Dereference();
// TODO: Investigate: Must not acutally be null
// eg. Assembly.AssemblyHandle See SD2-1117
if (corValue == null) return null; // Dereference() returned null
} catch { } catch {
// Error during dereferencing return null; // Error during dereferencing
return null;
} }
return DereferenceUnbox(dereferencedValue); // Try again
} else {
return null;
} }
} }
// Unbox value types
if (corValue.Is<ICorDebugBoxValue>()) { if (corValue.Is<ICorDebugBoxValue>()) {
return DereferenceUnbox(corValue.CastTo<ICorDebugBoxValue>().Object.CastTo<ICorDebugValue>()); // Try again corValue = corValue.CastTo<ICorDebugBoxValue>().Object.CastTo<ICorDebugValue>();
} }
return corValue; return corValue;
@ -360,8 +368,13 @@ namespace Debugger
more.Add(new VariableCollection("isNull", isNull.ToString())); more.Add(new VariableCollection("isNull", isNull.ToString()));
if (!isNull) { if (!isNull) {
more.Add(new VariableCollection("address", refValue.Value.ToString("X"))); more.Add(new VariableCollection("address", refValue.Value.ToString("X")));
VariableCollection deRef = GetDebugInfo(refValue.Dereference()); if (refValue.Dereference() != null) {
more.Add(new VariableCollection("dereferenced", deRef.Value, deRef.SubCollections, deRef.Items)); VariableCollection deRef = GetDebugInfo(refValue.Dereference());
more.Add(new VariableCollection("dereferenced", deRef.Value, deRef.SubCollections, deRef.Items));
} else {
more.Add(new VariableCollection("dereferenced", "N/A", null, null));
}
} }
items.Add(new VariableCollection("ICorDebugReferenceValue", "", more, null)); items.Add(new VariableCollection("ICorDebugReferenceValue", "", more, null));
} }

Loading…
Cancel
Save