public static IAsyncResult BeginLaunch (ProcessStartInfo info, AsyncCallback callback, LaunchOptions options = null) { if (info == null) throw new ArgumentNullException ("info"); Socket socket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Bind (new IPEndPoint (IPAddress.Loopback, 0)); socket.Listen (1000); IPEndPoint ep = (IPEndPoint) socket.LocalEndPoint; // We need to inject our arguments into the psi info.Arguments = string.Format ("{0} --debug --debugger-agent=transport=dt_socket,address={1}:{2}{3} {4}", options == null || !options.Valgrind ? "" : info.FileName, ep.Address, ep.Port, options == null || options.AgentArgs == null ? "" : "," + options.AgentArgs, info.Arguments); if (options != null && options.Valgrind) info.FileName = "valgrind"; ITargetProcess p; if (options != null && options.CustomProcessLauncher != null) p = new ProcessWrapper (options.CustomProcessLauncher (info)); else if (options != null && options.CustomTargetProcessLauncher != null) p = options.CustomTargetProcessLauncher (info); else p = new ProcessWrapper (Process.Start (info)); p.Exited += delegate (object sender, EventArgs eargs) { socket.Close (); }; LaunchCallback c = new LaunchCallback (LaunchInternal); return c.BeginInvoke (p, info, socket, callback, socket); }
public Debugger(ProcessStartInfo info, bool breakInMain) { Contract.Requires(info != null, "info is null"); ActiveObjects.Add(this); m_thread = new DebuggerThread(this, breakInMain); Boss boss = ObjectModel.Create("Application"); m_transcript = boss.Get<ITranscript>(); StepBy = StepSize.Line; var options = new LaunchOptions(); // options.AgentArgs = "loglevel=1,logfile='/Users/jessejones/Source/Continuum/sdb.log'"; // We do this lame assignment to a static so that OnLaunched can be made a static // method. Mono 2.6.7 doesn't GC asynchronously invoked delegates in a timely fashion // (tho it does appear to collect them if more than ten stack up). ms_debugger = this; Unused.Value = VirtualMachineManager.BeginLaunch(info, Debugger.OnLaunched, options); Broadcaster.Register("added breakpoint", this); Broadcaster.Register("removing breakpoint", this); Broadcaster.Register("toggled exceptions", this); ms_running = true; }
public static IAsyncResult BeginLaunch(ProcessStartInfo info, AsyncCallback callback, LaunchOptions options = null) { if (info == null) { throw new ArgumentNullException("info"); } Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Bind(new IPEndPoint(IPAddress.Loopback, 0)); socket.Listen(1000); IPEndPoint ep = (IPEndPoint)socket.LocalEndPoint; // We need to inject our arguments into the psi info.Arguments = string.Format("{0} --debug --debugger-agent=transport=dt_socket,address={1}:{2}{3} {4}", options == null || !options.Valgrind ? "" : info.FileName, ep.Address, ep.Port, options == null || options.AgentArgs == null ? "" : "," + options.AgentArgs, info.Arguments); if (options != null && options.Valgrind) { info.FileName = "valgrind"; } Process p; if (options != null && options.CustomProcessLauncher != null) { p = options.CustomProcessLauncher(info); } else { p = Process.Start(info); } p.Exited += delegate(object sender, EventArgs eargs) { socket.Close(); }; LaunchCallback c = new LaunchCallback(LaunchInternal); return(c.BeginInvoke(p, socket, callback, socket)); }
public static VirtualMachine Launch(ProcessStartInfo info, LaunchOptions options = null) { return(EndLaunch(BeginLaunch(info, null, options))); }
protected override void OnRun (DebuggerStartInfo startInfo) { if (exited) throw new InvalidOperationException ("Already exited"); var dsi = (SoftDebuggerStartInfo) startInfo; var runtime = Path.Combine (Path.Combine (dsi.MonoRuntimePrefix, "bin"), "mono"); RegisterUserAssemblies (dsi.UserAssemblyNames); var psi = new System.Diagnostics.ProcessStartInfo (runtime) { Arguments = string.Format ("\"{0}\" {1}", dsi.Command, dsi.Arguments), WorkingDirectory = dsi.WorkingDirectory, RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, CreateNoWindow = true, }; LaunchOptions options = null; if (dsi.UseExternalConsole && dsi.ExternalConsoleLauncher != null) { options = new LaunchOptions (); options.CustomTargetProcessLauncher = dsi.ExternalConsoleLauncher; psi.RedirectStandardOutput = false; psi.RedirectStandardError = false; } var sdbLog = Environment.GetEnvironmentVariable ("MONODEVELOP_SDB_LOG"); if (!String.IsNullOrEmpty (sdbLog)) { options = options ?? new LaunchOptions (); options.AgentArgs = string.Format ("loglevel=1,logfile='{0}'", sdbLog); } foreach (var env in dsi.MonoRuntimeEnvironmentVariables) psi.EnvironmentVariables[env.Key] = env.Value; foreach (var env in startInfo.EnvironmentVariables) psi.EnvironmentVariables[env.Key] = env.Value; if (!String.IsNullOrEmpty (dsi.LogMessage)) OnDebuggerOutput (false, dsi.LogMessage + "\n"); var callback = HandleConnectionCallbackErrors ((IAsyncResult ar) => { ConnectionStarted (VirtualMachineManager.EndLaunch (ar)); }); ConnectionStarting (VirtualMachineManager.BeginLaunch (psi, callback, options), dsi); }
public static VirtualMachine Launch (string[] args, LaunchOptions options) { ProcessStartInfo pi = new ProcessStartInfo ("mono"); pi.Arguments = String.Join (" ", args); return Launch (pi, options); }
public static VirtualMachine Launch (ProcessStartInfo info, LaunchOptions options) { return EndLaunch (BeginLaunch (info, null, options)); }
public static VirtualMachine Launch(ProcessStartInfo info, LaunchOptions options, TextWriter logWriter = null) { return EndLaunch (BeginLaunch (info, null, options, logWriter)); }
public static VirtualMachine Launch(ProcessStartInfo info, LaunchOptions options, TextWriter logWriter = null) { return(EndLaunch(BeginLaunch(info, null, options, logWriter))); }