public void RunModeBreakpoints(ITestSettings settings) { this.TestPurpose("Tests setting breakpoints while in run mode"); 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, "-fNonTerminating"); runner.ConfigurationDone(); // Wait a second to ensure the debuggee has entered run mode, then try to set a breakpoint Thread.Sleep(TimeSpan.FromSeconds(1)); this.Comment("Set a function breakpoint while in run mode"); FunctionBreakpoints functionBreakpoints = new FunctionBreakpoints("NonTerminating::DoSleep"); runner.ExpectBreakpointAndStepToTarget(SinkHelper.NonTerminating, startLine: 37, targetLine: 38) .AfterSetFunctionBreakpoints(functionBreakpoints); this.Comment("Remove function breakpoint"); functionBreakpoints.Remove("NonTerminating::DoSleep"); runner.SetFunctionBreakpoints(functionBreakpoints); this.Comment("Continue, set a line breakpoint while in run mode"); runner.Continue(); // Wait a second to ensure the debuggee has entered run mode, then try to set a breakpoint Thread.Sleep(TimeSpan.FromSeconds(1)); runner.Expects.HitBreakpointEvent(SinkHelper.NonTerminating, 28) .AfterSetBreakpoints(debuggee.Breakpoints(SinkHelper.NonTerminating, 28)); this.Comment("Escape loop"); using (IThreadInspector threadInspector = runner.GetThreadInspector()) { IFrameInspector firstFrame = threadInspector.Stack.First(); this.WriteLine(firstFrame.ToString()); firstFrame.GetVariable("this", "shouldExit").Value = "1"; } this.Comment("Continue until end"); runner.Expects.ExitedEvent() .TerminatedEvent() .AfterContinue(); runner.DisconnectAndVerify(); } }
public void AttachAsyncBreak(ITestSettings settings) { this.TestPurpose("Verifies attach and that breakpoints can be set from break mode."); this.WriteSettings(settings); IDebuggee debuggee = SinkHelper.Open(this, settings.CompilerSettings, DebuggeeMonikers.KitchenSink.Attach); Process debuggeeProcess = debuggee.Launch("-fNonTerminating", "-fCalling"); using (ProcessHelper.ProcessCleanup(this, debuggeeProcess)) using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings)) { this.Comment("Attach to debuggee"); runner.Attach(settings.DebuggerSettings, debuggeeProcess); runner.ConfigurationDone(); this.Comment("Attempt to break all"); StoppedEvent breakAllEvent = new StoppedEvent(StoppedReason.Pause); runner.Expects.Event(breakAllEvent) .AfterAsyncBreak(); this.WriteLine("Break all stopped on:"); this.WriteLine(breakAllEvent.ActualEvent.ToString()); this.Comment("Set breakpoint while breaking code."); runner.SetBreakpoints(debuggee.Breakpoints(SinkHelper.NonTerminating, 28)); this.Comment("Start running after the async break (since we have no idea where we are) and then hit the breakpoint"); runner.Expects.HitBreakpointEvent(SinkHelper.NonTerminating, 28) .AfterContinue(); this.Comment("Evaluate the shouldExit member to true to stop the infinite loop."); using (IThreadInspector threadInspector = runner.GetThreadInspector()) { IFrameInspector firstFrame = threadInspector.Stack.First(); this.WriteLine(firstFrame.ToString()); firstFrame.GetVariable("shouldExitLocal").Value = "true"; } this.Comment("Continue until debuggee exists"); runner.Expects.ExitedEvent(exitCode: 0).TerminatedEvent().AfterContinue(); this.Comment("Verify debugger and debuggee closed"); runner.DisconnectAndVerify(); Assert.True(debuggeeProcess.HasExited, "Debuggee still running."); } }
public void ExecutionAsyncBreak(ITestSettings settings) { this.TestPurpose("Verify break all should work run function"); this.WriteSettings(settings); this.Comment("Open the kitchen sink debuggee for execution tests."); IDebuggee debuggee = SinkHelper.Open(this, settings.CompilerSettings, DebuggeeMonikers.KitchenSink.Execution); using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings)) { this.Comment("Configure launch"); runner.Launch(settings.DebuggerSettings, debuggee, "-fNonTerminating", "-fCalling"); this.Comment("Try to break all"); StoppedEvent breakAllEvent = new StoppedEvent(StoppedReason.Pause); runner.Expects.Event(breakAllEvent).AfterAsyncBreak(); this.WriteLine("Break all stopped on:"); this.WriteLine(breakAllEvent.ActualEvent.ToString()); this.Comment("Set a breakpoint while breaking code"); runner.SetBreakpoints(debuggee.Breakpoints(SinkHelper.NonTerminating, 28)); this.Comment("Start running after the async break and then hit the breakpoint"); runner.Expects.HitBreakpointEvent(SinkHelper.NonTerminating, 28).AfterContinue(); this.Comment("Evaluate the shouldExit member to true to stop the infinite loop."); using (IThreadInspector threadInspector = runner.GetThreadInspector()) { IFrameInspector firstFrame = threadInspector.Stack.First(); this.WriteLine(firstFrame.ToString()); firstFrame.GetVariable("shouldExit").Value = "true"; } this.Comment("Continue running at the end of application"); runner.Expects.ExitedEvent().TerminatedEvent().AfterContinue(); this.Comment("Verify debugger and debuggee closed"); runner.DisconnectAndVerify(); } }