Browse Source

Changing Value class to work with the new metadata API.

Some bugfixes.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5108 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 17 years ago
parent
commit
33e0fbb591
  1. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  2. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/StackFrame.cs
  3. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Thread.cs
  4. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/Tests/IgnoreAttribute.cs
  5. 17
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/Tests/IgnoreOnExceptionAttribute.cs
  6. 20
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugMethodInfo.cs
  7. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugPropertyInfo.cs
  8. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs
  9. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Array.cs
  10. 22
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs
  11. 17
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Primitive.cs
  12. 61
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.cs

1
src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj

@ -90,6 +90,7 @@ @@ -90,6 +90,7 @@
<Compile Include="Src\Internal\MTA2STA.cs" />
<Compile Include="Src\Internal\Tests\ExpandAttribute.cs" />
<Compile Include="Src\Internal\Tests\IgnoreAttribute.cs" />
<Compile Include="Src\Internal\Tests\IgnoreOnExceptionAttribute.cs" />
<Compile Include="Src\Interop\CorDebug\CorDebug.cs" />
<Compile Include="Src\Interop\CorDebug\CorDebugChainReason.cs" />
<Compile Include="Src\Interop\CorDebug\CorDebugClass.cs" />

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

@ -125,7 +125,8 @@ namespace Debugger @@ -125,7 +125,8 @@ namespace Debugger
/// <summary> Returns diagnostic description of the frame </summary>
public override string ToString()
{
return this.MethodInfo.FullName;
// TODO: Use full name
return this.MethodInfo.DeclaringType.FullName + "." + this.MethodInfo.Name;
}
internal ICorDebugILFrame CorILFrame {
@ -281,6 +282,7 @@ namespace Debugger @@ -281,6 +282,7 @@ namespace Debugger
/// Gets the instance of the class asociated with the current frame.
/// That is, 'this' in C#.
/// </summary>
[Debugger.Tests.Ignore]
public Value GetThisValue()
{
return new Value(appDomain, GetThisCorValue());

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Thread.cs

@ -269,6 +269,7 @@ namespace Debugger @@ -269,6 +269,7 @@ namespace Debugger
/// <summary> Gets the whole callstack of the Thread. </summary>
/// <remarks> If the thread is in invalid state returns empty array </remarks>
[Debugger.Tests.Ignore]
public StackFrame[] GetCallstack()
{
return new List<StackFrame>(CallstackEnum).ToArray();
@ -332,6 +333,7 @@ namespace Debugger @@ -332,6 +333,7 @@ namespace Debugger
return stackFrame;
}
[Debugger.Tests.Ignore]
public string GetStackTrace()
{
return GetStackTrace("at {0} in {1}:line {2}", "at {0}");

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/Tests/IgnoreAttribute.cs

@ -9,7 +9,7 @@ using System; @@ -9,7 +9,7 @@ using System;
namespace Debugger.Tests
{
[AttributeUsage(AttributeTargets.Property)]
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
public class IgnoreAttribute: Attribute
{

17
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/Tests/IgnoreOnExceptionAttribute.cs

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace Debugger.Tests
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Class)]
public class IgnoreOnExceptionAttribute: Attribute
{
}
}

20
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugMethodInfo.cs

@ -156,16 +156,17 @@ namespace Debugger.MetaData @@ -156,16 +156,17 @@ namespace Debugger.MetaData
// public virtual MethodInfo MakeGenericMethod(params Type[] typeArguments);
// public override bool ContainsGenericParameters { get; }
public override Type ReturnType {
get {
if (this.MethodDefSig.RetType.Void) return null;
return DebugType.CreateFromSignature(this.DebugModule, this.MethodDefSig.RetType.Type, declaringType);
}
}
public override ParameterInfo ReturnParameter {
get {
return new DebugParameterInfo(
this,
string.Empty,
this.MethodDefSig.RetType.Void ?
null :
DebugType.CreateFromSignature(this.DebugModule, this.MethodDefSig.RetType.Type, declaringType),
-1
);
if (this.MethodDefSig.RetType.Void) return null;
return new DebugParameterInfo(this, string.Empty, this.ReturnType, -1);
}
}
@ -596,7 +597,8 @@ namespace Debugger.MetaData @@ -596,7 +597,8 @@ namespace Debugger.MetaData
public override string ToString()
{
return this.FullName;
// TODO: Use full name
return this.Name;
}
}
}

10
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugPropertyInfo.cs

