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 BreakpointBinding(ITestSettings settings) { this.TestPurpose("Tests that breakpoints are bound to the correct locations"); 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); SourceBreakpoints callingBreakpoints = debuggee.Breakpoints(SinkHelper.Calling, 11); FunctionBreakpoints functionBreakpoints = new FunctionBreakpoints("Calling::CoreRun"); // VsDbg does not fire Breakpoint Change events when breakpoints are set. // Instead it sends a new breakpoint event when it is bound (after configuration done). bool bindsLate = (settings.DebuggerSettings.DebuggerType == SupportedDebugger.VsDbg); this.Comment("Set a breakpoint at a location that has no executable code, expect it to be moved to the next line"); runner.Expects.ConditionalEvent(!bindsLate, x => x.BreakpointChangedEvent(BreakpointReason.Changed, 12)) .AfterSetBreakpoints(callingBreakpoints); this.Comment("Set a function breakpoint in a class member, expect it to be placed at the opening bracket"); runner.Expects.ConditionalEvent(!bindsLate, x => x.FunctionBreakpointChangedEvent(BreakpointReason.Changed, startLine: 47, endLine: 48)) .AfterSetFunctionBreakpoints(functionBreakpoints); this.Comment("Set a function breakpoint in a non-member, expect it to be placed on the first line of code"); functionBreakpoints.Add("a()"); runner.Expects.ConditionalEvent(!bindsLate, x => x.FunctionBreakpointChangedEvent(BreakpointReason.Changed, startLine: 42, endLine: 43)) .AfterSetFunctionBreakpoints(functionBreakpoints); runner.Expects.ConditionalEvent(bindsLate, x => x.BreakpointChangedEvent(BreakpointReason.Changed, 12) .FunctionBreakpointChangedEvent(BreakpointReason.Changed, startLine: 47, endLine: 48) .FunctionBreakpointChangedEvent(BreakpointReason.Changed, startLine: 42, endLine: 43)) .ExitedEvent() .TerminatedEvent() .AfterConfigurationDone(); runner.DisconnectAndVerify(); } }
public void RemoveAssemblyRelatedBreakpoints(NuGenAssembly assembly) { int index = 0; while (index < FunctionBreakpoints.Count) { NuGenFunctionBreakpointInformation breakpoint = FunctionBreakpoints[index]; if (breakpoint.MethodDefinition.BaseTypeDefinition.ModuleScope.Assembly == assembly) { breakpoint.Remove(); FunctionBreakpoints.Remove(breakpoint); NuGenUIHandler.Instance.RemoveBreakpoint(breakpoint); } else { index++; } } }
public void FunctionBreakpointsBasic(ITestSettings settings) { this.TestPurpose("Tests basic operation of function breakpoints"); 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, "-fCalling"); this.Comment("Set initial function breakpoints"); FunctionBreakpoints functionBreakpoints = new FunctionBreakpoints("Arguments::CoreRun", "Calling::CoreRun", "a()"); runner.SetFunctionBreakpoints(functionBreakpoints); this.Comment("Launch and run until first initial breakpoint"); runner.ExpectBreakpointAndStepToTarget(SinkHelper.Arguments, startLine: 9, targetLine: 10) .AfterConfigurationDone(); this.Comment("Continue until second initial breakpoint"); runner.ExpectBreakpointAndStepToTarget(SinkHelper.Calling, startLine: 47, targetLine: 48) .AfterContinue(); this.Comment("Remove and replace third initial function breakpoint while in break mode"); functionBreakpoints.Remove("a()"); functionBreakpoints.Add("b()"); runner.SetFunctionBreakpoints(functionBreakpoints); this.Comment("Continue until newly-added function breakpoint"); runner.ExpectBreakpointAndStepToTarget(SinkHelper.Calling, startLine: 37, targetLine: 38) .AfterContinue(); this.Comment("Continue until end"); runner.Expects.ExitedEvent() .TerminatedEvent() .AfterContinue(); runner.DisconnectAndVerify(); } }
public void DuplicateBreakpoints(ITestSettings settings) { this.TestPurpose("Tests that duplicate breakpoints are only hit once"); 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, "-fCalling"); // These two breakpoints should resolve to the same line - setting two breakpoints on the same // line directly will throw an exception. SourceBreakpoints callingBreakpoints = debuggee.Breakpoints(SinkHelper.Calling, 11, 12); this.Comment("Set two line breakpoints that resolve to the same source location"); runner.SetBreakpoints(callingBreakpoints); this.Comment("Set duplicate function breakpoints"); FunctionBreakpoints functionBreakpoints = new FunctionBreakpoints("Arguments::CoreRun", "Arguments::CoreRun"); runner.SetFunctionBreakpoints(functionBreakpoints); this.Comment("Run to first breakpoint"); runner.ExpectBreakpointAndStepToTarget(SinkHelper.Arguments, startLine: 9, targetLine: 10) .AfterConfigurationDone(); this.Comment("Run to second breakpoint"); runner.Expects.HitBreakpointEvent(SinkHelper.Calling, 12) .AfterContinue(); this.Comment("Run to completion"); runner.Expects.ExitedEvent() .TerminatedEvent() .AfterContinue(); runner.DisconnectAndVerify(); } }
private void AssociateBreakpointsWithMethods() { if (FunctionBreakpoints != null && FunctionBreakpoints.Count > 0 && Assemblies != null) { if (Assemblies.Count > 0) { int index = 0; while (index < FunctionBreakpoints.Count) { NuGenFunctionBreakpointInformation functionBreakpoint = FunctionBreakpoints[index]; if (functionBreakpoint.AssociateWithMethod()) { index++; } else { FunctionBreakpoints.Remove(functionBreakpoint); } } } else { FunctionBreakpoints.Clear(); } } if (RunToCursorBreakpoint != null) { if (!RunToCursorBreakpoint.AssociateWithMethod()) { RunToCursorBreakpoint.Remove(); RunToCursorBreakpoint = null; } } }
public static void AfterSetFunctionBreakpoints(this IRunBuilder runBuilder, FunctionBreakpoints functionBreakpoints) { runBuilder.AfterCommand(new SetFunctionBreakpointsCommand(functionBreakpoints)); }
public static SetBreakpointsResponseValue SetFunctionBreakpoints(this IDebuggerRunner runner, FunctionBreakpoints breakpoints) { return(runner.RunCommand(new SetFunctionBreakpointsCommand(breakpoints))); }
public void ExecutionStepRecursiveCall(ITestSettings settings) { this.TestPurpose("Verify steps should work when debugging recursive call"); 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, "-fCalling"); this.Comment("Set initial function breakpoints"); FunctionBreakpoints funcBp = new FunctionBreakpoints("Calling::CoreRun()"); runner.SetFunctionBreakpoints(funcBp); this.Comment("Launch and run until hit function breakpoint in the entry of calling"); runner.ExpectBreakpointAndStepToTarget(SinkHelper.Calling, startLine: 47, targetLine: 48).AfterConfigurationDone(); this.Comment("Step over to go to the entry of recursive call"); runner.Expects.HitStepEvent(SinkHelper.Calling, 49).AfterStepOver(); this.Comment("Step in the recursive call"); runner.ExpectStepAndStepToTarget(SinkHelper.Calling, startLine: 25, targetLine: 26).AfterStepIn(); using (IThreadInspector threadInspector = runner.GetThreadInspector()) { this.Comment("Set count = 2"); IFrameInspector currentFrame = threadInspector.Stack.First(); currentFrame.GetVariable("count").Value = "2"; this.Comment("Verify there is only one 'recursiveCall' frames"); threadInspector.AssertStackFrameNames(true, "recursiveCall.*", "Calling::CoreRun.*", "Feature::Run.*", "main.*"); } this.Comment("Step over and then step in the recursive call once again"); runner.Expects.HitStepEvent(SinkHelper.Calling, 29).AfterStepOver(); runner.ExpectStepAndStepToTarget(SinkHelper.Calling, startLine: 25, targetLine: 26).AfterStepIn(); using (IThreadInspector threadInspector = runner.GetThreadInspector()) { this.Comment("Verify there are two 'recursiveCall' frames"); threadInspector.AssertStackFrameNames(true, "recursiveCall.*", "recursiveCall.*", "Calling::CoreRun.*", "Feature::Run.*", "main.*"); this.Comment("Set a source breakpoint in recursive call"); SourceBreakpoints srcBp = debuggee.Breakpoints(SinkHelper.Calling, 26); runner.SetBreakpoints(srcBp); } this.Comment("Step over the recursive call and hit the source breakpoint"); runner.Expects.HitStepEvent(SinkHelper.Calling, 29).AfterStepOver(); runner.Expects.HitBreakpointEvent(SinkHelper.Calling, 26).AfterStepOver(); using (IThreadInspector threadInspector = runner.GetThreadInspector()) { this.Comment("Verify there are three 'recursiveCall' frames"); threadInspector.AssertStackFrameNames(true, "recursiveCall.*", "recursiveCall.*", "recursiveCall.*", "Calling::CoreRun.*", "Feature::Run.*", "main.*"); } this.Comment("Try to step out twice from recursive call"); runner.ExpectStepAndStepToTarget(SinkHelper.Calling, 29, 30).AfterStepOut(); runner.ExpectStepAndStepToTarget(SinkHelper.Calling, 29, 30).AfterStepOut(); using (IThreadInspector threadInspector = runner.GetThreadInspector()) { this.Comment("Verify 'recursiveCall' return back only one frame"); threadInspector.AssertStackFrameNames(true, "recursiveCall.*", "Calling::CoreRun.*", "Feature::Run.*", "main.*"); } this.Comment("Step over from recursive call"); runner.ExpectStepAndStepToTarget(SinkHelper.Calling, 49, 50).AfterStepOver(); using (IThreadInspector threadInspector = runner.GetThreadInspector()) { this.Comment("Verify there is not 'recursiveCall' frame"); threadInspector.AssertStackFrameNames(true, "Calling::CoreRun.*", "Feature::Run.*", "main.*"); } this.Comment("Verify stop debugging"); runner.DisconnectAndVerify(); } }
/// <summary> /// Testing the common targeted scenarios /// </summary> private void RunTargetedScenarios(ITestSettings settings, string outputName, int debuggeeMoniker) { this.Comment("Set initial debuggee"); IDebuggee debuggee = Debuggee.Open(this, settings.CompilerSettings, debuggeeName, debuggeeMoniker, outAppName); using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings)) { this.Comment("Configure launch"); runner.Launch(settings.DebuggerSettings, debuggee); this.Comment("Set initial function breakpoints"); FunctionBreakpoints functionBreakpoints = new FunctionBreakpoints("main", "myClass::DisplayName", "myClass::DisplayAge"); runner.SetFunctionBreakpoints(functionBreakpoints); this.Comment("Set line breakpoints to the lines with entry of shared library"); SourceBreakpoints bps = debuggee.Breakpoints(srcAppName, 71, 77); runner.SetBreakpoints(bps); this.Comment("Launch and run until first breakpoint in the entry of main"); runner.ExpectBreakpointAndStepToTarget(srcAppName, startLine: 62, targetLine: 63) .AfterConfigurationDone(); this.Comment("Continue to go to the line which is the first entry of shared library"); runner.Expects.HitBreakpointEvent(srcAppName, 71) .AfterContinue(); this.Comment("Step into the function in shared library"); runner.Expects.HitStepEvent(srcLibName, 23) .AfterStepIn(); this.Comment("Step out to go back to the entry in main function"); runner.Expects.HitStepEvent(srcAppName, 71) .AfterStepOut(); this.Comment("Step over to go to the line which is the second entry of shared library"); runner.Expects.HitStepEvent(srcAppName, 73).AfterStepOver(); this.Comment("Step over a function which have a breakpoint set in shared library"); runner.ExpectBreakpointAndStepToTarget(srcLibName, startLine: 8, targetLine: 9).AfterStepOver(); this.Comment("Step over a line in function which is inside shared library"); runner.Expects.HitStepEvent(srcLibName, 10).AfterStepOver(); this.Comment("Step out to go back to the entry in main function"); runner.ExpectStepAndStepToTarget(srcAppName, startLine: 73, targetLine: 75).AfterStepOut(); this.Comment("Continue to hit breakpoint in function which is inside shared library"); runner.ExpectBreakpointAndStepToTarget(srcLibName, startLine: 15, targetLine: 16) .AfterContinue(); this.Comment("Continue to hit breakpoint which set in the last entry of shared library"); runner.Expects.HitBreakpointEvent(srcAppName, 77).AfterContinue(); this.Comment("Step over a function which don't have breakpoint set in shared library"); runner.Expects.HitStepEvent(srcAppName, 79) .AfterStepOver(); this.Comment("Continue to run till at the end of the application"); runner.Expects.TerminatedEvent().AfterContinue(); runner.DisconnectAndVerify(); } }