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
9 changes: 4 additions & 5 deletions .github/workflows/Build-And-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,10 @@ jobs:
which g++
which gdb
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
# TODO: Try to make core dumps work
# Related CoreDump Tests: https://github.com/microsoft/MIEngine/issues/1170
# echo 1 | sudo tee /proc/sys/kernel/core_uses_pid
# ulimit -S -c unlimited
# sudo sysctl -w kernel.core_pattern=${{ github.workspace }}/core.%e
# Enable core dumps: set pattern to "core" so dumps land in CWD (the debuggee output dir)
echo core | sudo tee /proc/sys/kernel/core_pattern
echo 0 | sudo tee /proc/sys/kernel/core_uses_pid
sudo systemctl disable apport.service 2>/dev/null || true

- run: |
${{ github.workspace }}/eng/Scripts/CI-Build.sh
Expand Down
6 changes: 5 additions & 1 deletion eng/Scripts/CI-Test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ if [ ! -f "$RootDir/bin/DebugAdapterProtocolTests/Debug/CppTests/config.xml" ];
fi
fi

dotnet test "$RootDir"/bin/DebugAdapterProtocolTests/Debug/CppTests/CppTests.dll --logger "trx;LogFileName=$RootDir/bin/DebugAdapterProtocolTests/Debug/CppTests/results.trx"
# Run tests in a subshell with core dumps enabled (ulimit resets when subshell exits)
(
ulimit -c unlimited
dotnet test "$RootDir"/bin/DebugAdapterProtocolTests/Debug/CppTests/CppTests.dll --logger "trx;LogFileName=$RootDir/bin/DebugAdapterProtocolTests/Debug/CppTests/results.trx"
)
3 changes: 1 addition & 2 deletions test/CppTests/Tests/BreakpointTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,8 @@ public void LineLogBreakpointsBasic(ITestSettings settings)
[DependsOnTest(nameof(CompileKitchenSinkForBreakpointTests))]
[RequiresTestSettings]
// TODO: https://github.com/microsoft/MIEngine/issues/1170
// - gdb_gnu
// - lldb
[UnsupportedDebugger(SupportedDebugger.Lldb | SupportedDebugger.Gdb_Gnu | SupportedDebugger.Gdb_Cygwin | SupportedDebugger.Gdb_MinGW, SupportedArchitecture.x64 | SupportedArchitecture.x86)]
[UnsupportedDebugger(SupportedDebugger.Lldb | SupportedDebugger.Gdb_Cygwin | SupportedDebugger.Gdb_MinGW, SupportedArchitecture.x64 | SupportedArchitecture.x86)]
public void RunModeBreakpoints(ITestSettings settings)
{
this.TestPurpose("Tests setting breakpoints while in run mode");
Expand Down
19 changes: 5 additions & 14 deletions test/CppTests/Tests/CoreDumpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ public CoreDumpTests(ITestOutputHelper outputHelper) : base(outputHelper)
[Theory]
[RequiresTestSettings]
[SupportedPlatform(SupportedPlatform.Linux, SupportedArchitecture.x64 | SupportedArchitecture.x86)]
// TODO: https://github.com/microsoft/MIEngine/issues/1170
// - gdb_gnu
[UnsupportedDebugger(SupportedDebugger.Gdb_Gnu, SupportedArchitecture.x64 | SupportedArchitecture.x86)]
public void CoreDumpBasic(ITestSettings settings)
{
this.TestPurpose("This test checks to see if core dump can be launched successfully");
Expand All @@ -69,9 +66,6 @@ public void CoreDumpBasic(ITestSettings settings)
[Theory]
[RequiresTestSettings]
[SupportedPlatform(SupportedPlatform.Linux, SupportedArchitecture.x64 | SupportedArchitecture.x86)]
// TODO: https://github.com/microsoft/MIEngine/issues/1170
// - gdb_gnu
[UnsupportedDebugger(SupportedDebugger.Gdb_Gnu, SupportedArchitecture.x64 | SupportedArchitecture.x86)]
public void CoreDumpBasicMismatchedSourceAndSymbols(ITestSettings settings)
{
this.TestPurpose("This test checks to see if core dump can be launched successfully with mismathed source code.");
Expand All @@ -90,9 +84,6 @@ public void CoreDumpBasicMismatchedSourceAndSymbols(ITestSettings settings)
[Theory]
[RequiresTestSettings]
[SupportedPlatform(SupportedPlatform.Linux, SupportedArchitecture.x64 | SupportedArchitecture.x86)]
// TODO: https://github.com/microsoft/MIEngine/issues/1170
// - gdb_gnu
[UnsupportedDebugger(SupportedDebugger.Gdb_Gnu, SupportedArchitecture.x64 | SupportedArchitecture.x86)]
public void CoreDumpVerifyActions(ITestSettings settings)
{
this.TestPurpose("This test checks to see the behavior when do actions during core dump debugging.");
Expand Down Expand Up @@ -144,32 +135,32 @@ public void CoreDumpVerifyActions(ITestSettings settings)
StepInCommand stepInCommand = new StepInCommand(runner.DarRunner.CurrentThreadId);
runner.RunCommandExpectFailure(stepInCommand);
this.WriteLine(string.Format(CultureInfo.InvariantCulture, "Actual respone message: {0}", stepInCommand.Message));
Assert.Contains(stepInCommand.Message, string.Format(CultureInfo.InvariantCulture, stepError, "step in"));
Assert.Contains(string.Format(CultureInfo.InvariantCulture, stepError, "step in"), stepInCommand.Message);

this.Comment("Try to step over and verify the error message");
StepOverCommand stepOverCommand = new StepOverCommand(runner.DarRunner.CurrentThreadId);
runner.RunCommandExpectFailure(stepOverCommand);
this.WriteLine(string.Format(CultureInfo.InvariantCulture, "Actual respone message: {0}", stepOverCommand.Message));
Assert.Contains(stepOverCommand.Message, string.Format(CultureInfo.InvariantCulture, stepError, "step next"));
Assert.Contains(string.Format(CultureInfo.InvariantCulture, stepError, "step next"), stepOverCommand.Message);

this.Comment("Try to step out and verify the error message");
StepOutCommand stepOutCommand = new StepOutCommand(runner.DarRunner.CurrentThreadId);
runner.RunCommandExpectFailure(stepOutCommand);
this.WriteLine(string.Format(CultureInfo.InvariantCulture, "Actual respone message: {0}", stepOutCommand.Message));
Assert.Contains(stepOutCommand.Message, string.Format(CultureInfo.InvariantCulture, stepError, "step out"));
Assert.Contains(string.Format(CultureInfo.InvariantCulture, stepError, "step out"), stepOutCommand.Message);

this.Comment("Try to continue and verify the error message");
ContinueCommand continueCommand = new ContinueCommand(runner.DarRunner.CurrentThreadId);
runner.RunCommandExpectFailure(continueCommand);
this.WriteLine(string.Format(CultureInfo.InvariantCulture, "Actual respone message: {0}", continueCommand.Message));
Assert.Contains(continueCommand.Message, string.Format(CultureInfo.InvariantCulture, stepError, "continue"));
Assert.Contains(string.Format(CultureInfo.InvariantCulture, stepError, "continue"), continueCommand.Message);

this.Comment("Try to set a breakpoint and verify the error message");
SourceBreakpoints bp = debuggee.Breakpoints(srcAppName, 16);
SetBreakpointsResponseValue setBpResponse = runner.SetBreakpoints(bp);
Assert.False(setBpResponse.body.breakpoints[0].verified);
this.WriteLine(string.Format(CultureInfo.InvariantCulture, "Actual respone message: {0}", setBpResponse.body.breakpoints[0].message));
Assert.Contains(setBpResponse.body.breakpoints[0].message, bpError);
Assert.Contains(bpError, setBpResponse.body.breakpoints[0].message);

this.Comment("Stop core dump debugging");
runner.DisconnectAndVerify();
Expand Down
22 changes: 19 additions & 3 deletions test/CppTests/Tests/ExecutionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ public void ExecutionStepRecursiveCall(ITestSettings settings)
[Theory]
[DependsOnTest(nameof(CompileKitchenSinkForExecution))]
[RequiresTestSettings]
// TODO: Re-enable for VsDbg and Gdb_Gnu
[UnsupportedDebugger(SupportedDebugger.Gdb_Cygwin | SupportedDebugger.Gdb_MinGW | SupportedDebugger.Gdb_Gnu | SupportedDebugger.Lldb | SupportedDebugger.VsDbg, SupportedArchitecture.x86 | SupportedArchitecture.x64)]
// TODO: Re-enable for VsDbg
[UnsupportedDebugger(SupportedDebugger.Gdb_Cygwin | SupportedDebugger.Gdb_MinGW | SupportedDebugger.Lldb | SupportedDebugger.VsDbg, SupportedArchitecture.x86 | SupportedArchitecture.x64)]
public void ExecutionAsyncBreak(ITestSettings settings)
{
this.TestPurpose("Verify break all should work run function");
Expand All @@ -192,6 +192,22 @@ public void ExecutionAsyncBreak(ITestSettings settings)
this.Comment("Configure launch");
runner.Launch(settings.DebuggerSettings, debuggee, "-fNonTerminating", "-fCalling");

// Use a function breakpoint to deterministically confirm the debuggee is running
// before sending async break. Without this, the pause can arrive before GDB has
// fully started the inferior, resulting in no stopped event.
this.Comment("Set a function breakpoint to verify the debuggee enters the loop");
FunctionBreakpoints funcBp = new FunctionBreakpoints("NonTerminating::DoSleep");
runner.SetFunctionBreakpoints(funcBp);

this.Comment("Start running and hit the function breakpoint");
runner.ExpectBreakpointAndStepToTarget(SinkHelper.NonTerminating, startLine: 37, targetLine: 38)
.AfterConfigurationDone();

this.Comment("Remove the function breakpoint and continue so the debuggee is in run mode");
funcBp.Remove("NonTerminating::DoSleep");
runner.SetFunctionBreakpoints(funcBp);
runner.Continue();

this.Comment("Try to break all");
StoppedEvent breakAllEvent = new StoppedEvent(StoppedReason.Pause);
runner.Expects.Event(breakAllEvent).AfterAsyncBreak();
Expand All @@ -210,7 +226,7 @@ public void ExecutionAsyncBreak(ITestSettings settings)
{
IFrameInspector firstFrame = threadInspector.Stack.First();
this.WriteLine(firstFrame.ToString());
firstFrame.GetVariable("shouldExit").Value = "true";
firstFrame.GetVariable("this", "shouldExit").Value = "1";
}

this.Comment("Continue running at the end of application");
Expand Down
Loading