@ -54,7 +54,7 @@ namespace Debugger.MetaData @@ -54,7 +54,7 @@ namespace Debugger.MetaData
[Debugger.Tests.Ignore]
public override int MetadataToken {
get { return (getMethod ?? setMethod).MetadataToken; }
get { return 0; }
}
public override System.Reflection.Module Module {
@ -99,7 +99,13 @@ namespace Debugger.MetaData @@ -99,7 +99,13 @@ namespace Debugger.MetaData
}
public override Type PropertyType {
get { return getMethod.ReturnType; }
get {
if (getMethod != null) {
return getMethod.ReturnType;
} else {
return setMethod.GetParameters()[setMethod.GetParameters().Length - 1].ParameterType;
}
}
}
public override MethodInfo[] GetAccessors(bool nonPublic)

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

@ -26,6 +26,7 @@ namespace Debugger.MetaData @@ -26,6 +26,7 @@ namespace Debugger.MetaData
/// If two types are identical, the references to DebugType will also be identical
/// Type will be loaded once per each appdomain.
/// </remarks>
[Debugger.Tests.IgnoreOnException]
public class DebugType: System.Type, IDebugMemberInfo
{
public const BindingFlags BindingFlagsAll = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;

1
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Array.cs

@ -102,6 +102,7 @@ namespace Debugger @@ -102,6 +102,7 @@ namespace Debugger
}
/// <summary> Returns all elements in the array </summary>
[Debugger.Tests.Ignore]
public Value[] GetArrayElements()
{
List<Value> values = new List<Value>();

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

@ -21,19 +21,15 @@ namespace Debugger @@ -21,19 +21,15 @@ namespace Debugger
get {
if (IsNull) throw new GetValueException("Value is null");
if (this.Type.IsClass) {
return this.CorReferenceValue.Dereference().CastTo<ICorDebugObjectValue>();
}
if (this.Type.IsValueType) {
if (this.CorValue.Is<ICorDebugReferenceValue>()) {
// Dereference and unbox
return this.CorReferenceValue.Dereference().CastTo<ICorDebugBoxValue>().Object;
} else {
return this.CorValue.CastTo<ICorDebugObjectValue>();
}
}
throw new DebuggerException("Value is not an object");
ICorDebugValue corValue = this.CorValue;
// Dereference and unbox if necessary
if (corValue.Is<ICorDebugReferenceValue>())
corValue = corValue.CastTo<ICorDebugReferenceValue>().Dereference();
if (corValue.Is<ICorDebugBoxValue>())
return corValue.CastTo<ICorDebugBoxValue>().Object;
if (!corValue.Is<ICorDebugObjectValue>())
throw new DebuggerException("Value is not an object");
return corValue.CastTo<ICorDebugObjectValue>();
}
}

17
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Primitive.cs

