Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ private async Task<bool> SendCallStack(SessionId sessionId, ExecutionContext con
});
if (!await EvaluateCondition(sessionId, context, context.CallStack.First(), bp, token))
{
context.ClearState();
await SendCommand(sessionId, "Debugger.resume", new JObject(), token);
return true;
}
Expand Down
129 changes: 129 additions & 0 deletions src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,5 +448,134 @@ await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/Me
pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 38, 8, "StaticMethod4");
locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value<string>());
}

[Fact]
public async Task ConditionalBreakpointInALoop()
{
var bp_conditional = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 4, condition:"i == 3");
var bp_check = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 5);
await EvaluateAndCheck(
"window.setTimeout(function() { invoke_static_method('[debugger-test] LoopClass:LoopToBreak'); }, 1);",
"dotnet://debugger-test.dll/debugger-test.cs",
bp_conditional.Value["locations"][0]["lineNumber"].Value<int>(),
bp_conditional.Value["locations"][0]["columnNumber"].Value<int>(),
"LoopToBreak",
locals_fn: (locals) =>
{
CheckNumber(locals, "i", 3);
}
);

await SendCommandAndCheck(null, "Debugger.resume",
null,
bp_check.Value["locations"][0]["lineNumber"].Value<int>(),
bp_check.Value["locations"][0]["columnNumber"].Value<int>(),
"LoopToBreak");
}

[Fact]
public async Task ConditionalBreakpointInALoopStopMoreThanOnce()
{
var bp_conditional = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 4, condition:"i % 3 == 0");
var bp_check = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 5);
await EvaluateAndCheck(
"window.setTimeout(function() { invoke_static_method('[debugger-test] LoopClass:LoopToBreak'); }, 1);",
"dotnet://debugger-test.dll/debugger-test.cs",
bp_conditional.Value["locations"][0]["lineNumber"].Value<int>(),
bp_conditional.Value["locations"][0]["columnNumber"].Value<int>(),
"LoopToBreak",
locals_fn: (locals) =>
{
CheckNumber(locals, "i", 0);
}
);

await SendCommandAndCheck(null, "Debugger.resume",
null,
bp_conditional.Value["locations"][0]["lineNumber"].Value<int>(),
bp_conditional.Value["locations"][0]["columnNumber"].Value<int>(),
"LoopToBreak",
locals_fn: (locals) =>
{
CheckNumber(locals, "i", 3);
});

await SendCommandAndCheck(null, "Debugger.resume",
null,
bp_conditional.Value["locations"][0]["lineNumber"].Value<int>(),
bp_conditional.Value["locations"][0]["columnNumber"].Value<int>(),
"LoopToBreak",
locals_fn: (locals) =>
{
CheckNumber(locals, "i", 6);
});

await SendCommandAndCheck(null, "Debugger.resume",
null,
bp_conditional.Value["locations"][0]["lineNumber"].Value<int>(),
bp_conditional.Value["locations"][0]["columnNumber"].Value<int>(),
"LoopToBreak",
locals_fn: (locals) =>
{
CheckNumber(locals, "i", 9);
});

await SendCommandAndCheck(null, "Debugger.resume",
null,
bp_check.Value["locations"][0]["lineNumber"].Value<int>(),
bp_check.Value["locations"][0]["columnNumber"].Value<int>(),
"LoopToBreak");
}

[Fact]
public async Task ConditionalBreakpointNoStopInALoop()
{
var bp_conditional = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 4, condition:"i == \"10\"");
var bp_check = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 5);
await EvaluateAndCheck(
"window.setTimeout(function() { invoke_static_method('[debugger-test] LoopClass:LoopToBreak'); }, 1);",
"dotnet://debugger-test.dll/debugger-test.cs",
bp_check.Value["locations"][0]["lineNumber"].Value<int>(),
bp_check.Value["locations"][0]["columnNumber"].Value<int>(),
"LoopToBreak"
);
}

[Fact]
public async Task ConditionalBreakpointNotBooleanInALoop()
{
var bp_conditional = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 4, condition:"i + 4");
await EvaluateAndCheck(
"window.setTimeout(function() { invoke_static_method('[debugger-test] LoopClass:LoopToBreak'); }, 1);",
"dotnet://debugger-test.dll/debugger-test.cs",
bp_conditional.Value["locations"][0]["lineNumber"].Value<int>(),
bp_conditional.Value["locations"][0]["columnNumber"].Value<int>(),
"LoopToBreak",
locals_fn: (locals) =>
{
CheckNumber(locals, "i", 0);
}
);

await SendCommandAndCheck(null, "Debugger.resume",
null,
bp_conditional.Value["locations"][0]["lineNumber"].Value<int>(),
bp_conditional.Value["locations"][0]["columnNumber"].Value<int>(),
"LoopToBreak",
locals_fn: (locals) =>
{
CheckNumber(locals, "i", 1);
});

await SendCommandAndCheck(null, "Debugger.resume",
null,
bp_conditional.Value["locations"][0]["lineNumber"].Value<int>(),
bp_conditional.Value["locations"][0]["columnNumber"].Value<int>(),
"LoopToBreak",
locals_fn: (locals) =>
{
CheckNumber(locals, "i", 2);
});
}
}
}
12 changes: 12 additions & 0 deletions src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -770,3 +770,15 @@ public static void CallSetValue()
}
}

public class LoopClass
{
public static void LoopToBreak()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine($"should pause only on i == 3");
}
Console.WriteLine("breakpoint to check");
}
}