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 void Shutdown() { if (!m_shutDown) { if (m_vm != null) { // Tell everyone that the debugger is going away. if (ms_running) Broadcaster.Invoke("debugger stopped", this); Broadcaster.Unregister(this); // Force the VM to exit (which should kill the debugee). try { Log.WriteLine(TraceLevel.Info, "Debugger", "Exiting VM"); m_vm.Exit(5); } catch (System.Net.Sockets.SocketException e) { Log.WriteLine(TraceLevel.Warning, "Debugger", "Error exiting VM: {0}", e.Message); } catch (VMDisconnectedException) { } // If the debugee did not exit then give it a bit more time and then // hit it with a big hammer. (The debuggee will die asynchronously // so we'll often land in this code). Process process = m_vm.Process; if (process != null && !process.HasExited) { NSApplication.sharedApplication().BeginInvoke(() => DoKillProcess(process), TimeSpan.FromSeconds(3)); } } m_shutDown = true; m_vm = null; m_thread = null; m_currentThread = null; ms_running = false; } }