Skip to content

Commit 8480e6d

Browse files
authored
Add support for debugging generics <T> (#387)
1 parent d90aae6 commit 8480e6d

16 files changed

+113
-6
lines changed

nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
<!-- need this here to rebuild the packages.lock.json file in case the hashes fail to validate -->
1616
<!-- <DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder> -->
1717
</PropertyGroup>
18-
1918
<PropertyGroup>
2019
<PackageId>nanoFramework.Tools.Debugger.Net</PackageId>
2120
<Authors>nanoframework</Authors>

nanoFramework.Tools.DebugLibrary.Shared/Runtime/RunTimeValue.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ public virtual bool IsBoxed
219219
public abstract bool IsArray { get; }
220220
public virtual bool IsArrayReference { get { return m_handle.m_arrayref_referenceID != 0; } }
221221
public abstract bool IsReflection { get; }
222+
public abstract bool IsGenericInst { get; }
222223

223224
public virtual nanoClrDataType DataType
224225
{
@@ -337,9 +338,9 @@ static protected RuntimeValue Convert(Engine eng, WireProtocol.Commands.Debuggin
337338
case nanoClrDataType.DATATYPE_CLASS: return new RuntimeValue_Class(eng, src);
338339
case nanoClrDataType.DATATYPE_VALUETYPE: return new RuntimeValue_ValueType(eng, src);
339340

340-
case nanoClrDataType.DATATYPE_VAR: return new RuntimeValue_Class(eng, src);
341-
case nanoClrDataType.DATATYPE_GENERICINST: return new RuntimeValue_Class(eng, src);
342-
case nanoClrDataType.DATATYPE_MVAR: return new RuntimeValue_Class(eng, src);
341+
case nanoClrDataType.DATATYPE_VAR: return new RuntimeValue_Var(eng, src);
342+
case nanoClrDataType.DATATYPE_GENERICINST: return new RuntimeValue_Generic(eng, src);
343+
case nanoClrDataType.DATATYPE_MVAR: return new RuntimeValue_MVar(eng, src);
343344

344345
case nanoClrDataType.DATATYPE_SZARRAY: return new RuntimeValue_Array(eng, src);
345346

nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Array.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ protected internal RuntimeValue_Array(Engine eng, WireProtocol.Commands.Debuggin
1818
public override bool IsValueType { get { return false; } }
1919
public override bool IsArray { get { return true; } }
2020
public override bool IsReflection { get { return false; } }
21+
public override bool IsGenericInst { get { return false; } }
2122

2223
public override RuntimeValue GetElement(uint index)
2324
{

nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Class.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ protected internal RuntimeValue_Class(Engine eng, WireProtocol.Commands.Debuggin
1818
public override bool IsValueType { get { return false; } }
1919
public override bool IsArray { get { return false; } }
2020
public override bool IsReflection { get { return false; } }
21+
public override bool IsGenericInst { get { return false; } }
2122

2223
public override uint NumOfFields
2324
{
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
4+
// See LICENSE file in the project root for full license information.
5+
//
6+
7+
namespace nanoFramework.Tools.Debugger
8+
{
9+
public class RuntimeValue_Generic : RuntimeValue
10+
{
11+
protected internal RuntimeValue_Generic(Engine eng, WireProtocol.Commands.Debugging_Value handle) : base(eng, handle)
12+
{
13+
}
14+
15+
public override bool IsReference { get { return false; } }
16+
public override bool IsNull { get { return false; } }
17+
public override bool IsPrimitive { get { return false; } }
18+
public override bool IsValueType { get { return false; } }
19+
public override bool IsArray { get { return false; } }
20+
public override bool IsReflection { get { return false; } }
21+
public override bool IsGenericInst { get { return true; } }
22+
23+
public override uint Type => m_handle.m_ts;
24+
25+
public override uint NumOfFields
26+
{
27+
get
28+
{
29+
return m_handle.m_size - 1;
30+
}
31+
}
32+
33+
public override RuntimeValue GetField(uint offset, uint fd)
34+
{
35+
return m_eng.GetFieldValue(this, offset, fd);
36+
}
37+
}
38+
}

nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Indirect.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public override bool IsBoxed
5252
public override bool IsValueType { get { return (m_value != null && m_value.IsValueType); } }
5353
public override bool IsArray { get { return (m_value != null && m_value.IsArray); } }
5454
public override bool IsReflection { get { return false; } }
55+
public override bool IsGenericInst { get { return false; } }
5556

5657
public override object Value
5758
{

nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Internal.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ protected internal RuntimeValue_Internal(Engine eng, WireProtocol.Commands.Debug
1818
public override bool IsValueType { get { return false; } }
1919
public override bool IsArray { get { return false; } }
2020
public override bool IsReflection { get { return false; } }
21+
public override bool IsGenericInst { get { return false; } }
2122
}
2223
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
4+
// See LICENSE file in the project root for full license information.
5+
//
6+
7+
namespace nanoFramework.Tools.Debugger
8+
{
9+
public class RuntimeValue_MVar : RuntimeValue
10+
{
11+
protected internal RuntimeValue_MVar(Engine eng, WireProtocol.Commands.Debugging_Value handle) : base(eng, handle)
12+
{
13+
}
14+
15+
public override bool IsReference { get { return false; } }
16+
public override bool IsNull { get { return false; } }
17+
public override bool IsPrimitive { get { return false; } }
18+
public override bool IsValueType { get { return false; } }
19+
public override bool IsArray { get { return false; } }
20+
public override bool IsReflection { get { return false; } }
21+
public override bool IsGenericInst { get { return false; } }
22+
23+
}
24+
}

nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Primitive.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ protected internal RuntimeValue_Primitive(Engine eng, WireProtocol.Commands.Debu
4949
public override bool IsValueType { get { return false; } }
5050
public override bool IsArray { get { return false; } }
5151
public override bool IsReflection { get { return false; } }
52+
public override bool IsGenericInst { get { return false; } }
5253

5354
public override object Value
5455
{

nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Reflection.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ protected internal RuntimeValue_Reflection(Engine eng, WireProtocol.Commands.Deb
2525
public override bool IsValueType { get { return false; } }
2626
public override bool IsArray { get { return false; } }
2727
public override bool IsReflection { get { return true; } }
28+
public override bool IsGenericInst { get { return false; } }
2829

2930
public ReflectionDefinition.Kind ReflectionType
3031
{

0 commit comments

Comments
 (0)