From bc2dffc96041664b2e9b201f9f38048491eff8b3 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 15 Aug 2022 14:28:52 -0300 Subject: [PATCH 1/5] adding fields that are from non-user-code as private --- .../wasm/debugger/BrowserDebugProxy/DebugStore.cs | 12 ++++++++++-- .../BrowserDebugProxy/MemberObjectsExplorer.cs | 4 ++++ .../wasm/debugger/BrowserDebugProxy/MonoProxy.cs | 2 ++ .../wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs | 3 ++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs index 5bc2aaf564451f..a8fb31c402802d 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs @@ -701,6 +701,7 @@ internal sealed class TypeInfo internal int Token { get; } internal string Namespace { get; } internal bool IsCompilerGenerated { get; } + internal bool NonUserCode { get; } public string FullName { get; } public List Methods { get; } = new(); public Dictionary DebuggerBrowsableFields = new(); @@ -769,8 +770,15 @@ internal TypeInfo(AssemblyInfo assembly, TypeDefinitionHandle typeHandle, TypeDe continue; var container = metadataReader.GetMemberReference((MemberReferenceHandle)ctorHandle).Parent; var attributeName = assembly.EnCGetString(metadataReader.GetTypeReference((TypeReferenceHandle)container).Name); - if (attributeName == nameof(CompilerGeneratedAttribute)) - IsCompilerGenerated = true; + switch (attributeName) + { + case nameof(CompilerGeneratedAttribute): + IsCompilerGenerated = true; + break; + case nameof(DebuggerNonUserCodeAttribute): + NonUserCode = true; + break; + } } void AppendToBrowsable(Dictionary dict, CustomAttributeHandleCollection customAttrs, string fieldName) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs index 6e8049e8666bcf..dcae2c3942e58f 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs @@ -71,6 +71,10 @@ private static async Task ReadFieldValue( FieldAttributes.Public => "result", _ => "internal" }; + + if (!isOwn && typeInfo.Info.NonUserCode && getObjectOptions.HasFlag(GetObjectCommandOptions.JustMyCode)) + fieldValue["__section"] = "private"; + if (field.IsBackingField) { fieldValue["__isBackingField"] = true; diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs index 1626bb2f9e9d4e..7d2245da67784a 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs @@ -745,6 +745,8 @@ internal async Task> RuntimeGetObjectMembers(Sess if (args["forDebuggerDisplayAttribute"]?.Value() == true) getObjectOptions |= GetObjectCommandOptions.ForDebuggerDisplayAttribute; } + if (JustMyCode) + getObjectOptions |= GetObjectCommandOptions.JustMyCode; try { switch (objectId.Scheme) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs index 3b3de88f56a9c7..3a25a7fac07929 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs @@ -59,7 +59,8 @@ internal enum GetObjectCommandOptions OwnProperties = 4, ForDebuggerProxyAttribute = 8, ForDebuggerDisplayAttribute = 16, - WithProperties = 32 + WithProperties = 32, + JustMyCode = 64 } internal enum CommandSet { From af9c1ec1190d3af200cb8ff0adf368e169b61dce Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 15 Aug 2022 21:37:56 -0300 Subject: [PATCH 2/5] Do not show members from types that doesn't have debug information if JMC is enabled. --- .../debugger/BrowserDebugProxy/DebugStore.cs | 3 +- .../MemberObjectsExplorer.cs | 14 +++++---- .../debugger/DebuggerTestSuite/MiscTests.cs | 22 ++++++++++++++ ...-test-without-debug-symbols-to-load.csproj | 6 ++++ .../test.cs | 29 +++++++++++++++++++ .../tests/debugger-test/debugger-test.cs | 15 ++++++++++ .../tests/debugger-test/debugger-test.csproj | 4 ++- 7 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/debugger-test-without-debug-symbols-to-load.csproj create mode 100644 src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs index a8fb31c402802d..f98932d7372ed9 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs @@ -701,8 +701,9 @@ internal sealed class TypeInfo internal int Token { get; } internal string Namespace { get; } internal bool IsCompilerGenerated { get; } - internal bool NonUserCode { get; } + private bool NonUserCode { get; } public string FullName { get; } + internal bool IsNonUserCode => assembly.pdbMetadataReader == null || NonUserCode; public List Methods { get; } = new(); public Dictionary DebuggerBrowsableFields = new(); public Dictionary DebuggerBrowsableProperties = new(); diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs index dcae2c3942e58f..4c31bb1874839b 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs @@ -72,9 +72,6 @@ private static async Task ReadFieldValue( _ => "internal" }; - if (!isOwn && typeInfo.Info.NonUserCode && getObjectOptions.HasFlag(GetObjectCommandOptions.JustMyCode)) - fieldValue["__section"] = "private"; - if (field.IsBackingField) { fieldValue["__isBackingField"] = true; @@ -220,6 +217,10 @@ public static async Task ExpandFieldValues( if (getCommandOptions.HasFlag(GetObjectCommandOptions.ForDebuggerProxyAttribute)) fields = fields.Where(field => field.IsNotPrivate).ToList(); + var typeInfo = await sdbHelper.GetTypeInfo(containerTypeId, token); + if (typeInfo.Info.IsNonUserCode && getCommandOptions.HasFlag(GetObjectCommandOptions.JustMyCode)) + return fieldValues; + using var commandParamsWriter = new MonoBinaryWriter(); commandParamsWriter.Write(id.Value); commandParamsWriter.Write(fields.Count); @@ -229,8 +230,6 @@ public static async Task ExpandFieldValues( ? await sdbHelper.SendDebuggerAgentCommand(CmdType.GetValues, commandParamsWriter, token) : await sdbHelper.SendDebuggerAgentCommand(CmdObject.RefGetValues, commandParamsWriter, token); - var typeInfo = await sdbHelper.GetTypeInfo(containerTypeId, token); - int numFieldsRead = 0; foreach (FieldTypeClass field in fields) { @@ -595,6 +594,11 @@ public static async Task GetObjectMemberValues( if (!getCommandType.HasFlag(GetObjectCommandOptions.WithProperties)) return GetMembersResult.FromValues(allMembers.Values, sortByAccessLevel); + var typeInfo = await sdbHelper.GetTypeInfo(typeId, token); + + if (typeInfo.Info.IsNonUserCode && getCommandType.HasFlag(GetObjectCommandOptions.JustMyCode)) + break; + allMembers = await ExpandPropertyValues( sdbHelper, typeId, diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs index 5e0f0d6802c5a9..d72f22c8cbfdab 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs @@ -1039,5 +1039,27 @@ await EvaluateAndCheck( } ); } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task InspectThisThatInheritsFromClassNonUserCode(bool jmc) + { + await SetJustMyCode(jmc); + var expression = $"{{ invoke_static_method('[debugger-test] ClassInheritsFromClassWithoutDebugSymbols:Run'); }}"; + + await EvaluateAndCheck( + "window.setTimeout(function() {" + expression + "; }, 1);", + "dotnet://debugger-test.dll/debugger-test.cs", 1287, 8, + $"ClassInheritsFromClassWithoutDebugSymbols.CallMethod", + locals_fn: async (locals) => + { + var this_props = await GetObjectOnLocals(locals, "this"); + await CheckProps(this_props, new + { + }, "this_props", num_fields: jmc ? 1 : 7); + } + ); + } } } diff --git a/src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/debugger-test-without-debug-symbols-to-load.csproj b/src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/debugger-test-without-debug-symbols-to-load.csproj new file mode 100644 index 00000000000000..34367db0bff2da --- /dev/null +++ b/src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/debugger-test-without-debug-symbols-to-load.csproj @@ -0,0 +1,6 @@ + + + none + false + + diff --git a/src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs b/src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs new file mode 100644 index 00000000000000..4536150d156866 --- /dev/null +++ b/src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs @@ -0,0 +1,29 @@ +using System; + +namespace DebuggerTests +{ + public class ClassWithoutDebugSymbolsToInherit + { + private int propA {get;} + public int propB {get;} + protected int propC {get;} + private int d; + public int e; + protected int f; + public ClassWithoutDebugSymbolsToInherit() + { + propA = 10; + propB = 20; + propC = 30; + d = 40; + e = 50; + f = 60; + Console.WriteLine(propA); + Console.WriteLine(propB); + Console.WriteLine(propC); + Console.WriteLine(d); + Console.WriteLine(e); + Console.WriteLine(f); + } + } +} diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs index 6424ca3d5cdd93..17f620b6476717 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs @@ -1275,3 +1275,18 @@ public static void MethodWithHiddenLinesAtTheEnd3() #line default } +public class ClassInheritsFromClassWithoutDebugSymbols : DebuggerTests.ClassWithoutDebugSymbolsToInherit +{ + public static void Run() + { + var myVar = new ClassInheritsFromClassWithoutDebugSymbols(); + myVar.CallMethod(); + } + + public void CallMethod() + { + System.Diagnostics.Debugger.Break(); + } + + public int myField; +} \ No newline at end of file diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj index 42edcb663f906a..ae4def00e6aed7 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj @@ -21,6 +21,7 @@ + @@ -44,7 +45,6 @@ debugger-main.js -1 - true @@ -52,6 +52,7 @@ + @@ -63,6 +64,7 @@ + Date: Mon, 15 Aug 2022 23:38:07 -0300 Subject: [PATCH 3/5] Addressing @radical comments. --- .../MemberObjectsExplorer.cs | 17 ++++--- .../debugger/DebuggerTestSuite/MiscTests.cs | 38 +++++++++++---- .../test.cs | 6 +++ .../tests/debugger-test/debugger-test.cs | 48 +++++++++++++++++++ 4 files changed, 92 insertions(+), 17 deletions(-) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs index 4c31bb1874839b..f199e228771ac2 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs @@ -217,10 +217,6 @@ public static async Task ExpandFieldValues( if (getCommandOptions.HasFlag(GetObjectCommandOptions.ForDebuggerProxyAttribute)) fields = fields.Where(field => field.IsNotPrivate).ToList(); - var typeInfo = await sdbHelper.GetTypeInfo(containerTypeId, token); - if (typeInfo.Info.IsNonUserCode && getCommandOptions.HasFlag(GetObjectCommandOptions.JustMyCode)) - return fieldValues; - using var commandParamsWriter = new MonoBinaryWriter(); commandParamsWriter.Write(id.Value); commandParamsWriter.Write(fields.Count); @@ -230,6 +226,8 @@ public static async Task ExpandFieldValues( ? await sdbHelper.SendDebuggerAgentCommand(CmdType.GetValues, commandParamsWriter, token) : await sdbHelper.SendDebuggerAgentCommand(CmdObject.RefGetValues, commandParamsWriter, token); + var typeInfo = await sdbHelper.GetTypeInfo(containerTypeId, token); + int numFieldsRead = 0; foreach (FieldTypeClass field in fields) { @@ -574,9 +572,15 @@ public static async Task GetObjectMemberValues( string typeName = await sdbHelper.GetTypeName(typeId, token); // 0th id is for the object itself, and then its ancestors bool isOwn = i == 0; + var typeInfo = await sdbHelper.GetTypeInfo(typeId, token); + + if (typeInfo.Info.IsNonUserCode && getCommandType.HasFlag(GetObjectCommandOptions.JustMyCode)) + break; + IReadOnlyList thisTypeFields = await sdbHelper.GetTypeFields(typeId, token); if (!includeStatic) thisTypeFields = thisTypeFields.Where(f => !f.Attributes.HasFlag(FieldAttributes.Static)).ToList(); + if (thisTypeFields.Count > 0) { var allFields = await ExpandFieldValues( @@ -594,11 +598,6 @@ public static async Task GetObjectMemberValues( if (!getCommandType.HasFlag(GetObjectCommandOptions.WithProperties)) return GetMembersResult.FromValues(allMembers.Values, sortByAccessLevel); - var typeInfo = await sdbHelper.GetTypeInfo(typeId, token); - - if (typeInfo.Info.IsNonUserCode && getCommandType.HasFlag(GetObjectCommandOptions.JustMyCode)) - break; - allMembers = await ExpandPropertyValues( sdbHelper, typeId, diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs index d72f22c8cbfdab..d2094571a43533 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs @@ -1041,23 +1041,45 @@ await EvaluateAndCheck( } [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task InspectThisThatInheritsFromClassNonUserCode(bool jmc) + [InlineData("ClassInheritsFromClassWithoutDebugSymbols", 1287, true)] + [InlineData("ClassInheritsFromClassWithoutDebugSymbols", 1287, false)] + [InlineData("ClassInheritsFromNonUserCodeClass", 1335, true)] + [InlineData("ClassInheritsFromNonUserCodeClass", 1335, false)] + public async Task InspectThisThatInheritsFromClassNonUserCode(string class_name, int line, bool jmc) { await SetJustMyCode(jmc); - var expression = $"{{ invoke_static_method('[debugger-test] ClassInheritsFromClassWithoutDebugSymbols:Run'); }}"; + var expression = "{{ invoke_static_method('[debugger-test] " + class_name + ":Run'); }}"; await EvaluateAndCheck( "window.setTimeout(function() {" + expression + "; }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 1287, 8, - $"ClassInheritsFromClassWithoutDebugSymbols.CallMethod", + "dotnet://debugger-test.dll/debugger-test.cs", line, 8, + $"{class_name}.CallMethod", locals_fn: async (locals) => { var this_props = await GetObjectOnLocals(locals, "this"); - await CheckProps(this_props, new + if (jmc) { - }, "this_props", num_fields: jmc ? 1 : 7); + await CheckProps(this_props, new + { + myField = TNumber(0), + }, "this_props", num_fields: 1); + } + else + { + Console.WriteLine(this_props); + await CheckProps(this_props, new + { + propA = TNumber(10), + propB = TNumber(20), + propC = TNumber(30), + d = TNumber(40), + e = TNumber(50), + f = TNumber(60), + G = TGetter("G"), + H = TGetter("H"), + myField = TNumber(0), + }, "this_props", num_fields: 9); + } } ); } diff --git a/src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs b/src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs index 4536150d156866..f7e6afa42828bc 100644 --- a/src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs +++ b/src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs @@ -10,6 +10,12 @@ public class ClassWithoutDebugSymbolsToInherit private int d; public int e; protected int f; + public int G + { + get {return f + 1;} + } + public int H => f; + public ClassWithoutDebugSymbolsToInherit() { propA = 10; diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs index 17f620b6476717..3995c72e884a48 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs @@ -1288,5 +1288,53 @@ public void CallMethod() System.Diagnostics.Debugger.Break(); } + public int myField; +} + +[System.Diagnostics.DebuggerNonUserCode] +public class ClassNonUserCodeToInherit +{ + private int propA {get;} + public int propB {get;} + protected int propC {get;} + private int d; + public int e; + protected int f; + public int G + { + get {return f + 1;} + } + public int H => f; + + public ClassNonUserCodeToInherit() + { + propA = 10; + propB = 20; + propC = 30; + d = 40; + e = 50; + f = 60; + Console.WriteLine(propA); + Console.WriteLine(propB); + Console.WriteLine(propC); + Console.WriteLine(d); + Console.WriteLine(e); + Console.WriteLine(f); + } +} + +public class ClassInheritsFromNonUserCodeClass : ClassNonUserCodeToInherit +{ + public static void Run() + { + var myVar = new ClassInheritsFromNonUserCodeClass(); + myVar.CallMethod(); + } + + public void CallMethod() + { + System.Diagnostics.Debugger.Break(); + } + public int myField; } \ No newline at end of file From 9bcfca32d7203f1607fad5e7b1f3ad0eef87bfd6 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 16 Aug 2022 00:07:13 -0300 Subject: [PATCH 4/5] Apply suggestions from code review Co-authored-by: Ankit Jain --- .../debugger-test-without-debug-symbols-to-load/test.cs | 6 +++--- src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs b/src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs index f7e6afa42828bc..5dcdc29f93f2d0 100644 --- a/src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs +++ b/src/mono/wasm/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs @@ -10,9 +10,9 @@ public class ClassWithoutDebugSymbolsToInherit private int d; public int e; protected int f; - public int G - { - get {return f + 1;} + public int G + { + get {return f + 1;} } public int H => f; diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs index 3995c72e884a48..07f736371fec71 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs @@ -1300,9 +1300,9 @@ public class ClassNonUserCodeToInherit private int d; public int e; protected int f; - public int G - { - get {return f + 1;} + public int G + { + get {return f + 1;} } public int H => f; From d70f222abd00402b8d68245712897aaaf173867d Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 16 Aug 2022 00:20:09 -0300 Subject: [PATCH 5/5] Adding more tests. --- .../MemberObjectsExplorer.cs | 9 ++-- .../debugger/DebuggerTestSuite/MiscTests.cs | 9 ++-- ...ugger-test-with-non-user-code-class.csproj | 4 ++ .../test.cs | 41 +++++++++++++++++++ .../tests/debugger-test/debugger-test.cs | 19 ++++++++- .../tests/debugger-test/debugger-test.csproj | 2 + 6 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 src/mono/wasm/debugger/tests/debugger-test-with-non-user-code-class/debugger-test-with-non-user-code-class.csproj create mode 100644 src/mono/wasm/debugger/tests/debugger-test-with-non-user-code-class/test.cs diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs index f199e228771ac2..24f4d8522cb845 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs @@ -568,14 +568,15 @@ public static async Task GetObjectMemberValues( for (int i = 0; i < typeIdsCnt; i++) { int typeId = typeIdsIncludingParents[i]; + var typeInfo = await sdbHelper.GetTypeInfo(typeId, token); + + if (typeInfo.Info.IsNonUserCode && getCommandType.HasFlag(GetObjectCommandOptions.JustMyCode)) + continue; + int parentTypeId = i + 1 < typeIdsCnt ? typeIdsIncludingParents[i + 1] : -1; string typeName = await sdbHelper.GetTypeName(typeId, token); // 0th id is for the object itself, and then its ancestors bool isOwn = i == 0; - var typeInfo = await sdbHelper.GetTypeInfo(typeId, token); - - if (typeInfo.Info.IsNonUserCode && getCommandType.HasFlag(GetObjectCommandOptions.JustMyCode)) - break; IReadOnlyList thisTypeFields = await sdbHelper.GetTypeFields(typeId, token); if (!includeStatic) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs index d2094571a43533..50ebc7704388ce 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs @@ -1045,6 +1045,8 @@ await EvaluateAndCheck( [InlineData("ClassInheritsFromClassWithoutDebugSymbols", 1287, false)] [InlineData("ClassInheritsFromNonUserCodeClass", 1335, true)] [InlineData("ClassInheritsFromNonUserCodeClass", 1335, false)] + [InlineData("ClassInheritsFromNonUserCodeClassThatInheritsFromNormalClass", 1352, true)] + [InlineData("ClassInheritsFromNonUserCodeClassThatInheritsFromNormalClass", 1352, false)] public async Task InspectThisThatInheritsFromClassNonUserCode(string class_name, int line, bool jmc) { await SetJustMyCode(jmc); @@ -1062,11 +1064,11 @@ await EvaluateAndCheck( await CheckProps(this_props, new { myField = TNumber(0), - }, "this_props", num_fields: 1); + myField2 = TNumber(0), + }, "this_props", num_fields: 2); } else { - Console.WriteLine(this_props); await CheckProps(this_props, new { propA = TNumber(10), @@ -1078,7 +1080,8 @@ await EvaluateAndCheck( G = TGetter("G"), H = TGetter("H"), myField = TNumber(0), - }, "this_props", num_fields: 9); + myField2 = TNumber(0), + }, "this_props", num_fields: 10); } } ); diff --git a/src/mono/wasm/debugger/tests/debugger-test-with-non-user-code-class/debugger-test-with-non-user-code-class.csproj b/src/mono/wasm/debugger/tests/debugger-test-with-non-user-code-class/debugger-test-with-non-user-code-class.csproj new file mode 100644 index 00000000000000..c0d42d7f25cde5 --- /dev/null +++ b/src/mono/wasm/debugger/tests/debugger-test-with-non-user-code-class/debugger-test-with-non-user-code-class.csproj @@ -0,0 +1,4 @@ + + + + diff --git a/src/mono/wasm/debugger/tests/debugger-test-with-non-user-code-class/test.cs b/src/mono/wasm/debugger/tests/debugger-test-with-non-user-code-class/test.cs new file mode 100644 index 00000000000000..af11a6329d0d26 --- /dev/null +++ b/src/mono/wasm/debugger/tests/debugger-test-with-non-user-code-class/test.cs @@ -0,0 +1,41 @@ +using System; + +namespace DebuggerTests +{ + public class NormalClass + { + public int myField2; + } + + [System.Diagnostics.DebuggerNonUserCode] + public class ClassNonUserCodeToInheritThatInheritsFromNormalClass : NormalClass + { + private int propA {get;} + public int propB {get;} + protected int propC {get;} + private int d; + public int e; + protected int f; + public int G + { + get {return f + 1;} + } + public int H => f; + + public ClassNonUserCodeToInheritThatInheritsFromNormalClass() + { + propA = 10; + propB = 20; + propC = 30; + d = 40; + e = 50; + f = 60; + Console.WriteLine(propA); + Console.WriteLine(propB); + Console.WriteLine(propC); + Console.WriteLine(d); + Console.WriteLine(e); + Console.WriteLine(f); + } + } +} diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs index 07f736371fec71..6b5f84561beb9e 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs @@ -1287,7 +1287,7 @@ public void CallMethod() { System.Diagnostics.Debugger.Break(); } - + public int myField2; public int myField; } @@ -1336,5 +1336,22 @@ public void CallMethod() System.Diagnostics.Debugger.Break(); } + public int myField2; + public int myField; +} + +public class ClassInheritsFromNonUserCodeClassThatInheritsFromNormalClass : DebuggerTests.ClassNonUserCodeToInheritThatInheritsFromNormalClass +{ + public static void Run() + { + var myVar = new ClassInheritsFromNonUserCodeClassThatInheritsFromNormalClass(); + myVar.CallMethod(); + } + + public void CallMethod() + { + System.Diagnostics.Debugger.Break(); + } + public int myField; } \ No newline at end of file diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj index ae4def00e6aed7..0ea4fcc719f4b8 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj @@ -22,6 +22,7 @@ + @@ -53,6 +54,7 @@ +