Skip to content

Commit

Permalink
Fix conditional breakpoints with double quotes (#1249)
Browse files Browse the repository at this point in the history
* Fix conditional breakpoints with double quotes

This PR addresses escaping double quotes for conditional breakpoints
with strings.

* Disable test on macOS lldb
  • Loading branch information
WardenGnaw authored Dec 10, 2021
1 parent 75f267c commit d5a0595
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/MICore/CommandFactories/MICommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public virtual Task<StringBuilder> BuildBreakInsert(string condition, bool enabl
if (condition != null)
{
cmd.Append("-c \"");
cmd.Append(condition);
cmd.Append(EscapeQuotes(condition));
cmd.Append("\" ");
}
if (!enabled)
Expand Down
2 changes: 1 addition & 1 deletion src/MICore/CommandFactories/lldb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async override Task<StringBuilder> BuildBreakInsert(string condition, boo
if (condition != null)
{
cmd.Append("-c \"");
cmd.Append(condition);
cmd.Append(EscapeQuotes(condition));
cmd.Append("\" ");
}
if (!enabled)
Expand Down
38 changes: 38 additions & 0 deletions test/CppTests/Tests/BreakpointTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,44 @@ public void ConditionalBreakpoints(ITestSettings settings)
}
}

[Theory]
[DependsOnTest(nameof(CompileKitchenSinkForBreakpointTests))]
[RequiresTestSettings]
// lldb-mi returns the condition without escaping the quotes.
// >=breakpoint-modified,bkpt={..., cond="str == "hello, world"", ...}
[UnsupportedDebugger(SupportedDebugger.Lldb, SupportedArchitecture.x64 | SupportedArchitecture.x86)]
public void ConditionalStringBreakpoints(ITestSettings settings)
{
this.TestPurpose("Tests that conditional breakpoints on strings work");
this.WriteSettings(settings);

IDebuggee debuggee = SinkHelper.Open(this, settings.CompilerSettings, DebuggeeMonikers.KitchenSink.Breakpoint);

using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings))
{
this.Comment("Configure launch");
runner.Launch(settings.DebuggerSettings, debuggee, "-fExpression");

this.Comment("Set a conditional line with string comparison breakpoint");
SourceBreakpoints callingBreakpoints = new SourceBreakpoints(debuggee, SinkHelper.Expression);
callingBreakpoints.Add(69, "str == \"hello, world\"");
runner.SetBreakpoints(callingBreakpoints);

this.Comment("Run to conditional breakpoint");
runner.Expects.HitBreakpointEvent(null, 69)
.AfterConfigurationDone();

// Skip verifying variable since strings result in "{ ... }"

this.Comment("Run to completion");
runner.Expects.ExitedEvent()
.TerminatedEvent()
.AfterContinue();

runner.DisconnectAndVerify();
}
}

[Theory]
[DependsOnTest(nameof(CompileKitchenSinkForBreakpointTests))]
[RequiresTestSettings]
Expand Down

0 comments on commit d5a0595

Please sign in to comment.