Skip to content

Commit 63a304a

Browse files
authored
[debugger] Fix debugger.break behavior (#56788)
* Fix debugger.break behavior. * Fix line number of other tests that uses Debugger.Break.
1 parent 2bdf376 commit 63a304a

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

src/mono/mono/mini/interp/interp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3297,6 +3297,7 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs
32973297
MINT_IN_BREAK;
32983298
MINT_IN_CASE(MINT_BREAK)
32993299
++ip;
3300+
SAVE_INTERP_STATE (frame);
33003301
do_debugger_tramp (mono_component_debugger ()->user_break, frame);
33013302
MINT_IN_BREAK;
33023303
MINT_IN_CASE(MINT_BREAKPOINT)

src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,37 @@ public async Task BreakOnDebuggerBreak()
259259
{
260260
await EvaluateAndCheck(
261261
"window.setTimeout(function() { invoke_static_method_async('[debugger-test] UserBreak:BreakOnDebuggerBreakCommand'); }, 1);",
262-
"dotnet://debugger-test.dll/debugger-test2.cs", 58, 4,
263-
"BreakOnDebuggerBreakCommand");
262+
"dotnet://debugger-test.dll/debugger-test2.cs", 58, 8,
263+
"BreakOnDebuggerBreakCommand",
264+
locals_fn: (locals) =>
265+
{
266+
CheckNumber(locals, "a", 10);
267+
}
268+
);
269+
await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test2.cs", 59, 8, "BreakOnDebuggerBreakCommand",
270+
locals_fn: (locals) =>
271+
{
272+
CheckNumber(locals, "a", 10);
273+
}
274+
);
275+
await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test2.cs", 60, 8, "BreakOnDebuggerBreakCommand",
276+
locals_fn: (locals) =>
277+
{
278+
CheckNumber(locals, "a", 20);
279+
}
280+
);
281+
await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test2.cs", 61, 8, "BreakOnDebuggerBreakCommand",
282+
locals_fn: (locals) =>
283+
{
284+
CheckNumber(locals, "a", 50);
285+
}
286+
);
287+
await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test2.cs", 62, 4, "BreakOnDebuggerBreakCommand",
288+
locals_fn: (locals) =>
289+
{
290+
CheckNumber(locals, "a", 100);
291+
}
292+
);
264293
}
265294

266295
[Fact]
@@ -297,10 +326,10 @@ public async Task DebugHotReloadMethodChangedUserBreak()
297326
"MethodBody1", "StaticMethod1");
298327
var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
299328
CheckNumber(locals, "a", 10);
300-
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 14, 8, "StaticMethod1");
329+
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 12, 16, "StaticMethod1");
301330
locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
302331
CheckNumber(locals, "b", 15);
303-
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 14, 8, "StaticMethod1");
332+
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 12, 12, "StaticMethod1");
304333
locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
305334
CheckBool(locals, "c", true);
306335
}
@@ -315,10 +344,10 @@ public async Task DebugHotReloadMethodUnchanged()
315344
"MethodBody2", "StaticMethod1");
316345
var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
317346
CheckNumber(locals, "a", 10);
318-
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 23, 8, "StaticMethod1");
347+
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 21, 12, "StaticMethod1");
319348
locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
320349
CheckNumber(locals, "a", 10);
321-
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 23, 8, "StaticMethod1");
350+
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 21, 12, "StaticMethod1");
322351
locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
323352
CheckNumber(locals, "a", 10);
324353
}

src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ public async Task GetObjectValueWithInheritance()
340340
{
341341
var pause_location = await EvaluateAndCheck(
342342
"window.setTimeout(function() { invoke_static_method('[debugger-test] TestChild:TestWatchWithInheritance'); }, 1);",
343-
"dotnet://debugger-test.dll/debugger-test2.cs", 122, 4,
343+
"dotnet://debugger-test.dll/debugger-test2.cs", 125, 8,
344344
"TestWatchWithInheritance");
345345
var frame_id = pause_location["callFrames"][0]["callFrameId"].Value<string>();
346346
var frame_locals = await GetProperties(frame_id);

src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ public static void Types()
5555
public class UserBreak {
5656
public static void BreakOnDebuggerBreakCommand()
5757
{
58+
int a = 10;
5859
Debugger.Break();
60+
a = 20;
61+
a = 50;
62+
a = 100;
5963
}
6064
}
6165

0 commit comments

Comments
 (0)