From 5e92d39bcf2201f6f8a0bb401a339e139e3cbd0b Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz Date: Tue, 2 Nov 2021 14:46:42 +0100 Subject: [PATCH 1/7] Draft of hidden attribute decorator use. --- .../debugger/BrowserDebugProxy/MonoProxy.cs | 5 +++ .../BrowserDebugProxy/MonoSDBHelper.cs | 45 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs index 674824df71580..f6668d777954f 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs @@ -1153,6 +1153,10 @@ private async Task SetMonoBreakpoint(SessionId sessionId, string req var assembly_id = await SdbHelper.GetAssemblyId(sessionId, asm_name, token); var methodId = await SdbHelper.GetMethodIdByToken(sessionId, assembly_id, method_token, token); var breakpoint_id = await SdbHelper.SetBreakpoint(sessionId, methodId, il_offset, token); + var type_id = await SdbHelper.GetTypeIdFromToken(sessionId, assembly_id, method_token, token); + var isHidden = await SdbHelper.GetDebuggerHiddenAttribute(sessionId, type_id, token); + if (isHidden) + return bp; if (breakpoint_id > 0) { @@ -1301,6 +1305,7 @@ private async Task SetBreakpoint(SessionId sessionId, DebugStore store, Breakpoi { SourceLocation loc = sourceId.First(); req.Method = loc.CliLocation.Method; + Breakpoint bp = await SetMonoBreakpoint(sessionId, req.Id, loc, req.Condition, token); // If we didn't successfully enable the breakpoint diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs index dee4b5ac0f5fd..9ac1f1203ec75 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs @@ -1327,6 +1327,32 @@ internal async Task GetCAttrsFromType(SessionId sessionId, int return null; } + internal async Task> GetCAttrsFromMethod(SessionId sessionId, int typeId, CancellationToken token) + { + var customAttributeNames = new List(); + var invokeParams = new MemoryStream(); + var invokeParamsWriter = new MonoBinaryWriter(invokeParams); + var commandParams = new MemoryStream(); + var commandParamsWriter = new MonoBinaryWriter(commandParams); + commandParamsWriter.Write(typeId); + commandParamsWriter.Write(0); + var retDebuggerCmdReader = await SendDebuggerAgentCommand(sessionId, CmdMethod.GetCattrs, commandParams, token); + var count = retDebuggerCmdReader.ReadInt32(); + if (count == 0) + return customAttributeNames; + for (int i = 0; i < count; i++) + { + var methodId = retDebuggerCmdReader.ReadInt32(); + commandParams = new MemoryStream(); + commandParamsWriter = new MonoBinaryWriter(commandParams); + commandParamsWriter.Write(methodId); + var retDebuggerCmdReader2 = await SendDebuggerAgentCommand(sessionId, CmdMethod.GetDeclaringType, commandParams, token); + var customAttributeTypeId = retDebuggerCmdReader2.ReadInt32(); + customAttributeNames.Add(await GetTypeName(sessionId, customAttributeTypeId, token)); + } + return customAttributeNames; + } + public async Task GetAssemblyFromType(SessionId sessionId, int type_id, CancellationToken token) { var commandParams = new MemoryStream(); @@ -1342,6 +1368,25 @@ public async Task GetAssemblyFromType(SessionId sessionId, int type_id, Can return retDebuggerCmdReader.ReadInt32(); } + public async Task GetDebuggerHiddenAttribute(SessionId sessionId, int type_id, CancellationToken token) + { + string expr = ""; + try + { + + var customMethodAttributes = await GetCAttrsFromMethod(sessionId, type_id, token); + if (customMethodAttributes.Any(a => a == "System.Diagnostics.DebuggerHiddenAttribute")) + { + return true; + } + } + catch (Exception) + { + logger.LogDebug($"Could not evaluate DebuggerHiddenAttribute - {expr}"); + } + return false; + } + public async Task GetValueFromDebuggerDisplayAttribute(SessionId sessionId, int objectId, int typeId, CancellationToken token) { string expr = ""; From 8c44faefae2a04e0e6c8420e6198aaeb49381359 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz Date: Wed, 3 Nov 2021 09:05:48 +0100 Subject: [PATCH 2/7] Removed checking custom attributes in the runtime each time the breakpoint is set and moved it to the constructor which is more efficient. --- .../debugger/BrowserDebugProxy/DebugStore.cs | 13 ++++++ .../debugger/BrowserDebugProxy/MonoProxy.cs | 8 ++-- .../BrowserDebugProxy/MonoSDBHelper.cs | 45 ------------------- 3 files changed, 17 insertions(+), 49 deletions(-) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs index be7d729dd019e..8579898faf715 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs @@ -330,6 +330,7 @@ internal class MethodInfo internal LocalScopeHandleCollection localScopes; public bool IsStatic() => (methodDef.Attributes & MethodAttributes.Static) != 0; public int IsAsync { get; set; } + public bool IsHiddenFromDebugger { get; } public MethodInfo(AssemblyInfo assembly, MethodDefinitionHandle methodDefHandle, int token, SourceFile source, TypeInfo type, MetadataReader asmMetadataReader, MetadataReader pdbMetadataReader) { this.IsAsync = -1; @@ -363,6 +364,18 @@ public MethodInfo(AssemblyInfo assembly, MethodDefinitionHandle methodDefHandle, StartLocation = new SourceLocation(this, start); EndLocation = new SourceLocation(this, end); + + foreach (var cattr in methodDef.GetCustomAttributes()) + { + var ctorHandle = asmMetadataReader.GetCustomAttribute(cattr).Constructor; + if (ctorHandle.Kind == HandleKind.MemberReference) + { + var container = asmMetadataReader.GetMemberReference((MemberReferenceHandle)ctorHandle).Parent; + var name = asmMetadataReader.GetString(asmMetadataReader.GetTypeReference((TypeReferenceHandle)container).Name); + if (name == "DebuggerHiddenAttribute") + this.IsHiddenFromDebugger = true; + } + } } localScopes = pdbMetadataReader.GetLocalScopes(methodDefHandle); } diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs index f6668d777954f..0edfb15225b4c 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs @@ -1153,10 +1153,6 @@ private async Task SetMonoBreakpoint(SessionId sessionId, string req var assembly_id = await SdbHelper.GetAssemblyId(sessionId, asm_name, token); var methodId = await SdbHelper.GetMethodIdByToken(sessionId, assembly_id, method_token, token); var breakpoint_id = await SdbHelper.SetBreakpoint(sessionId, methodId, il_offset, token); - var type_id = await SdbHelper.GetTypeIdFromToken(sessionId, assembly_id, method_token, token); - var isHidden = await SdbHelper.GetDebuggerHiddenAttribute(sessionId, type_id, token); - if (isHidden) - return bp; if (breakpoint_id > 0) { @@ -1305,6 +1301,10 @@ private async Task SetBreakpoint(SessionId sessionId, DebugStore store, Breakpoi { SourceLocation loc = sourceId.First(); req.Method = loc.CliLocation.Method; + if (req.Method.IsHiddenFromDebugger) + { + continue; + } Breakpoint bp = await SetMonoBreakpoint(sessionId, req.Id, loc, req.Condition, token); diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs index 9ac1f1203ec75..dee4b5ac0f5fd 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs @@ -1327,32 +1327,6 @@ internal async Task GetCAttrsFromType(SessionId sessionId, int return null; } - internal async Task> GetCAttrsFromMethod(SessionId sessionId, int typeId, CancellationToken token) - { - var customAttributeNames = new List(); - var invokeParams = new MemoryStream(); - var invokeParamsWriter = new MonoBinaryWriter(invokeParams); - var commandParams = new MemoryStream(); - var commandParamsWriter = new MonoBinaryWriter(commandParams); - commandParamsWriter.Write(typeId); - commandParamsWriter.Write(0); - var retDebuggerCmdReader = await SendDebuggerAgentCommand(sessionId, CmdMethod.GetCattrs, commandParams, token); - var count = retDebuggerCmdReader.ReadInt32(); - if (count == 0) - return customAttributeNames; - for (int i = 0; i < count; i++) - { - var methodId = retDebuggerCmdReader.ReadInt32(); - commandParams = new MemoryStream(); - commandParamsWriter = new MonoBinaryWriter(commandParams); - commandParamsWriter.Write(methodId); - var retDebuggerCmdReader2 = await SendDebuggerAgentCommand(sessionId, CmdMethod.GetDeclaringType, commandParams, token); - var customAttributeTypeId = retDebuggerCmdReader2.ReadInt32(); - customAttributeNames.Add(await GetTypeName(sessionId, customAttributeTypeId, token)); - } - return customAttributeNames; - } - public async Task GetAssemblyFromType(SessionId sessionId, int type_id, CancellationToken token) { var commandParams = new MemoryStream(); @@ -1368,25 +1342,6 @@ public async Task GetAssemblyFromType(SessionId sessionId, int type_id, Can return retDebuggerCmdReader.ReadInt32(); } - public async Task GetDebuggerHiddenAttribute(SessionId sessionId, int type_id, CancellationToken token) - { - string expr = ""; - try - { - - var customMethodAttributes = await GetCAttrsFromMethod(sessionId, type_id, token); - if (customMethodAttributes.Any(a => a == "System.Diagnostics.DebuggerHiddenAttribute")) - { - return true; - } - } - catch (Exception) - { - logger.LogDebug($"Could not evaluate DebuggerHiddenAttribute - {expr}"); - } - return false; - } - public async Task GetValueFromDebuggerDisplayAttribute(SessionId sessionId, int objectId, int typeId, CancellationToken token) { string expr = ""; From 5302e15803e0831662649c7ceefdb2e7efb22ae4 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz Date: Wed, 3 Nov 2021 11:27:31 +0100 Subject: [PATCH 3/7] Added test for DebuggerHidden decorator. --- .../DebuggerTestSuite/BreakpointTests.cs | 8 ++++++++ .../tests/debugger-test/debugger-test.cs | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs index dd807d0bfaf54..3575033252219 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs @@ -642,5 +642,13 @@ await EvaluateAndCheck( } ); } + + + [Fact] + public async Task DebuggerAttributeNoStopInDebuggerHidden() + { + var bp_hidden = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", "HiddenMethod", 1); + Assert.Empty(bp_hidden.Value["locations"]); + } } } 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 2338c9e65d624..99ad361821f57 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using System.Diagnostics; public partial class Math { //Only append content to this class as the test suite depends on line info public static int IntAdd(int a, int b) @@ -807,3 +808,19 @@ public int Increment(int count) return count + 1; } } + +public class DebuggerAttribute +{ + static int currentCount = 0; + + [DebuggerHidden] + public static void HiddenMethod() + { + currentCount++; + } + + public static void Run() + { + HiddenMethod(); + } +} From 01e5e831be6a14e4a8d337795d477826c0ec31fa Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz Date: Wed, 3 Nov 2021 12:01:01 +0100 Subject: [PATCH 4/7] By adding a line: using System.Diagnostics; IntAdd method moved down one line what resulted in CreateGoodBreakpoint tests failures. All row numbers in these tests had to be incremented. --- .../DebuggerTestSuite/BreakpointTests.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs index 3575033252219..b5317b41bdbb9 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs @@ -130,11 +130,11 @@ public async Task CreateBadBreakpoint() [Fact] public async Task CreateGoodBreakpointAndHit() { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); + var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 11, 8); await EvaluateAndCheck( "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, + "dotnet://debugger-test.dll/debugger-test.cs", 11, 8, "IntAdd", wait_for_event_fn: (pause_location) => { @@ -145,7 +145,7 @@ await EvaluateAndCheck( Assert.Equal("IntAdd", top_frame["functionName"].Value()); Assert.Contains("debugger-test.cs", top_frame["url"].Value()); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, top_frame["functionLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 9, 4, scripts, top_frame["functionLocation"]); //now check the scope var scope = top_frame["scopeChain"][0]; @@ -153,8 +153,8 @@ await EvaluateAndCheck( Assert.Equal("IntAdd", scope["name"]); Assert.Equal("object", scope["object"]["type"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, scope["startLocation"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 14, 4, scripts, scope["endLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 9, 4, scripts, scope["startLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 15, 4, scripts, scope["endLocation"]); return Task.CompletedTask; } ); @@ -577,10 +577,10 @@ await SendCommandAndCheck(null, "Debugger.resume", [Fact] public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain() { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); + var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 11, 8); var pause_location = await EvaluateAndCheck( "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, + "dotnet://debugger-test.dll/debugger-test.cs", 11, 8, "IntAdd"); Assert.Equal("other", pause_location["reason"]?.Value()); Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); @@ -589,7 +589,7 @@ public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain() Assert.Equal("IntAdd", top_frame["functionName"].Value()); Assert.Contains("debugger-test.cs", top_frame["url"].Value()); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, top_frame["functionLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 9, 4, scripts, top_frame["functionLocation"]); //now check the scope var scope = top_frame["scopeChain"][0]; @@ -597,8 +597,8 @@ public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain() Assert.Equal("IntAdd", scope["name"]); Assert.Equal("object", scope["object"]["type"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, scope["startLocation"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 14, 4, scripts, scope["endLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 9, 4, scripts, scope["startLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 15, 4, scripts, scope["endLocation"]); await cli.SendCommand("Debugger.resume", null, token); @@ -617,7 +617,7 @@ public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain() await insp.WaitFor(Inspector.READY); await EvaluateAndCheck( "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, + "dotnet://debugger-test.dll/debugger-test.cs", 11, 8, "IntAdd", wait_for_event_fn: (pause_location) => { @@ -628,7 +628,7 @@ await EvaluateAndCheck( Assert.Equal("IntAdd", top_frame["functionName"].Value()); Assert.Contains("debugger-test.cs", top_frame["url"].Value()); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, top_frame["functionLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 9, 4, scripts, top_frame["functionLocation"]); //now check the scope var scope = top_frame["scopeChain"][0]; @@ -636,8 +636,8 @@ await EvaluateAndCheck( Assert.Equal("IntAdd", scope["name"]); Assert.Equal("object", scope["object"]["type"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, scope["startLocation"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 14, 4, scripts, scope["endLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 9, 4, scripts, scope["startLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 15, 4, scripts, scope["endLocation"]); return Task.CompletedTask; } ); From f021822ff067f3e474119aa9392f15c4bfc6644f Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz Date: Wed, 3 Nov 2021 13:01:54 +0100 Subject: [PATCH 5/7] Reverted edition of tests not connected with HiddenAttribute. --- .../DebuggerTestSuite/BreakpointTests.cs | 28 +++++++++---------- .../tests/debugger-test/debugger-test.cs | 9 ++++-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs index b5317b41bdbb9..3575033252219 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs @@ -130,11 +130,11 @@ public async Task CreateBadBreakpoint() [Fact] public async Task CreateGoodBreakpointAndHit() { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 11, 8); + var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); await EvaluateAndCheck( "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 11, 8, + "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, "IntAdd", wait_for_event_fn: (pause_location) => { @@ -145,7 +145,7 @@ await EvaluateAndCheck( Assert.Equal("IntAdd", top_frame["functionName"].Value()); Assert.Contains("debugger-test.cs", top_frame["url"].Value()); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 9, 4, scripts, top_frame["functionLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, top_frame["functionLocation"]); //now check the scope var scope = top_frame["scopeChain"][0]; @@ -153,8 +153,8 @@ await EvaluateAndCheck( Assert.Equal("IntAdd", scope["name"]); Assert.Equal("object", scope["object"]["type"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 9, 4, scripts, scope["startLocation"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 15, 4, scripts, scope["endLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, scope["startLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 14, 4, scripts, scope["endLocation"]); return Task.CompletedTask; } ); @@ -577,10 +577,10 @@ await SendCommandAndCheck(null, "Debugger.resume", [Fact] public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain() { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 11, 8); + var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); var pause_location = await EvaluateAndCheck( "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 11, 8, + "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, "IntAdd"); Assert.Equal("other", pause_location["reason"]?.Value()); Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); @@ -589,7 +589,7 @@ public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain() Assert.Equal("IntAdd", top_frame["functionName"].Value()); Assert.Contains("debugger-test.cs", top_frame["url"].Value()); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 9, 4, scripts, top_frame["functionLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, top_frame["functionLocation"]); //now check the scope var scope = top_frame["scopeChain"][0]; @@ -597,8 +597,8 @@ public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain() Assert.Equal("IntAdd", scope["name"]); Assert.Equal("object", scope["object"]["type"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 9, 4, scripts, scope["startLocation"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 15, 4, scripts, scope["endLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, scope["startLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 14, 4, scripts, scope["endLocation"]); await cli.SendCommand("Debugger.resume", null, token); @@ -617,7 +617,7 @@ public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain() await insp.WaitFor(Inspector.READY); await EvaluateAndCheck( "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 11, 8, + "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, "IntAdd", wait_for_event_fn: (pause_location) => { @@ -628,7 +628,7 @@ await EvaluateAndCheck( Assert.Equal("IntAdd", top_frame["functionName"].Value()); Assert.Contains("debugger-test.cs", top_frame["url"].Value()); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 9, 4, scripts, top_frame["functionLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, top_frame["functionLocation"]); //now check the scope var scope = top_frame["scopeChain"][0]; @@ -636,8 +636,8 @@ await EvaluateAndCheck( Assert.Equal("IntAdd", scope["name"]); Assert.Equal("object", scope["object"]["type"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 9, 4, scripts, scope["startLocation"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 15, 4, scripts, scope["endLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, scope["startLocation"]); + CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 14, 4, scripts, scope["endLocation"]); return Task.CompletedTask; } ); 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 99ad361821f57..4a029949d156d 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs @@ -3,7 +3,6 @@ using System; using System.Linq; -using System.Diagnostics; public partial class Math { //Only append content to this class as the test suite depends on line info public static int IntAdd(int a, int b) @@ -813,14 +812,20 @@ public class DebuggerAttribute { static int currentCount = 0; - [DebuggerHidden] + [System.Diagnostics.DebuggerHidden] public static void HiddenMethod() { currentCount++; } + public static void VisibleMethod() + { + currentCount++; + } + public static void Run() { HiddenMethod(); + VisibleMethod(); } } From 74d27f8981ef8d95149d45267641c0ca743b1880 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz Date: Wed, 3 Nov 2021 13:51:17 +0100 Subject: [PATCH 6/7] Added visible method to the HiddenAttribute test. --- .../wasm/debugger/DebuggerTestSuite/BreakpointTests.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs index 3575033252219..398df51a299dd 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs @@ -648,7 +648,15 @@ await EvaluateAndCheck( public async Task DebuggerAttributeNoStopInDebuggerHidden() { var bp_hidden = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", "HiddenMethod", 1); + var bp_visible = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", "VisibleMethod", 1); Assert.Empty(bp_hidden.Value["locations"]); + await EvaluateAndCheck( + "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerAttribute:VisibleMethod'); }, 1);", + "dotnet://debugger-test.dll/debugger-test.cs", + bp_visible.Value["locations"][0]["lineNumber"].Value(), + bp_visible.Value["locations"][0]["columnNumber"].Value(), + "VisibleMethod" + ); } } } From 3deab4b59924da80b828ac016169cc967d2c717e Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz Date: Wed, 3 Nov 2021 13:59:07 +0100 Subject: [PATCH 7/7] Applying thaystg review suggestion. --- src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs index 0edfb15225b4c..cb0a51ccd7804 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs @@ -1302,9 +1302,7 @@ private async Task SetBreakpoint(SessionId sessionId, DebugStore store, Breakpoi SourceLocation loc = sourceId.First(); req.Method = loc.CliLocation.Method; if (req.Method.IsHiddenFromDebugger) - { continue; - } Breakpoint bp = await SetMonoBreakpoint(sessionId, req.Id, loc, req.Condition, token);