int StartCustomTestHost(TestProcessStartInfo startInfo, TestContext currentTestContext) { OperationConsole console = currentTestContext.ExecutionContext.ConsoleFactory.CreateConsole( OperationConsoleFactory.CreateConsoleOptions.Default.WithTitle(GettextCatalog.GetString("Unit Tests"))); ExecutionCommand command; if (runJobInProgress.Project is DotNetProject dnp) { if (dnp.HasFlavor <DotNetCoreProjectExtension> () && dnp.TargetFramework.IsNetCoreApp()) { command = new DotNetCoreExecutionCommand( startInfo.WorkingDirectory, startInfo.FileName, startInfo.Arguments ) { EnvironmentVariables = startInfo.EnvironmentVariables }; ((DotNetCoreExecutionCommand)command).Command = startInfo.FileName; ((DotNetCoreExecutionCommand)command).Arguments = startInfo.Arguments; } else { var portArgument = startInfo.Arguments.IndexOf(" --port", StringComparison.Ordinal); var assembly = startInfo.Arguments.Remove(portArgument - 1).Trim(new char[] { '"' }); var arguments = startInfo.Arguments.Substring(portArgument + 1); command = new DotNetExecutionCommand( assembly, arguments, startInfo.WorkingDirectory, startInfo.EnvironmentVariables ); } } else { command = new NativeExecutionCommand( startInfo.WorkingDirectory, startInfo.FileName, startInfo.Arguments, startInfo.EnvironmentVariables); } runJobInProgress.ProcessOperation = currentTestContext.ExecutionContext.ExecutionHandler.Execute(command, console); var eventProcessSet = new ManualResetEvent(false); runJobInProgress.ProcessOperation.ProcessIdSet += delegate { eventProcessSet.Set(); }; if (runJobInProgress.ProcessOperation.ProcessId == 0) { if (!eventProcessSet.WaitOne(5000) && runJobInProgress.ProcessOperation.ProcessId == 0) { throw new Exception("Timeout, process id not set."); } } return(runJobInProgress.ProcessOperation.ProcessId); }
protected virtual ExecutionCommand CreateExecutionCommand(ConfigurationSelector configSel, ProjectConfiguration configuration) { DotNetExecutionCommand cmd = new DotNetExecutionCommand(FileName); cmd.Arguments = configuration.CommandLineParameters; cmd.WorkingDirectory = Path.GetDirectoryName(FileName); cmd.EnvironmentVariables = new Dictionary <string, string> (configuration.EnvironmentVariables); return(cmd); }
protected DebuggerSession Start(string test) { DotNetExecutionCommand cmd = new DotNetExecutionCommand(); cmd.Command = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "MonoDevelop.Debugger.Tests.TestApp.exe"); cmd.Arguments = test; DebuggerStartInfo si = engine.CreateDebuggerStartInfo(cmd); DebuggerSession session = engine.CreateSession(); DebuggerSessionOptions ops = new DebuggerSessionOptions(); ops.EvaluationOptions = EvaluationOptions.DefaultOptions; ops.EvaluationOptions.EvaluationTimeout = 100000; FilePath path = Util.TestsRootDir; path = path.ParentDirectory.Combine("src", "addins", "MonoDevelop.Debugger", "MonoDevelop.Debugger.Tests.TestApp", "Main.cs").FullPath; TextFile file = TextFile.ReadFile(path); int i = file.Text.IndexOf("void " + test); if (i == -1) { throw new Exception("Test not found: " + test); } i = file.Text.IndexOf("/*break*/", i); if (i == -1) { throw new Exception("Break marker not found: " + test); } int line, col; file.GetLineColumnFromPosition(i, out line, out col); Breakpoint bp = session.Breakpoints.Add(path, line); bp.Enabled = true; ManualResetEvent done = new ManualResetEvent(false); session.OutputWriter = delegate(bool isStderr, string text) { Console.WriteLine("PROC:" + text); }; session.TargetHitBreakpoint += delegate { done.Set(); }; session.Run(si, ops); if (!done.WaitOne(3000)) { throw new Exception("Timeout while waiting for initial breakpoint"); } return(session); }
public void Customize(ExecutionCommand cmd, object data) { DotNetExecutionCommand command = (DotNetExecutionCommand)cmd; MonoExecutionParameters config = (MonoExecutionParameters)data; string opts; config.GenerateOptions(command.EnvironmentVariables, out opts); command.RuntimeArguments = opts; }
protected virtual ExecutionCommand CreateExecutionCommand(ConfigurationSelector configSel, DotNetProjectConfiguration configuration) { DotNetExecutionCommand cmd = new DotNetExecutionCommand(configuration.CompiledOutputName); cmd.Arguments = configuration.CommandLineParameters; cmd.WorkingDirectory = Path.GetDirectoryName(configuration.CompiledOutputName); cmd.EnvironmentVariables = new Dictionary <string, string> (configuration.EnvironmentVariables); cmd.TargetRuntime = TargetRuntime; cmd.UserAssemblyPaths = GetUserAssemblyPaths(configSel); return(cmd); }
protected DebuggerStartInfo CreateStartInfo(string test, string engineId) { var cmd = new DotNetExecutionCommand { TargetRuntime = runtime, Command = TargetExePath, Arguments = test }; var dsi = engine.CreateDebuggerStartInfo(cmd); return(dsi); }
public IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console) { var config = ((PythonExecutionCommand)command).Configuration; var runtime = (IronPythonRuntime)config.Runtime; var args = runtime.GetArguments(config); string dir = Path.GetFullPath(config.ParentItem.BaseDirectory); var cmd = new DotNetExecutionCommand(runtime.Path, String.Join(" ", args), dir, config.EnvironmentVariables); return(cmd.TargetRuntime.GetExecutionHandler().Execute(cmd, console)); }
public ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console) { var cmd = (AspNetExecutionCommand)command; var xspPath = GetXspPath(cmd); var evars = new Dictionary <string, string>(cmd.EnvironmentVariables); foreach (var v in cmd.TargetRuntime.GetToolsExecutionEnvironment(cmd.TargetFramework).Variables) { if (!evars.ContainsKey(v.Key)) { evars.Add(v.Key, v.Value); } } //HACK: work around Mono trying to create registry in non-writable location if (cmd.TargetRuntime is MonoTargetRuntime && !Platform.IsWindows) { evars ["MONO_REGISTRY_PATH"] = UserProfile.Current.TempDir.Combine("aspnet-registry"); } //if it's a script, use a native execution handler if (xspPath.Extension != ".exe") { //set mono debug mode if project's in debug mode if (cmd.DebugMode) { evars ["MONO_OPTIONS"] = "--debug"; } var ncmd = new NativeExecutionCommand( xspPath, cmd.XspParameters.GetXspParameters() + " --nonstop", cmd.BaseDirectory, evars); return(Runtime.ProcessService.GetDefaultExecutionHandler(ncmd).Execute(ncmd, console)); } // Set DEVPATH when running on Windows (notice that this has no effect unless // <developmentMode developerInstallation="true" /> is set in xsp2.exe.config if (cmd.TargetRuntime is MsNetTargetRuntime) { evars["DEVPATH"] = Path.GetDirectoryName(xspPath); } var netCmd = new DotNetExecutionCommand( xspPath, cmd.XspParameters.GetXspParameters() + " --nonstop", cmd.BaseDirectory, evars); netCmd.DebugMode = cmd.DebugMode; return(cmd.TargetRuntime.GetExecutionHandler().Execute(netCmd, console)); }
public bool CanDebugCommand(ExecutionCommand command) { DotNetExecutionCommand cmd = command as DotNetExecutionCommand; if (cmd != null) { return(cmd.TargetRuntime == null || cmd.TargetRuntime.RuntimeId == "MS.NET"); } AspNetExecutionCommand acmd = command as AspNetExecutionCommand; if (acmd != null) { return(acmd.TargetRuntime == null || acmd.TargetRuntime.RuntimeId == "MS.NET"); } return(false); }
public IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console) { var cmd = (AspNetExecutionCommand)command; var xspName = GetXspName(cmd); var xspPath = GetXspPath(cmd, xspName); if (xspPath.IsNullOrEmpty || !File.Exists(xspPath)) { throw new UserException(string.Format("The \"{0}\" web server cannot be started. Please ensure that it is installed.", xspName), null); } //if it's a script, use a native execution handler if (xspPath.Extension != ".exe") { //set mono debug mode if project's in debug mode var envVars = cmd.TargetRuntime.GetToolsExecutionEnvironment(cmd.TargetFramework).Variables; if (cmd.DebugMode) { envVars = new Dictionary <string, string> (envVars); envVars ["MONO_OPTIONS"] = "--debug"; } var ncmd = new NativeExecutionCommand( xspPath, cmd.XspParameters.GetXspParameters() + " --nonstop", cmd.BaseDirectory, envVars); return(Runtime.ProcessService.GetDefaultExecutionHandler(ncmd).Execute(ncmd, console)); } // Set DEVPATH when running on Windows (notice that this has no effect unless // <developmentMode developerInstallation="true" /> is set in xsp2.exe.config var evars = cmd.TargetRuntime.GetToolsExecutionEnvironment(cmd.TargetFramework).Variables; if (cmd.TargetRuntime is MsNetTargetRuntime) { evars["DEVPATH"] = Path.GetDirectoryName(xspPath); } var netCmd = new DotNetExecutionCommand( xspPath, cmd.XspParameters.GetXspParameters() + " --nonstop", cmd.BaseDirectory, evars); netCmd.DebugMode = cmd.DebugMode; return(cmd.TargetRuntime.GetExecutionHandler().Execute(netCmd, console)); }
public DebuggerStartInfo CreateDebuggerStartInfo(ExecutionCommand command) { DotNetExecutionCommand cmd = (DotNetExecutionCommand)command; MonoDebuggerStartInfo startInfo = CreateDebuggerStartInfo(cmd.TargetRuntime); startInfo.Command = cmd.Command; startInfo.Arguments = cmd.Arguments; startInfo.WorkingDirectory = cmd.WorkingDirectory; if (cmd.EnvironmentVariables.Count > 0) { foreach (KeyValuePair <string, string> val in cmd.EnvironmentVariables) { startInfo.EnvironmentVariables [val.Key] = val.Value; } } return(startInfo); }
public static IAsyncOperation ProfileProcess(IProfiler profiler, Process process) { if (IdeApp.ProjectOperations.CurrentRunOperation != null && !IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted) { return(IdeApp.ProjectOperations.CurrentRunOperation); } SwitchWorkbenchContext(ProfileWorkbenchContext); string workingDir = ProfilingService.GetProcessDirectory(process.Id); IExecutionHandler handler = profiler.GetProcessExecutionHandlerFactory(process); DotNetExecutionCommand cmd = new DotNetExecutionCommand(); cmd.WorkingDirectory = workingDir; return(handler.Execute(cmd, null /*context.ConsoleFactory.CreateConsole (true)*/)); }
public override IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console) { DummyProcessAsyncOperation dpao = new DummyProcessAsyncOperation(process); string profilerIdentifier, tempFile, snapshotFile; ProfilingService.GetProfilerInformation(process.Id, out profilerIdentifier, out tempFile); DotNetExecutionCommand dotcmd = (DotNetExecutionCommand)command; snapshotFile = profiler.GetSnapshotFileName(dotcmd.WorkingDirectory, tempFile); ProfilingService.ActiveProfiler = profiler; ProfilingContext profContext = new ProfilingContext(dpao, snapshotFile); profiler.Start(profContext); return(dpao); }
public override IProcessAsyncOperation Execute (ExecutionCommand command, IConsole console) { DotNetExecutionCommand dotcmd = (DotNetExecutionCommand) command; string tempFile = Path.GetTempFileName (); string snapshotFile = profiler.GetSnapshotFileName (dotcmd.Command, tempFile); string args = string.Format ("--profile={2}:{3} --debug \"{0}\" {1}", dotcmd.Command, dotcmd.Arguments, profiler.Identifier, tempFile); NativeExecutionCommand cmd = new NativeExecutionCommand ("mono", args, dotcmd.WorkingDirectory, dotcmd.EnvironmentVariables); IProcessAsyncOperation pao = base.Execute (cmd, console); ProfilingService.ActiveProfiler = profiler; ProfilingContext profContext = new ProfilingContext (pao, snapshotFile); profiler.Start (profContext); return pao; }
public DebuggerStartInfo CreateDebuggerStartInfo(ExecutionCommand command) { DotNetExecutionCommand cmd = command as DotNetExecutionCommand; if (cmd != null) { DebuggerStartInfo startInfo = new DebuggerStartInfo(); startInfo.Command = cmd.Command; startInfo.Arguments = cmd.Arguments; startInfo.WorkingDirectory = cmd.WorkingDirectory; if (cmd.EnvironmentVariables.Count > 0) { foreach (KeyValuePair <string, string> val in cmd.EnvironmentVariables) { startInfo.EnvironmentVariables[val.Key] = val.Value; } } return(startInfo); } #if ASPNET var acmd = command as AspNetExecutionCommand; if (acmd != null) { DebuggerStartInfo startInfo = new DebuggerStartInfo(); string xspName = AspNetExecutionHandler.GetXspName(acmd); string xspPath = acmd.TargetRuntime.GetToolPath(acmd.TargetFramework, xspName); if (!File.Exists(xspPath)) { throw new UserException(string.Format("The \"{0}\" web server cannot be started. Please ensure that it is installed.", xspName), null); } startInfo.Command = xspPath; startInfo.Arguments = acmd.XspParameters.GetXspParameters() + " --nonstop"; startInfo.WorkingDirectory = acmd.BaseDirectory; // Set DEVPATH when running on Windows (notice that this has no effect unless // <developmentMode developerInstallation="true" /> is set in xsp2.exe.config startInfo.EnvironmentVariables["DEVPATH"] = Path.GetDirectoryName(xspPath); return(startInfo); } #endif throw new NotSupportedException(); }
protected override ExecutionCommand OnCreateExecutionCommand(ConfigurationSelector configSel, DotNetProjectConfiguration configuration, ProjectRunConfiguration runConfiguration) { // Unless we pass a port it will spawn a child host, which won't be followed by the debugger. var cfg = (DotNetProjectConfiguration)Project.GetConfiguration(configSel); var cmd = new DotNetExecutionCommand(FuncExe) { Arguments = "host start -p 7071 --pause-on-error", WorkingDirectory = cfg.OutputDirectory, EnvironmentVariables = cfg.GetParsedEnvironmentVariables(), }; // The Mono Mac filesystem watcher immediate fires a change event on the assembly, // causing the host to shutdown and restart as a new process. // However, it doesn't seem to be possible to disable the host's filesystem watcher. // Instead, force Mono to disable file watching. cmd.EnvironmentVariables ["MONO_MANAGED_WATCHER"] = "disabled"; return(cmd); }
protected void Start(string test) { TargetRuntime runtime; switch (EngineId) { case "MonoDevelop.Debugger.Win32": runtime = Runtime.SystemAssemblyService.GetTargetRuntime("MS.NET"); break; case "Mono.Debugger.Soft": runtime = Runtime.SystemAssemblyService.GetTargetRuntimes() .OfType <MonoTargetRuntime> () .OrderByDescending(o => o.Version) .FirstOrDefault(); break; default: runtime = Runtime.SystemAssemblyService.DefaultRuntime; break; } if (runtime == null) { Assert.Ignore("Runtime not found for: {0}", EngineId); return; } Console.WriteLine("Target Runtime: " + runtime.DisplayRuntimeName + " " + runtime.Version); // main/build/tests FilePath path = Path.GetDirectoryName(GetType().Assembly.Location); var exe = Path.Combine(path, "MonoDevelop.Debugger.Tests.TestApp.exe"); var cmd = new DotNetExecutionCommand(); cmd.TargetRuntime = runtime; cmd.Command = exe; cmd.Arguments = test; if (Platform.IsWindows) { var monoRuntime = runtime as MonoTargetRuntime; if (monoRuntime != null) { var psi = new System.Diagnostics.ProcessStartInfo(Path.Combine(monoRuntime.Prefix, "bin", "pdb2mdb.bat"), cmd.Command); psi.UseShellExecute = false; psi.CreateNoWindow = true; System.Diagnostics.Process.Start(psi).WaitForExit(); } } var dsi = engine.CreateDebuggerStartInfo(cmd); var soft = dsi as SoftDebuggerStartInfo; if (soft != null) { var assemblyName = AssemblyName.GetAssemblyName(exe); soft.UserAssemblyNames = new List <AssemblyName> (); soft.UserAssemblyNames.Add(assemblyName); } Session = engine.CreateSession(); var ops = new DebuggerSessionOptions(); ops.EvaluationOptions = EvaluationOptions.DefaultOptions; ops.EvaluationOptions.AllowTargetInvoke = AllowTargetInvokes; ops.EvaluationOptions.EvaluationTimeout = 100000; path = path.ParentDirectory.ParentDirectory.Combine("src", "addins", "MonoDevelop.Debugger", "MonoDevelop.Debugger.Tests.TestApp", test + ".cs").FullPath; SourceFile = TextFile.ReadFile(path); TestName = test; AddBreakpoint("break"); var done = new ManualResetEvent(false); Session.TargetHitBreakpoint += (sender, e) => { Frame = e.Backtrace.GetFrame(0); lastStoppedPosition = Frame.SourceLocation; targetStoppedEvent.Set(); done.Set(); }; Session.TargetExceptionThrown += (sender, e) => { Frame = e.Backtrace.GetFrame(0); for (int i = 0; i < e.Backtrace.FrameCount; i++) { if (!e.Backtrace.GetFrame(i).IsExternalCode) { Frame = e.Backtrace.GetFrame(i); break; } } lastStoppedPosition = Frame.SourceLocation; targetStoppedEvent.Set(); }; Session.TargetStopped += (sender, e) => { Frame = e.Backtrace.GetFrame(0); lastStoppedPosition = Frame.SourceLocation; targetStoppedEvent.Set(); }; var targetExited = new ManualResetEvent(false); Session.TargetExited += delegate { targetExited.Set(); }; Session.Run(dsi, ops); switch (WaitHandle.WaitAny(new WaitHandle[] { done, targetExited }, 30000)) { case 0: //Breakpoint is hit good... run tests now break; case 1: throw new Exception("Test application exited before hitting breakpoint"); default: throw new Exception("Timeout while waiting for initial breakpoint"); } }
public bool CanDebugCommand(ExecutionCommand command) { DotNetExecutionCommand cmd = command as DotNetExecutionCommand; return(cmd != null && DebuggingSupported(cmd.TargetRuntime)); }
protected virtual DebuggerSession CreateSession(string test, string engineId) { switch (engineId) { case "MonoDevelop.Debugger.Win32": runtime = Runtime.SystemAssemblyService.GetTargetRuntime("MS.NET"); break; case "Mono.Debugger.Soft": runtime = Runtime.SystemAssemblyService.GetTargetRuntimes() .OfType <MonoTargetRuntime> () .OrderByDescending((o) => { //Attempt to find latest version of Mono registred in IDE and use that for unit tests if (string.IsNullOrWhiteSpace(o.Version) || o.Version == "Unknown") { return(new Version(0, 0, 0, 0)); } int indexOfBeforeDetails = o.Version.IndexOf(" (", StringComparison.Ordinal); string hopefullyVersion; if (indexOfBeforeDetails != -1) { hopefullyVersion = o.Version.Remove(indexOfBeforeDetails); } else { hopefullyVersion = o.Version; } if (Version.TryParse(hopefullyVersion, out var version)) { return(version); } return(new Version(0, 0, 0, 0)); }).FirstOrDefault(); break; default: runtime = Runtime.SystemAssemblyService.DefaultRuntime; break; } if (runtime == null) { Assert.Ignore("Runtime not found for: {0}", engineId); } Console.WriteLine("Target Runtime: " + runtime.DisplayRuntimeName + " " + runtime.Version + " " + (IntPtr.Size == 8 ? "64bit" : "32bit")); // main/build/tests var exe = TargetExePath; var cmd = new DotNetExecutionCommand(); cmd.TargetRuntime = runtime; cmd.Command = exe; cmd.Arguments = test; if (Platform.IsWindows) { var monoRuntime = runtime as MonoTargetRuntime; if (monoRuntime != null) { var psi = new ProcessStartInfo(Path.Combine(monoRuntime.Prefix, "bin", "pdb2mdb.bat"), exe); psi.UseShellExecute = false; psi.CreateNoWindow = true; Process.Start(psi).WaitForExit(); } } return(engine.CreateSession()); }
protected DebuggerSession Start(string test) { TargetRuntime runtime; switch (EngineId) { case "MonoDevelop.Debugger.Win32": runtime = Runtime.SystemAssemblyService.GetTargetRuntime("MS.NET"); break; case "Mono.Debugger.Soft": runtime = Runtime.SystemAssemblyService.GetTargetRuntime("Mono"); break; default: runtime = Runtime.SystemAssemblyService.DefaultRuntime; break; } if (runtime == null) { return(null); } var cmd = new DotNetExecutionCommand(); cmd.Command = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "MonoDevelop.Debugger.Tests.TestApp.exe"); cmd.Arguments = test; cmd.TargetRuntime = runtime; DebuggerStartInfo si = engine.CreateDebuggerStartInfo(cmd); DebuggerSession session = engine.CreateSession(); var ops = new DebuggerSessionOptions(); ops.EvaluationOptions = EvaluationOptions.DefaultOptions; ops.EvaluationOptions.EvaluationTimeout = 100000; FilePath path = Util.TestsRootDir; path = path.ParentDirectory.Combine("src", "addins", "MonoDevelop.Debugger", "MonoDevelop.Debugger.Tests.TestApp", "Main.cs").FullPath; TextFile file = TextFile.ReadFile(path); int i = file.Text.IndexOf("void " + test, StringComparison.Ordinal); if (i == -1) { throw new Exception("Test not found: " + test); } i = file.Text.IndexOf("/*break*/", i, StringComparison.Ordinal); if (i == -1) { throw new Exception("Break marker not found: " + test); } int line, col; file.GetLineColumnFromPosition(i, out line, out col); Breakpoint bp = session.Breakpoints.Add(path, line); bp.Enabled = true; var done = new ManualResetEvent(false); session.OutputWriter = (isStderr, text) => Console.WriteLine("PROC:" + text); session.TargetHitBreakpoint += delegate { done.Set(); }; session.Run(si, ops); if (!done.WaitOne(3000)) { throw new Exception("Timeout while waiting for initial breakpoint"); } return(session); }
protected void Start(string test) { TargetRuntime runtime; switch (EngineId) { case "MonoDevelop.Debugger.Win32": runtime = Runtime.SystemAssemblyService.GetTargetRuntime("MS.NET"); break; case "Mono.Debugger.Soft": runtime = Runtime.SystemAssemblyService.GetTargetRuntimes() .OfType <MonoTargetRuntime> () .OrderByDescending((o) => { //Attempt to find latest version of Mono registred in IDE and use that for unit tests if (string.IsNullOrWhiteSpace(o.Version) || o.Version == "Unknown") { return(new Version(0, 0, 0, 0)); } int indexOfBeforeDetails = o.Version.IndexOf(" (", StringComparison.Ordinal); if (indexOfBeforeDetails == -1) { return(new Version(0, 0, 0, 0)); } string hopefullyVersion = o.Version.Remove(indexOfBeforeDetails); Version version; if (Version.TryParse(hopefullyVersion, out version)) { return(version); } else { return(new Version(0, 0, 0, 0)); } }).FirstOrDefault(); break; default: runtime = Runtime.SystemAssemblyService.DefaultRuntime; break; } if (runtime == null) { Assert.Ignore("Runtime not found for: {0}", EngineId); return; } Console.WriteLine("Target Runtime: " + runtime.DisplayRuntimeName + " " + runtime.Version + " " + (IntPtr.Size == 8 ? "64bit" : "32bit")); // main/build/tests FilePath path = Path.GetDirectoryName(GetType().Assembly.Location); var exe = Path.Combine(path, "MonoDevelop.Debugger.Tests.TestApp.exe"); var cmd = new DotNetExecutionCommand(); cmd.TargetRuntime = runtime; cmd.Command = exe; cmd.Arguments = test; if (Platform.IsWindows) { var monoRuntime = runtime as MonoTargetRuntime; if (monoRuntime != null) { var psi = new System.Diagnostics.ProcessStartInfo(Path.Combine(monoRuntime.Prefix, "bin", "pdb2mdb.bat"), cmd.Command); psi.UseShellExecute = false; psi.CreateNoWindow = true; System.Diagnostics.Process.Start(psi).WaitForExit(); } } var dsi = engine.CreateDebuggerStartInfo(cmd); var soft = dsi as SoftDebuggerStartInfo; if (soft != null) { var assemblyName = AssemblyName.GetAssemblyName(exe); soft.UserAssemblyNames = new List <AssemblyName> (); soft.UserAssemblyNames.Add(assemblyName); } Session = engine.CreateSession(); var ops = new DebuggerSessionOptions(); ops.ProjectAssembliesOnly = true; ops.EvaluationOptions = EvaluationOptions.DefaultOptions; ops.EvaluationOptions.AllowTargetInvoke = AllowTargetInvokes; ops.EvaluationOptions.EvaluationTimeout = 100000; path = path.ParentDirectory.ParentDirectory.Combine("src", "addins", "MonoDevelop.Debugger", "MonoDevelop.Debugger.Tests.TestApp", test + ".cs").FullPath; SourceFile = TextFile.ReadFile(path); TestName = test; AddBreakpoint("break"); var done = new ManualResetEvent(false); Session.TargetHitBreakpoint += (sender, e) => { Frame = e.Backtrace.GetFrame(0); lastStoppedPosition = Frame.SourceLocation; targetStoppedEvent.Set(); done.Set(); }; Session.TargetExceptionThrown += (sender, e) => { Frame = e.Backtrace.GetFrame(0); for (int i = 0; i < e.Backtrace.FrameCount; i++) { if (!e.Backtrace.GetFrame(i).IsExternalCode) { Frame = e.Backtrace.GetFrame(i); break; } } lastStoppedPosition = Frame.SourceLocation; targetStoppedEvent.Set(); }; Session.TargetStopped += (sender, e) => { //This can be null in case of ForcedStop //which is called when exception is thrown //when Continue & Stepping is executed if (e.Backtrace != null) { Frame = e.Backtrace.GetFrame(0); lastStoppedPosition = Frame.SourceLocation; targetStoppedEvent.Set(); } else { Console.WriteLine("e.Backtrace is null"); } }; var targetExited = new ManualResetEvent(false); Session.TargetExited += delegate { targetExited.Set(); }; Session.Run(dsi, ops); Session.ExceptionHandler = (ex) => { Console.WriteLine("Session.ExceptionHandler:" + Environment.NewLine + ex.ToString()); return(true); }; switch (WaitHandle.WaitAny(new WaitHandle[] { done, targetExited }, 30000)) { case 0: //Breakpoint is hit good... run tests now break; case 1: throw new Exception("Test application exited before hitting breakpoint"); default: throw new Exception("Timeout while waiting for initial breakpoint"); } if (Session is SoftDebuggerSession) { Console.WriteLine("SDB protocol version:" + ((SoftDebuggerSession)Session).ProtocolVersion); } }