From bb149864b657a69c3939e43af13d4f88c404ed2e Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 3 Aug 2021 14:28:57 -0300 Subject: [PATCH 1/2] Fix debugger.break behavior. --- src/mono/mono/mini/interp/interp.c | 1 + .../DebuggerTestSuite/BreakpointTests.cs | 33 +++++++++++++++++-- .../tests/debugger-test/debugger-test2.cs | 4 +++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/mini/interp/interp.c b/src/mono/mono/mini/interp/interp.c index 44d1c70b396bc5..d43b388f1e6f37 100644 --- a/src/mono/mono/mini/interp/interp.c +++ b/src/mono/mono/mini/interp/interp.c @@ -3297,6 +3297,7 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs MINT_IN_BREAK; MINT_IN_CASE(MINT_BREAK) ++ip; + SAVE_INTERP_STATE (frame); do_debugger_tramp (mono_component_debugger ()->user_break, frame); MINT_IN_BREAK; MINT_IN_CASE(MINT_BREAKPOINT) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs index 7bfc088150682f..159335ed6d3234 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs @@ -259,8 +259,37 @@ public async Task BreakOnDebuggerBreak() { await EvaluateAndCheck( "window.setTimeout(function() { invoke_static_method_async('[debugger-test] UserBreak:BreakOnDebuggerBreakCommand'); }, 1);", - "dotnet://debugger-test.dll/debugger-test2.cs", 56, 4, - "BreakOnDebuggerBreakCommand"); + "dotnet://debugger-test.dll/debugger-test2.cs", 56, 8, + "BreakOnDebuggerBreakCommand", + locals_fn: (locals) => + { + CheckNumber(locals, "a", 10); + } + ); + await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test2.cs", 57, 8, "BreakOnDebuggerBreakCommand", + locals_fn: (locals) => + { + CheckNumber(locals, "a", 10); + } + ); + await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test2.cs", 58, 8, "BreakOnDebuggerBreakCommand", + locals_fn: (locals) => + { + CheckNumber(locals, "a", 20); + } + ); + await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test2.cs", 59, 8, "BreakOnDebuggerBreakCommand", + locals_fn: (locals) => + { + CheckNumber(locals, "a", 50); + } + ); + await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test2.cs", 60, 4, "BreakOnDebuggerBreakCommand", + locals_fn: (locals) => + { + CheckNumber(locals, "a", 100); + } + ); } [Fact] diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs b/src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs index b9d97c8e23484b..6a24418e7f9b3f 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs @@ -53,6 +53,10 @@ public static void Types() public class UserBreak { public static void BreakOnDebuggerBreakCommand() { + int a = 10; Debugger.Break(); + a = 20; + a = 50; + a = 100; } } From 37260f854ccaba744d3ee9426a432bc25251e052 Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 3 Aug 2021 14:38:05 -0300 Subject: [PATCH 2/2] Fix line number of other tests that uses Debugger.Break. --- .../wasm/debugger/DebuggerTestSuite/BreakpointTests.cs | 8 ++++---- .../wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs index 159335ed6d3234..c077c2b234ba32 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs @@ -326,10 +326,10 @@ public async Task DebugHotReloadMethodChangedUserBreak() "MethodBody1", "StaticMethod1"); var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); CheckNumber(locals, "a", 10); - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 14, 8, "StaticMethod1"); + pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 12, 16, "StaticMethod1"); locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); CheckNumber(locals, "b", 15); - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 14, 8, "StaticMethod1"); + pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 12, 12, "StaticMethod1"); locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); CheckBool(locals, "c", true); } @@ -344,10 +344,10 @@ public async Task DebugHotReloadMethodUnchanged() "MethodBody2", "StaticMethod1"); var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); CheckNumber(locals, "a", 10); - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 23, 8, "StaticMethod1"); + pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 21, 12, "StaticMethod1"); locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); CheckNumber(locals, "a", 10); - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 23, 8, "StaticMethod1"); + pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 21, 12, "StaticMethod1"); locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); CheckNumber(locals, "a", 10); } diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs index 6b4dcd65900be9..b27e2ee7ea9555 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs @@ -340,7 +340,7 @@ public async Task GetObjectValueWithInheritance() { var pause_location = await EvaluateAndCheck( "window.setTimeout(function() { invoke_static_method('[debugger-test] TestChild:TestWatchWithInheritance'); }, 1);", - "dotnet://debugger-test.dll/debugger-test2.cs", 83, 4, + "dotnet://debugger-test.dll/debugger-test2.cs", 86, 8, "TestWatchWithInheritance"); var frame_id = pause_location["callFrames"][0]["callFrameId"].Value(); var frame_locals = await GetProperties(frame_id);