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
throw new GetValueException("Invalid parameter count"); throw new GetValueException("Invalid parameter count");
} }
if (thisValue != null) { if (thisValue != null) {
if (!(thisValue.IsObject)) { // if (!(thisValue.IsObject)) // eg Can evaluate on array
throw new GetValueException("Can not evaluate on a value which is not an object");
}
if (!method.DeclaringType.IsInstanceOfType(thisValue)) { if (!method.DeclaringType.IsInstanceOfType(thisValue)) {
throw new GetValueException( throw new GetValueException(
"Can not evaluate because the object is not of proper type. " + "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
/// </summary> /// </summary>
public DebugType BaseType { public DebugType BaseType {
get { 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; ICorDebugType baseType = corType.Base;
if (baseType != null) { if (baseType != null) {
return Create(process, baseType); return Create(process, baseType);

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

@ -43,9 +43,7 @@ namespace Debugger
if (objectInstance.IsNull) { if (objectInstance.IsNull) {
throw new GetValueException("Null reference"); throw new GetValueException("Null reference");
} }
if (!objectInstance.IsObject) { //if (!objectInstance.IsObject) // eg Array.Length can be called
throw new GetValueException("Target object is not class or value type");
}
if (!memberInfo.DeclaringType.IsInstanceOfType(objectInstance)) { if (!memberInfo.DeclaringType.IsInstanceOfType(objectInstance)) {
throw new GetValueException("Object is not of type " + memberInfo.DeclaringType.FullName); throw new GetValueException("Object is not of type " + memberInfo.DeclaringType.FullName);
} }
@ -238,9 +236,8 @@ namespace Debugger
/// <summary> Invoke the ToString() method </summary> /// <summary> Invoke the ToString() method </summary>
public string InvokeToString() public string InvokeToString()
{ {
if (!IsObject) { if (IsPrimitive) return AsString;
throw new DebuggerException("ToString can be only invoked on object"); // if (!IsObject) // Can invoke on primitives
}
return Eval.InvokeMethod(Process, typeof(object), "ToString", this, new Value[] {}).AsString; 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 {
ObjectDump("array", array); ObjectDump("array", array);
ObjectDump("array elements", array.GetArrayElements()); ObjectDump("array elements", array.GetArrayElements());
ObjectDump("type", array.Type); ObjectDump("type", array.Type);
ObjectDump("array.Length", array.GetMemberValue("Length"));
EndTest(); EndTest();
} }
@ -146,7 +147,31 @@ namespace Debugger.Tests {
</Item> </Item>
</array_elements> </array_elements>
<type Type="DebugType" ToString="System.Int32[]"> <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> <FullName>System.Int32[]</FullName>
<HasElementType>True</HasElementType> <HasElementType>True</HasElementType>
<IsArray>True</IsArray> <IsArray>True</IsArray>
@ -158,6 +183,21 @@ namespace Debugger.Tests {
<ManagedType>System.Array</ManagedType> <ManagedType>System.Array</ManagedType>
<Module exception="The type is not a class or value type." /> <Module exception="The type is not a class or value type." />
</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 /> <ProcessExited />
</Test> </Test>
</DebuggerTests> </DebuggerTests>

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

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

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

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

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

@ -36,6 +36,10 @@ namespace Debugger.Tests {
StartTest("PrimitiveValue.cs"); StartTest("PrimitiveValue.cs");
ObjectDump("locals", process.SelectedStackFrame.GetLocalVariableValues()); 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(); EndTest();
} }
@ -66,7 +70,19 @@ namespace Debugger.Tests {
<IsPrimitive>True</IsPrimitive> <IsPrimitive>True</IsPrimitive>
<PrimitiveValue>True</PrimitiveValue> <PrimitiveValue>True</PrimitiveValue>
<Type Type="DebugType" ToString="System.Boolean"> <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> <FullName>System.Boolean</FullName>
<HasElementType>False</HasElementType> <HasElementType>False</HasElementType>
<IsArray>False</IsArray> <IsArray>False</IsArray>
@ -93,7 +109,19 @@ namespace Debugger.Tests {
<IsPrimitive>True</IsPrimitive> <IsPrimitive>True</IsPrimitive>
<PrimitiveValue>5</PrimitiveValue> <PrimitiveValue>5</PrimitiveValue>
<Type Type="DebugType" ToString="System.Int32"> <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> <FullName>System.Int32</FullName>
<HasElementType>False</HasElementType> <HasElementType>False</HasElementType>
<IsArray>False</IsArray> <IsArray>False</IsArray>
@ -120,7 +148,19 @@ namespace Debugger.Tests {
<IsPrimitive>True</IsPrimitive> <IsPrimitive>True</IsPrimitive>
<PrimitiveValue>five</PrimitiveValue> <PrimitiveValue>five</PrimitiveValue>
<Type Type="DebugType" ToString="System.String"> <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> <FullName>System.String</FullName>
<HasElementType>False</HasElementType> <HasElementType>False</HasElementType>
<IsArray>False</IsArray> <IsArray>False</IsArray>
@ -147,7 +187,19 @@ namespace Debugger.Tests {
<IsPrimitive>True</IsPrimitive> <IsPrimitive>True</IsPrimitive>
<PrimitiveValue>5.5</PrimitiveValue> <PrimitiveValue>5.5</PrimitiveValue>
<Type Type="DebugType" ToString="System.Double"> <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> <FullName>System.Double</FullName>
<HasElementType>False</HasElementType> <HasElementType>False</HasElementType>
<IsArray>False</IsArray> <IsArray>False</IsArray>
@ -161,6 +213,9 @@ namespace Debugger.Tests {
</Type> </Type>
</Item> </Item>
</locals> </locals>
<b_as_string>True</b_as_string>
<i_as_string>5</i_as_string>
<s_as_string>five</s_as_string>
<ProcessExited /> <ProcessExited />
</Test> </Test>
</DebuggerTests> </DebuggerTests>

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

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

Loading…
Cancel
Save