public Process Attach(int pid) { if ((debugger != null) || (main_process != null)) { throw new TargetException(TargetError.AlreadyHaveTarget); } if (!IsScript) { Print("Attaching to {0}", pid); } try { debugger = new Debugger(config); new InterpreterEventSink(this, debugger); CommandResult result; current_process = main_process = debugger.Attach(session, pid, out result); current_thread = current_process.MainThread; Wait(result); return(current_process); } catch (TargetException) { debugger.Dispose(); debugger = null; throw; } }
public void StartProcess() { Debugger.Options.StopOnLogMessage = false; if (options.PID != 0) { string clrVersion = string.IsNullOrEmpty(options.CLRVersion) ? MdbgVersionPolicy.GetDefaultAttachVersion(options.PID) : options.CLRVersion; Process = Debugger.Attach(options.PID, null, clrVersion); WriteLine("Attached to " + options.PID); Process.Go().WaitOne(); } else if (!string.IsNullOrEmpty(options.Executable)) { var clrVersion = MdbgVersionPolicy.GetDefaultLaunchVersion(options.Executable); Process = Debugger.Processes.CreateLocalProcess(new CorDebugger(clrVersion)); if (Process == null) { throw new Exception("Could not create debugging interface for runtime version " + clrVersion); } Process.DebugMode = DebugModeFlag.Debug; Process.CreateProcess(options.Executable, configuration.arguments != null ? configuration.arguments : ""); Process.Go().WaitOne(); } else { WriteLine(options.GetUsage()); return; } Console.CancelKeyPress += OnAbort; }
private async Task StartDebugger() { foreach (DocumentTab tab in from tab in _tabs where tab.FileName != null select tab) { tab.SaveIfDirty(); } menuTestGame.Enabled = toolTestGame.Enabled = false; menuDebug.Enabled = toolDebug.Enabled = false; if (TestGame != null) { TestGame(null, EventArgs.Empty); } Debugger = await BuildEngine.Debug(Core.Project); if (Debugger != null) { Debugger.Detached += debugger_Detached; Debugger.Paused += debugger_Paused; Debugger.Resumed += debugger_Resumed; menuTestGame.Enabled = false; toolTestGame.Enabled = false; _isFirstDebugStop = true; if (await Debugger.Attach()) { menuDebug.Text = "&Resume"; toolDebug.Text = "Resume"; var breaks = Core.Project.GetAllBreakpoints(); foreach (string filename in breaks.Keys) { foreach (int lineNumber in breaks[filename]) { await Debugger.SetBreakpoint(filename, lineNumber); } } await Debugger.Resume(); } else { Activate(); MessageBox.Show("Sphere Studio failed to start a debugging session.", "Unable to Start Debugging", MessageBoxButtons.OK, MessageBoxIcon.Error); Debugger = null; UpdateControls(); } } UpdateControls(); }
public MainWindow() { InitializeComponent(); BasePanel.MainWindow = this; BaseDocument.MainWindow = this; dockPanel = new DockPanel(); dockPanel.Dock = System.Windows.Forms.DockStyle.Fill; dockPanel.DockBackColor = System.Drawing.SystemColors.AppWorkspace; dockPanel.DockBottomPortion = 200D; dockPanel.DockLeftPortion = 350D; dockPanel.Name = "dockPanel"; Controls.Add(dockPanel); Controls.SetChildIndex(dockPanel, 0); Debugger = new Debugger((AsyncTask task) => { BeginInvoke(task); }); breakpointsPanel = new BreakpointsPanel(Debugger); callstackPanel = new CallstackPanel(Debugger); codeDocuments.Add(new CodeDocument(Debugger)); filesystemPanel = new FilesystemPanel(Debugger); functionsPanel = new FunctionsPanel(Debugger); heapDocument = new HeapDocument(Debugger); memoryDocuments.Add(new MemoryDocument(Debugger)); modulesPanel = new ModulesPanel(Debugger); profilePanel = new ProfilePanel(Debugger); registersPanels.Add(new RegistersPanel(Debugger, RegisterClass.GuestGeneralPurpose)); registersPanels.Add(new RegistersPanel(Debugger, RegisterClass.GuestFloatingPoint)); registersPanels.Add(new RegistersPanel(Debugger, RegisterClass.GuestVector)); statisticsDocument = new StatisticsDocument(Debugger); threadsPanel = new ThreadsPanel(Debugger); tracePanel = new TracePanel(Debugger); // deserializeDockContent = // new DeserializeDockContent(GetContentFromPersistString); SetupDefaultLayout(); // For hotkeys. KeyPreview = true; Debugger.StateChanged += Debugger_StateChanged; Debugger_StateChanged(this, Debugger.CurrentState); Debugger.CurrentContext.Changed += CurrentContext_Changed; CurrentContext_Changed(Debugger.CurrentContext); Debugger.Attach(); }