@ -17,14 +17,17 @@ namespace Debugger @@ -17,14 +17,17 @@ namespace Debugger
{
internal ICorDebugGenericValue CorGenericValue {
get {
if (!this.Type.IsPrimitive && !this.Type.IsValueType) throw new DebuggerException("Value is not a 'generic'");
if (IsNull) throw new GetValueException("Value is null");
// Dereference and unbox
if (this.CorValue.Is<ICorDebugReferenceValue>()) {
return this.CorReferenceValue.Dereference().CastTo<ICorDebugBoxValue>().Object.CastTo<ICorDebugGenericValue>();
} else {
return this.CorValue.CastTo<ICorDebugGenericValue>();
}
ICorDebugValue corValue = this.CorValue;
// Dereference and unbox if necessary
if (corValue.Is<ICorDebugReferenceValue>())
corValue = corValue.CastTo<ICorDebugReferenceValue>().Dereference();
if (corValue.Is<ICorDebugBoxValue>())
corValue = corValue.CastTo<ICorDebugBoxValue>().Object.CastTo<ICorDebugValue>();
if (!corValue.Is<ICorDebugGenericValue>())
throw new DebuggerException("Value is not an generic value");
return corValue.CastTo<ICorDebugGenericValue>();
}
}

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

@ -24,7 +24,6 @@ namespace Debugger @@ -24,7 +24,6 @@ namespace Debugger
public partial class Value: DebuggerObject
{
AppDomain appDomain;
Process process;
ICorDebugValue corValue;
PauseSession corValue_pauseSession;
DebugType type;
@ -40,15 +39,9 @@ namespace Debugger @@ -40,15 +39,9 @@ namespace Debugger
/// <summary> Gets a string representation of the value </summary>
public string AsString {
get {
if (this.IsNull) return "null";
if (this.Type.IsArray) return "{" + this.Type.FullName + "}";
if (this.Type.IsClass) return "{" + this.Type.FullName + "}";
if (this.Type.IsValueType) return "{" + this.Type.FullName + "}";
if (this.IsNull) return "null";
if (this.Type.IsPrimitive) return PrimitiveValue.ToString();
// Does not work well with unit tests: (variable value)
// if (this.Type.IsPointer) return "0x" + this.CorValue.CastTo<ICorDebugReferenceValue>().Address.ToString("X8");
if (this.Type.IsPointer) return "{" + this.Type.FullName + "}";
throw new DebuggerException("Unknown type");
return "{" + this.Type.FullName + "}";
}
}
@ -60,14 +53,14 @@ namespace Debugger @@ -60,14 +53,14 @@ namespace Debugger
[Debugger.Tests.Ignore]
public Process Process {
get { return process; }
get { return appDomain.Process; }
}
/// <summary> Returns true if the Value can not be used anymore.
/// Value is valid only until the debuggee is resummed. </summary>
public bool IsInvalid {
get {
return corValue_pauseSession != process.PauseSession &&
return corValue_pauseSession != this.Process.PauseSession &&
!corValue.Is<ICorDebugHandleValue>();
}
}
@ -75,18 +68,16 @@ namespace Debugger @@ -75,18 +68,16 @@ namespace Debugger
[Tests.Ignore]
public ICorDebugValue CorValue {
get {
if (this.IsInvalid) {
if (this.IsInvalid)
throw new GetValueException("Value is no longer valid");
}
return corValue;
}
}
ICorDebugReferenceValue CorReferenceValue {
get {
if (!this.IsReference) throw new DebuggerException("Reference value expected");
if (!this.CorValue.Is<ICorDebugReferenceValue>())
throw new DebuggerException("Reference value expected");
return this.CorValue.CastTo<ICorDebugReferenceValue>();
}
}
@ -96,9 +87,7 @@ namespace Debugger @@ -96,9 +87,7 @@ namespace Debugger
/// </summary>
[Debugger.Tests.IgnoreAttribute]
public ulong Address {
get {
return corValue.Address;
}
get { return corValue.Address; }
}
/// <summary> Gets value indication whether the value is a reference </summary>
@ -129,32 +118,25 @@ namespace Debugger @@ -129,32 +118,25 @@ namespace Debugger
return newValue;
}
[Debugger.Tests.Ignore]
public Value GetPermanentReference()
{
ICorDebugValue corValue = this.CorValue;
if (this.Type.IsClass) {
corValue = this.CorObjectValue.CastTo<ICorDebugHeapValue2>().CreateHandle(CorDebugHandleType.HANDLE_STRONG).CastTo<ICorDebugValue>();
}
if (this.Type.IsValueType || this.Type.IsPrimitive) {
if (!corValue.Is<ICorDebugReferenceValue>()) {
return this.Box();
} else {
// Make the reference to box permanent
corValue = corValue.CastTo<ICorDebugReferenceValue>().Dereference().CastTo<ICorDebugHeapValue2>().CreateHandle(CorDebugHandleType.HANDLE_STRONG).CastTo<ICorDebugValue>();
}
if (this.CorValue.Is<ICorDebugHandleValue>()) {
return this;
} else if (this.CorValue.Is<ICorDebugReferenceValue>()) {
return new Value(appDomain, this.CorValue.CastTo<ICorDebugReferenceValue>().Dereference().CastTo<ICorDebugHeapValue2>().CreateHandle(CorDebugHandleType.HANDLE_STRONG).CastTo<ICorDebugValue>());
} else {
return this.Box();
}
return new Value(appDomain, corValue);
}
internal Value(AppDomain appDomain, ICorDebugValue corValue)
{
if (corValue == null) {
if (corValue == null)
throw new ArgumentNullException("corValue");
}
this.appDomain = appDomain;
this.process = appDomain.Process;
this.corValue = corValue;
this.corValue_pauseSession = process.PauseSession;
this.corValue_pauseSession = this.Process.PauseSession;
if (corValue.Is<ICorDebugReferenceValue>() &&
corValue.CastTo<ICorDebugReferenceValue>().Value == 0 &&
@ -171,9 +153,7 @@ namespace Debugger @@ -171,9 +153,7 @@ namespace Debugger
/// <summary> Returns the <see cref="Debugger.DebugType"/> of the value </summary>
public DebugType Type {
get {
return type;
}
get { return type; }
}
[Tests.Ignore]
@ -202,10 +182,9 @@ namespace Debugger @@ -202,10 +182,9 @@ namespace Debugger
{
ICorDebugValue newCorValue = newValue.CorValue;
if (this.IsReference) {
if (!newCorValue.Is<ICorDebugReferenceValue>()) {
if (this.CorValue.Is<ICorDebugReferenceValue>()) {
if (!newCorValue.Is<ICorDebugReferenceValue>())
newCorValue = newValue.Box().CorValue;
}
corValue.CastTo<ICorDebugReferenceValue>().SetValue(newCorValue.CastTo<ICorDebugReferenceValue>().Value);
} else {
corValue.CastTo<ICorDebugGenericValue>().RawValue = newValue.CorGenericValue.RawValue;

Loading…
Cancel
Save