Browse Source

Fixed base type for arrays and for primitive values. Updated tests for it.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2919 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 18 years ago
parent
commit
2c00845a93
  1. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Eval.cs
  2. 8
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs
  3. 9
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs
  4. 42
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ArrayValue.cs
  5. 4
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionArgumentVariables.cs
  6. 4
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLocalVariables.cs
  7. 63
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/PrimitiveValue.cs
  8. 2
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/StackOverflow.cs

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Eval.cs

@ -206,9 +206,7 @@ namespace Debugger @@ -206,9 +206,7 @@ namespace Debugger
throw new GetValueException("Invalid parameter count");
}
if (thisValue != null) {
if (!(thisValue.IsObject)) {
throw new GetValueException("Can not evaluate on a value which is not an object");
}
// if (!(thisValue.IsObject)) // eg Can evaluate on array
if (!method.DeclaringType.IsInstanceOfType(thisValue)) {
throw new GetValueException(
"Can not evaluate because the object is not of proper type. " +

8
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs

@ -217,6 +217,14 @@ namespace Debugger.MetaData @@ -217,6 +217,14 @@ namespace Debugger.MetaData
/// </summary>
public DebugType BaseType {
get {
// corType.Base does not work for arrays
if (this.IsArray) {
return DebugType.GetType(this.Process, "System.Array");
}
// corType.Base does not work for primitive types
if (this.IsPrimitive) {
return DebugType.GetType(this.Process, "System.Object");
}
ICorDebugType baseType = corType.Base;
if (baseType != null) {
return Create(process, baseType);

9
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs

@ -43,9 +43,7 @@ namespace Debugger @@ -43,9 +43,7 @@ namespace Debugger
if (objectInstance.IsNull) {
throw new GetValueException("Null reference");
}
if (!objectInstance.IsObject) {
throw new GetValueException("Target object is not class or value type");
}
//if (!objectInstance.IsObject) // eg Array.Length can be called
if (!memberInfo.DeclaringType.IsInstanceOfType(objectInstance)) {
throw new GetValueException("Object is not of type " + memberInfo.DeclaringType.FullName);
}
@ -238,9 +236,8 @@ namespace Debugger @@ -238,9 +236,8 @@ namespace Debugger
/// <summary> Invoke the ToString() method </summary>
public string InvokeToString()
{
if (!IsObject) {
throw new DebuggerException("ToString can be only invoked on object");
}
if (IsPrimitive) return AsString;
// if (!IsObject) // Can invoke on primitives
return Eval.InvokeMethod(Process, typeof(object), "ToString", this, new Value[] {}).AsString;
}

42
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ArrayValue.cs

@ -38,6 +38,7 @@ namespace Debugger.Tests { @@ -38,6 +38,7 @@ namespace Debugger.Tests {
ObjectDump("array", array);
ObjectDump("array elements", array.GetArrayElements());
ObjectDump("type", array.Type);
ObjectDump("array.Length", array.GetMemberValue("Length"));
EndTest();
}
@ -146,7 +147,31 @@ namespace Debugger.Tests { @@ -146,7 +147,31 @@ namespace Debugger.Tests {
</Item>
</array_elements>
<type Type="DebugType" ToString="System.Int32[]">
<BaseType exception="Value does not fall within the expected range." />
<BaseType Type="DebugType" ToString="System.Array">
<BaseType Type="DebugType" ToString="System.Object">
<BaseType>null</BaseType>
<FullName>System.Object</FullName>
<HasElementType>False</HasElementType>
<IsArray>False</IsArray>
<IsClass>True</IsClass>
<IsGenericType>False</IsGenericType>
<IsInteger>False</IsInteger>
<IsPrimitive>False</IsPrimitive>
<IsValueType>False</IsValueType>
<ManagedType>null</ManagedType>
<Module>mscorlib.dll</Module>
</BaseType>
<FullName>System.Array</FullName>
<HasElementType>False</HasElementType>
<IsArray>False</IsArray>
<IsClass>True</IsClass>
<IsGenericType>False</IsGenericType>
<IsInteger>False</IsInteger>
<IsPrimitive>False</IsPrimitive>
<IsValueType>False</IsValueType>
<ManagedType>null</ManagedType>
<Module>mscorlib.dll</Module>
</BaseType>
<FullName>System.Int32[]</FullName>
<HasElementType>True</HasElementType>
<IsArray>True</IsArray>
@ -158,6 +183,21 @@ namespace Debugger.Tests { @@ -158,6 +183,21 @@ namespace Debugger.Tests {
<ManagedType>System.Array</ManagedType>
<Module exception="The type is not a class or value type." />
</type>
<array.Length Type="Value" ToString="array.Length = 5">
<ArrayDimensions exception="Value is not an array" />
<ArrayLenght exception="Value is not an array" />
<ArrayRank exception="Value is not an array" />
<AsString>5</AsString>
<Expression>array.Length</Expression>
<HasExpired>False</HasExpired>
<IsArray>False</IsArray>
<IsInteger>True</IsInteger>
<IsNull>False</IsNull>
<IsObject>False</IsObject>
<IsPrimitive>True</IsPrimitive>
<PrimitiveValue>5</PrimitiveValue>
<Type>System.Int32</Type>
</array.Length>
<ProcessExited />
</Test>
</DebuggerTests>

4
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionArgumentVariables.cs

@ -124,11 +124,11 @@ namespace Debugger.Tests { @@ -124,11 +124,11 @@ namespace Debugger.Tests {
<PrimitiveValue>A</PrimitiveValue>
<Type>System.String</Type>
</Item>
<Item Type="Value" ToString="s_null = &lt;null&gt;">
<Item Type="Value" ToString="s_null = null">
<ArrayDimensions exception="Value is not an array" />
<ArrayLenght exception="Value is not an array" />
<ArrayRank exception="Value is not an array" />
<AsString>&lt;null&gt;</AsString>
<AsString>null</AsString>
<Expression>s_null</Expression>
<HasExpired>False</HasExpired>
<IsArray>False</IsArray>

4
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLocalVariables.cs

@ -94,11 +94,11 @@ namespace Debugger.Tests { @@ -94,11 +94,11 @@ namespace Debugger.Tests {
<PrimitiveValue exception="Value is not a primitive type" />
<Type>System.String[]</Type>
</Item>
<Item Type="Value" ToString="n = &lt;null&gt;">
<Item Type="Value" ToString="n = null">
<ArrayDimensions exception="Value is not an array" />
<ArrayLenght exception="Value is not an array" />
<ArrayRank exception="Value is not an array" />
<AsString>&lt;null&gt;</AsString>
<AsString>null</AsString>
<Expression>n</Expression>
<HasExpired>False</HasExpired>
<IsArray>False</IsArray>

63
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/PrimitiveValue.cs

@ -36,6 +36,10 @@ namespace Debugger.Tests { @@ -36,6 +36,10 @@ namespace Debugger.Tests {
StartTest("PrimitiveValue.cs");
ObjectDump("locals", process.SelectedStackFrame.GetLocalVariableValues());
// Test System.Object access
ObjectDump("b as string", process.SelectedStackFrame.GetLocalVariableValue("b").InvokeToString());
ObjectDump("i as string", process.SelectedStackFrame.GetLocalVariableValue("i").InvokeToString());
ObjectDump("s as string", process.SelectedStackFrame.GetLocalVariableValue("s").InvokeToString());
EndTest();
}
@ -66,7 +70,19 @@ namespace Debugger.Tests { @@ -66,7 +70,19 @@ namespace Debugger.Tests {
<IsPrimitive>True</IsPrimitive>
<PrimitiveValue>True</PrimitiveValue>
<Type Type="DebugType" ToString="System.Boolean">
<BaseType exception="Value does not fall within the expected range." />
<BaseType Type="DebugType" ToString="System.Object">
<BaseType>null</BaseType>
<FullName>System.Object</FullName>
<HasElementType>False</HasElementType>
<IsArray>False</IsArray>
<IsClass>True</IsClass>
<IsGenericType>False</IsGenericType>
<IsInteger>False</IsInteger>
<IsPrimitive>False</IsPrimitive>
<IsValueType>False</IsValueType>
<ManagedType>null</ManagedType>
<Module>mscorlib.dll</Module>
</BaseType>
<FullName>System.Boolean</FullName>
<HasElementType>False</HasElementType>
<IsArray>False</IsArray>
@ -93,7 +109,19 @@ namespace Debugger.Tests { @@ -93,7 +109,19 @@ namespace Debugger.Tests {
<IsPrimitive>True</IsPrimitive>
<PrimitiveValue>5</PrimitiveValue>
<Type Type="DebugType" ToString="System.Int32">
<BaseType exception="Value does not fall within the expected range." />
<BaseType Type="DebugType" ToString="System.Object">
<BaseType>null</BaseType>
<FullName>System.Object</FullName>
<HasElementType>False</HasElementType>
<IsArray>False</IsArray>
<IsClass>True</IsClass>
<IsGenericType>False</IsGenericType>
<IsInteger>False</IsInteger>
<IsPrimitive>False</IsPrimitive>
<IsValueType>False</IsValueType>
<ManagedType>null</ManagedType>
<Module>mscorlib.dll</Module>
</BaseType>
<FullName>System.Int32</FullName>
<HasElementType>False</HasElementType>
<IsArray>False</IsArray>
@ -120,7 +148,19 @@ namespace Debugger.Tests { @@ -120,7 +148,19 @@ namespace Debugger.Tests {
<IsPrimitive>True</IsPrimitive>
<PrimitiveValue>five</PrimitiveValue>
<Type Type="DebugType" ToString="System.String">
<BaseType exception="Value does not fall within the expected range." />
<BaseType Type="DebugType" ToString="System.Object">
<BaseType>null</BaseType>
<FullName>System.Object</FullName>
<HasElementType>False</HasElementType>
<IsArray>False</IsArray>
<IsClass>True</IsClass>
<IsGenericType>False</IsGenericType>
<IsInteger>False</IsInteger>
<IsPrimitive>False</IsPrimitive>
<IsValueType>False</IsValueType>
<ManagedType>null</ManagedType>
<Module>mscorlib.dll</Module>
</BaseType>
<FullName>System.String</FullName>
<HasElementType>False</HasElementType>
<IsArray>False</IsArray>
@ -147,7 +187,19 @@ namespace Debugger.Tests { @@ -147,7 +187,19 @@ namespace Debugger.Tests {
<IsPrimitive>True</IsPrimitive>
<PrimitiveValue>5.5</PrimitiveValue>
<Type Type="DebugType" ToString="System.Double">
<BaseType exception="Value does not fall within the expected range." />
<BaseType Type="DebugType" ToString="System.Object">
<BaseType>null</BaseType>
<FullName>System.Object</FullName>
<HasElementType>False</HasElementType>
<IsArray>False</IsArray>
<IsClass>True</IsClass>
<IsGenericType>False</IsGenericType>
<IsInteger>False</IsInteger>
<IsPrimitive>False</IsPrimitive>
<IsValueType>False</IsValueType>
<ManagedType>null</ManagedType>
<Module>mscorlib.dll</Module>
</BaseType>
<FullName>System.Double</FullName>
<HasElementType>False</HasElementType>
<IsArray>False</IsArray>
@ -161,6 +213,9 @@ namespace Debugger.Tests { @@ -161,6 +213,9 @@ namespace Debugger.Tests {
</Type>
</Item>
</locals>
<b_as_string>True</b_as_string>
<i_as_string>5</i_as_string>
<s_as_string>five</s_as_string>
<ProcessExited />
</Test>
</DebuggerTests>

2
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/StackOverflow.cs

@ -50,7 +50,7 @@ namespace Debugger.Tests { @@ -50,7 +50,7 @@ namespace Debugger.Tests {
<ModuleLoaded symbols="False">mscorlib.dll</ModuleLoaded>
<ModuleLoaded symbols="True">StackOverflow.exe</ModuleLoaded>
<DebuggingPaused>Break</DebuggingPaused>
<ExceptionThrown>&lt;null&gt;</ExceptionThrown>
<ExceptionThrown>null</ExceptionThrown>
<DebuggingPaused>Exception</DebuggingPaused>
<LastStackFrame Type="StackFrame" ToString="Debugger.Tests.TestPrograms.StackOverflow.Fun">
<ArgumentCount>1</ArgumentCount>

Loading…
Cancel
Save