Browse Source

Fixed signature reading for fields;

Unit test for signature reading (still partially failing)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4524 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 17 years ago
parent
commit
14bf49761a
  1. 17
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs
  2. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/FieldInfo.cs
  3. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Mono.Cecil/Mono.Cecil.Signatures/SignatureReader.cs
  4. 180
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugTypes.cs
  5. 10
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Metadata.cs

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

@ -346,23 +346,16 @@ namespace Debugger.MetaData @@ -346,23 +346,16 @@ namespace Debugger.MetaData
if (tokenType == CorTokenType.TypeDef || tokenType == CorTokenType.TypeRef) {
return Create(module.AppDomain, GetCorClass(module, token));
} else if (tokenType == CorTokenType.TypeSpec) {
Blob typeSpecBlob = module.MetaData.GetTypeSpecFromToken(token);
return Create(module, typeSpecBlob.GetData(), declaringType);
byte[] typeSpecBlob = module.MetaData.GetTypeSpecFromToken(token).GetData();
SignatureReader sigReader = new SignatureReader(typeSpecBlob);
int start;
SigType sigType = sigReader.ReadType(typeSpecBlob, 0, out start);
return Create(module, sigType, declaringType);
} else {
throw new DebuggerException("Unknown token type");
}
}
/// <param name="signatureContext">Type definition to use to resolve numbered generic references</param>
public static DebugType Create(Module module, byte[] sig, DebugType declaringType)
{
SignatureReader sigReader = new SignatureReader(sig);
int start;
SigType sigType = sigReader.ReadType(sig, 0, out start);
return Create(module, sigType, declaringType);
}
internal static DebugType Create(Module module, SigType sigType, DebugType declaringType)
{
System.Type sysType = CorElementTypeToManagedType((CorElementType)(uint)sigType.ElementType);

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/FieldInfo.cs

@ -65,7 +65,9 @@ namespace Debugger.MetaData @@ -65,7 +65,9 @@ namespace Debugger.MetaData
/// <summary> The type of the field</summary>
public DebugType Type {
get {
return DebugType.Create(this.Module, fieldProps.SigBlob.GetData(), this.DeclaringType);
SignatureReader sigReader = new SignatureReader(fieldProps.SigBlob.GetData());
FieldSig fieldSig = sigReader.GetFieldSig(0);
return DebugType.Create(this.Module, fieldSig.Type, this.DeclaringType);
}
}

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Mono.Cecil/Mono.Cecil.Signatures/SignatureReader.cs

@ -240,9 +240,9 @@ namespace Mono.Cecil.Signatures { @@ -240,9 +240,9 @@ namespace Mono.Cecil.Signatures {
public override void VisitFieldSig (FieldSig field)
{
int start;
Utilities.ReadCompressedInteger (m_blobData, (int) field.BlobIndex, out start);
field.CallingConvention = m_blobData [start];
int start = 0;
//Utilities.ReadCompressedInteger (m_blobData, (int) field.BlobIndex, out start);
//field.CallingConvention = m_blobData [start];
field.Field = (field.CallingConvention & 0x6) != 0;
field.CustomMods = ReadCustomMods (m_blobData, start + 1, out start);
field.Type = ReadType (m_blobData, start, out start);

180
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugTypes.cs

@ -12,9 +12,24 @@ namespace Debugger.Tests.TestPrograms @@ -12,9 +12,24 @@ namespace Debugger.Tests.TestPrograms
{
public class DebugTypes
{
public class MyClass
public unsafe class MyClass
{
public delegate int Add(byte b1, byte b2);
public int i;
public bool b;
public char c;
public IntPtr intPtr;
public int* pInt;
public int[] intArray;
public int[,] intMultiArray;
public List<int> intList;
public List<int>[] intListArray;
public Point point;
public MyClass myClass;
public Add fnPtr;
public T Foo<T>(ref T tRef, T[] tArray) { return tRef; }
}
public interface MyInterface<K, V, T>
@ -40,6 +55,7 @@ namespace Debugger.Tests.TestPrograms @@ -40,6 +55,7 @@ namespace Debugger.Tests.TestPrograms
object nullObject = null;
string nullString = null;
object obj = new Object();
MyClass myClass = new MyClass();
int loc = 42;
int locByRef = 43;
int* locPtr = &loc;
@ -90,6 +106,7 @@ namespace Debugger.Tests { @@ -90,6 +106,7 @@ namespace Debugger.Tests {
"DebugType.ElementType"
);
StartTest("DebugTypes.cs");
ObjectDump("MyClassMemberts", process.SelectedStackFrame.GetLocalVariableValue("myClass").Type.GetMembers());
ObjectDump("LocalVariables", process.SelectedStackFrame.GetLocalVariableValues());
process.Continue();
ObjectDump("Arguments", process.SelectedStackFrame.GetArgumentValues());
@ -107,10 +124,143 @@ namespace Debugger.Tests { @@ -107,10 +124,143 @@ namespace Debugger.Tests {
<ProcessStarted />
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
<ModuleLoaded>DebugTypes.exe (Has symbols)</ModuleLoaded>
<DebuggingPaused>Break DebugTypes.cs:59,4-59,40</DebuggingPaused>
<DebuggingPaused>Break DebugTypes.cs:75,4-75,40</DebuggingPaused>
<MyClassMemberts
Capacity="16"
Count="14">
<Item>
<FieldInfo
DeclaringType="MyClass"
FullName="MyClass.i"
IsPublic="True"
Module="DebugTypes.exe"
Name="i"
Type="System.Int32" />
</Item>
<Item>
<FieldInfo
DeclaringType="MyClass"
FullName="MyClass.b"
IsPublic="True"
Module="DebugTypes.exe"
Name="b"
Type="System.Boolean" />
</Item>
<Item>
<FieldInfo
DeclaringType="MyClass"
FullName="MyClass.c"
IsPublic="True"
Module="DebugTypes.exe"
Name="c"
Type="System.Char" />
</Item>
<Item>
<FieldInfo
DeclaringType="MyClass"
FullName="MyClass.intPtr"
IsPublic="True"
Module="DebugTypes.exe"
Name="intPtr"
Type="System.IntPtr" />
</Item>
<Item>
<FieldInfo
DeclaringType="MyClass"
FullName="MyClass.pInt"
IsPublic="True"
Module="DebugTypes.exe"
Name="pInt"
Type="{Exception: Ptr}" />
</Item>
<Item>
<FieldInfo
DeclaringType="MyClass"
FullName="MyClass.intArray"
IsPublic="True"
Module="DebugTypes.exe"
Name="intArray"
Type="{Exception: SzArray}" />
</Item>
<Item>
<FieldInfo
DeclaringType="MyClass"
FullName="MyClass.intMultiArray"
IsPublic="True"
Module="DebugTypes.exe"
Name="intMultiArray"
Type="{Exception: Array}" />
</Item>
<Item>
<FieldInfo
DeclaringType="MyClass"
FullName="MyClass.intList"
IsPublic="True"
Module="DebugTypes.exe"
Name="intList"
Type="System.Collections.Generic.List&lt;System.Int32&gt;" />
</Item>
<Item>
<FieldInfo
DeclaringType="MyClass"
FullName="MyClass.intListArray"
IsPublic="True"
Module="DebugTypes.exe"
Name="intListArray"
Type="{Exception: SzArray}" />
</Item>
<Item>
<FieldInfo
DeclaringType="MyClass"
FullName="MyClass.point"
IsPublic="True"
Module="DebugTypes.exe"
Name="point"
Type="Point" />
</Item>
<Item>
<FieldInfo
DeclaringType="MyClass"
FullName="MyClass.myClass"
IsPublic="True"
Module="DebugTypes.exe"
Name="myClass"
Type="MyClass" />
</Item>
<Item>
<FieldInfo
DeclaringType="MyClass"
FullName="MyClass.fnPtr"
IsPublic="True"
Module="DebugTypes.exe"
Name="fnPtr"
Type="Add" />
</Item>
<Item>
<MethodInfo
DeclaringType="MyClass"
FullName="MyClass.Foo"
IsPublic="True"
Module="DebugTypes.exe"
Name="Foo"
ParameterCount="2"
ParameterTypes="{Exception: SzArray}"
ReturnType="System.Object" />
</Item>
<Item>
<MethodInfo
DeclaringType="MyClass"
FullName="MyClass..ctor"
IsPublic="True"
IsSpecialName="True"
Module="DebugTypes.exe"
Name=".ctor"
StepOver="True" />
</Item>
</MyClassMemberts>
<LocalVariables
Capacity="32"
Count="19">
Count="20">
<Item>
<Value
ArrayDimensions="{Exception: Value is null}"
@ -199,6 +349,28 @@ namespace Debugger.Tests { @@ -199,6 +349,28 @@ namespace Debugger.Tests {
</Type>
</Value>
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="{MyClass}"
Expression="myClass"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="MyClass">
<Type>
<DebugType
BaseType="System.Object"
FullName="MyClass"
Kind="Class"
Module="DebugTypes.exe"
Name="MyClass">
<ElementType>null</ElementType>
</DebugType>
</Type>
</Value>
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
@ -603,7 +775,7 @@ namespace Debugger.Tests { @@ -603,7 +775,7 @@ namespace Debugger.Tests {
</Value>
</Item>
</LocalVariables>
<DebuggingPaused>Break DebugTypes.cs:76,4-76,40</DebuggingPaused>
<DebuggingPaused>Break DebugTypes.cs:92,4-92,40</DebuggingPaused>
<Arguments
Capacity="16"
Count="15">

10
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Metadata.cs

@ -87,7 +87,7 @@ namespace Debugger.Tests { @@ -87,7 +87,7 @@ namespace Debugger.Tests {
IsPrivate="True"
Module="Metadata.exe"
Name="privateField"
Type="System.Int16" />
Type="System.Int32" />
</Item>
<Item>
<FieldInfo
@ -96,7 +96,7 @@ namespace Debugger.Tests { @@ -96,7 +96,7 @@ namespace Debugger.Tests {
IsPublic="True"
Module="Metadata.exe"
Name="publicField"
Type="System.Int16" />
Type="System.Int32" />
</Item>
<Item>
<FieldInfo
@ -105,7 +105,7 @@ namespace Debugger.Tests { @@ -105,7 +105,7 @@ namespace Debugger.Tests {
IsProtected="True"
Module="Metadata.exe"
Name="protectedField"
Type="System.Int16" />
Type="System.Int32" />
</Item>
<Item>
<FieldInfo
@ -114,7 +114,7 @@ namespace Debugger.Tests { @@ -114,7 +114,7 @@ namespace Debugger.Tests {
IsInternal="True"
Module="Metadata.exe"
Name="internalField"
Type="System.Int16" />
Type="System.Int32" />
</Item>
<Item>
<FieldInfo
@ -124,7 +124,7 @@ namespace Debugger.Tests { @@ -124,7 +124,7 @@ namespace Debugger.Tests {
IsStatic="True"
Module="Metadata.exe"
Name="staticField"
Type="System.Int16" />
Type="System.Int32" />
</Item>
<Item>
<MethodInfo

Loading…
Cancel
Save