Skip to content

Commit bd35982

Browse files
thaystggithub-actions
authored andcommitted
1 parent 614c782 commit bd35982

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ private async Task<bool> SendCallStack(SessionId sessionId, ExecutionContext con
828828
});
829829
if (!await EvaluateCondition(sessionId, context, context.CallStack.First(), bp, token))
830830
{
831+
context.ClearState();
831832
await SendCommand(sessionId, "Debugger.resume", new JObject(), token);
832833
return true;
833834
}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,5 +448,29 @@ await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/Me
448448
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 38, 8, "StaticMethod4");
449449
locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
450450
}
451+
452+
[Fact]
453+
public async Task ConditionalBreakpointInALoop()
454+
{
455+
var bp_conditional = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 4, condition:"i == 3");
456+
var bp_check = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 5);
457+
await EvaluateAndCheck(
458+
"window.setTimeout(function() { invoke_static_method('[debugger-test] LoopClass:LoopToBreak'); }, 1);",
459+
"dotnet://debugger-test.dll/debugger-test.cs",
460+
bp_conditional.Value["locations"][0]["lineNumber"].Value<int>(),
461+
bp_conditional.Value["locations"][0]["columnNumber"].Value<int>(),
462+
"LoopToBreak",
463+
locals_fn: (locals) =>
464+
{
465+
CheckNumber(locals, "i", 3);
466+
}
467+
);
468+
469+
await SendCommandAndCheck(null, "Debugger.resume",
470+
null,
471+
bp_check.Value["locations"][0]["lineNumber"].Value<int>(),
472+
bp_check.Value["locations"][0]["columnNumber"].Value<int>(),
473+
"LoopToBreak");
474+
}
451475
}
452476
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,3 +770,15 @@ public static void CallSetValue()
770770
}
771771
}
772772

773+
public class LoopClass
774+
{
775+
public static void LoopToBreak()
776+
{
777+
for (int i = 0; i < 10; i++)
778+
{
779+
Console.WriteLine($"should pause only on i == 3");
780+
}
781+
Console.WriteLine("breakpoint to check");
782+
}
783+
}
784+

0 commit comments

Comments
 (0)