public void AttachThreadsBreakOneAndSetExitFlag(VisualStudioApp app) { string debugSolution = app.CopyProjectForTest(@"TestData\DebugAttach\DebugAttach.sln"); string startFile = "fg.py"; int breakLine = 8; var dbg2 = (Debugger2)app.Dte.Debugger; SD.Process processToAttach = OpenSolutionAndLaunchFile(app, debugSolution, startFile, "", ""); try { Process2 proc = AttachAndWaitForMode(app, processToAttach, AD7Engine.DebugEngineName, dbgDebugMode.dbgRunMode); dbg2.Breakpoints.Add(File: startFile, Line: breakLine); DebugProjectUITests.WaitForMode(app, dbgDebugMode.dbgBreakMode); dbg2.BreakpointLastHit.Delete(); var x = proc.Threads.Cast <Thread2>() .SelectMany <Thread2, StackFrame>(t => t.StackFrames.Cast <StackFrame>()) .SelectMany <StackFrame, Expression>(f => f.Locals.Cast <Expression>()) .Where(e => e.Name == "exit_flag") .First(); Assert.IsNotNull(x, "Couldn't find a frame with 'exit_flag' defined!"); x.Value = "True"; dbg2.Go(WaitForBreakOrEnd: false); DebugProjectUITests.WaitForMode(app, dbgDebugMode.dbgDesignMode); } finally { if (!processToAttach.HasExited) { processToAttach.Kill(); } } }
public void AttachBasic(VisualStudioApp app) { string debugSolution = app.CopyProjectForTest(@"TestData\DebugAttach\DebugAttach.sln"); string startFile = "Simple.py"; var dbg2 = (Debugger2)app.Dte.Debugger; SD.Process processToAttach = OpenSolutionAndLaunchFile(app, debugSolution, startFile, "", ""); try { AttachAndWaitForMode(app, processToAttach, AD7Engine.DebugEngineName, dbgDebugMode.dbgRunMode); } finally { dbg2.DetachAll(); DebugProjectUITests.WaitForMode(app, dbgDebugMode.dbgDesignMode); if (!processToAttach.HasExited) { processToAttach.Kill(); } } }
private static Process2 AttachAndWaitForMode(VisualStudioApp app, SD.Process processToAttach, object debugEngines, dbgDebugMode expectedMode) { Debugger2 dbg2 = (Debugger2)app.Dte.Debugger; System.Threading.Thread.Sleep(1000); Process2 result = null; Transport t = dbg2.Transports.Item("Default"); bool foundit = false; foreach (Process2 p in dbg2.LocalProcesses) { if (p.ProcessID == processToAttach.Id) { foundit = true; p.Attach2(debugEngines); result = p; break; } } Assert.IsTrue(foundit, "The process to attach [{0}] could not be found in LocalProcesses (did it exit immediately?)", processToAttach.Id); DebugProjectUITests.WaitForMode(app, expectedMode); return(result); }
private static void StartHelloWorldAndBreak(VisualStudioApp app) { DebugProjectUITests.OpenProjectAndBreak(app, @"TestData\MixedModeHelloWorld.sln", "Program.py", 1); }