public override void Execute(object parameter) { if (CurrentDebugger.IsDebugging && CurrentDebugger.IsProcessRunning) { CurrentDebugger.Break(); MainWindow.Instance.SetStatus("Debugging...", Brushes.Red); } }
public override void Execute(object parameter) { if (CurrentDebugger.IsDebugging && !CurrentDebugger.IsProcessRunning) { base.Execute(null); CurrentDebugger.StepOut(); } }
public async void Restart() { if (CurrentDebugger != null) { PrepareToRun(); await CurrentDebugger.ResetAsync(true); } }
void AddBreakpoint(BreakpointBookmark bookmark) { Breakpoint breakpoint = CurrentDebugger.AddBreakpoint(bookmark.FileName, bookmark.LineNumber, 0, bookmark.IsEnabled); bookmark.InternalBreakpointObject = breakpoint; bookmark.IsHealthy = (CurrentProcess == null) || breakpoint.IsSet; bookmark.IsEnabledChanged += delegate { breakpoint.IsEnabled = bookmark.IsEnabled; }; }
public override void Execute(object parameter) { if (CurrentDebugger.IsDebugging && !CurrentDebugger.IsProcessRunning) { CurrentDebugger.Continue(); MainWindow.Instance.SetStatus("Running...", Brushes.Black); } }
public override void Execute(object parameter) { if (CurrentDebugger.IsDebugging) { CurrentDebugger.Detach(); EnableDebuggerUI(true); CurrentDebugger.DebugStopped -= OnDebugStopped; } }
private async void StopDebugSession() { ignoreEvents = true; await CurrentDebugger.StopAsync(); ignoreEvents = false; ResetDebugSession(); }
public async void Pause() { if (CurrentDebugger != null) { if (IsExecuting) { await CurrentDebugger.PauseAsync(); } } }
public async void StepOver() { if (CurrentDebugger != null) { if (!IsExecuting) { PrepareToRun(); await CurrentDebugger.StepOverAsync(); } } }
public async void Continue() { if (CurrentDebugger != null) { if (!IsExecuting) { PrepareToRun(); await CurrentDebugger.ContinueAsync(); } } }
public async Task <VariableObject> ProbeExpressionAsync(string expression) { VariableObject result = null; if (CurrentDebugger.State == DebuggerState.Paused) { result = await CurrentDebugger.CreateWatchAsync(string.Format("probe{0}", CurrentDebugger.GetVariableId()), expression); } return(result); }
public override void Attach(System.Diagnostics.Process existingProcess) { if (existingProcess == null) { return; } if (IsDebugging) { MessageService.ShowMessage(errorDebugging); return; } if (!ServiceInitialized) { InitializeService(); } string version = CurrentDebugger.GetProgramVersion(existingProcess.MainModule.FileName); if (version.StartsWith("v1.0")) { MessageService.ShowMessage("${res:XML.MainMenu.DebugMenu.Error.Net10NotSupported}"); } else { OnDebugStarting(EventArgs.Empty); UpdateBreakpointLines(); try { CurrentProcess = CurrentDebugger.Attach(existingProcess); debugger_ProcessStarted(); attached = true; CurrentProcess.ModuleLoaded += process_Modules_Added; } catch (System.Exception e) { // CORDBG_E_DEBUGGER_ALREADY_ATTACHED if (e is COMException || e is UnauthorizedAccessException) { string msg = StringParser.Parse("${res:XML.MainMenu.DebugMenu.Error.CannotAttachToProcess}"); MessageService.ShowMessage(msg + " " + e.Message); OnDebugStopped(EventArgs.Empty); } else { throw; } } } }
public void StartDebug(IProject project) { if (project?.Debugger != null) { Project = project; Task.Factory.StartNew(async() => { await project.ToolChain.Build(_console, project); //Debugger.DebugMode = true; project.Debugger.Initialise(); _console.WriteLine(); _console.WriteLine("Starting Debugger..."); if (await project.Debugger.StartAsync(project.ToolChain, _console, project)) { Dispatcher.UIThread.InvokeAsync(() => { if (DebugSessionStarted != null) { DebugSessionStarted(this, new EventArgs()); } _shell.CurrentPerspective = Perspective.Debug; }); CurrentDebugger = project.Debugger; await BreakPointManager.GoLiveAsync(); await BreakPointManager.Add(await CurrentDebugger.BreakMainAsync()); await CurrentDebugger.RunAsync(); } else { _console.WriteLine("Unable to connect to debugger."); ResetDebugSession(); } }); } else { _console.WriteLine("No debugger selected."); } }
public override void Detach() { ClassBrowserSupport.Detach(CurrentProcess); CurrentDebugger.Detach(); }
public override void Start(ProcessStartInfo processStartInfo) { if (IsDebugging) { MessageService.ShowMessage(errorDebugging); return; } if (!ServiceInitialized) { InitializeService(); } string version = CurrentDebugger.GetProgramVersion(processStartInfo.FileName); if (version.StartsWith("v1.0")) { MessageService.ShowMessage("${res:XML.MainMenu.DebugMenu.Error.Net10NotSupported}"); } else if (version.StartsWith("v1.1")) { MessageService.ShowMessage(StringParser.Parse("${res:XML.MainMenu.DebugMenu.Error.Net10NotSupported}").Replace("1.0", "1.1")); // } else if (string.IsNullOrEmpty(version)) { // // Not a managed assembly // MessageService.ShowMessage("${res:XML.MainMenu.DebugMenu.Error.BadAssembly}"); } else if (CurrentDebugger.IsKernelDebuggerEnabled) { MessageService.ShowMessage("${res:XML.MainMenu.DebugMenu.Error.KernelDebuggerEnabled}"); } else { attached = false; OnDebugStarting(EventArgs.Empty); UpdateBreakpointLines(); try { CurrentProcess = CurrentDebugger.Start(processStartInfo.FileName, processStartInfo.WorkingDirectory, processStartInfo.Arguments, this.BreakAtBeginning); debugger_ProcessStarted(); } catch (System.Exception e) { // COMException: The request is not supported. (Exception from HRESULT: 0x80070032) // COMException: The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail. (Exception from HRESULT: 0x800736B1) // COMException: The requested operation requires elevation. (Exception from HRESULT: 0x800702E4) // COMException: The directory name is invalid. (Exception from HRESULT: 0x8007010B) // BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1) // UnauthorizedAccessException: Отказано в доступе. (Исключение из HRESULT: 0x80070005 (E_ACCESSDENIED)) if (e is COMException || e is BadImageFormatException || e is UnauthorizedAccessException) { string msg = StringParser.Parse("${res:XML.MainMenu.DebugMenu.Error.CannotStartProcess}"); msg += " " + e.Message; if (e is COMException && ((uint)((COMException)e).ErrorCode == 0x80070032)) { msg += Environment.NewLine + Environment.NewLine; msg += "64-bit debugging is not supported. Please set Project -> Project Options... -> Compiling -> Target CPU to 32bit."; } MessageService.ShowMessage(msg); OnDebugStopped(EventArgs.Empty); } else { throw; } } } }
public DebugManager() { BreakPointManager = new BreakPointManager(); StartDebuggingCommand = ReactiveCommand.Create(); StartDebuggingCommand.Subscribe(async o => { switch (_shell.CurrentPerspective) { case Perspective.Editor: if (o == null) { o = _shell.CurrentSolution.StartupProject; } if (o is IProject) { var masterProject = o as IProject; //WorkspaceViewModel.Instance.SaveAllCommand.Execute(null); Task.Factory.StartNew(async() => { //WorkspaceViewModel.Instance.ExecutingCompileTask = true; if (await masterProject.ToolChain.Build(_console, masterProject)) { //Debugger = masterProject.SelectedDebugAdaptor; if (CurrentDebugger != null) { //await WorkspaceViewModel.Instance.DispatchDebug((Action)(() => { StartDebug(masterProject); } //)); } else { _console.WriteLine( "You have not selected a debug adaptor. Please goto Tools->Options to configure your debug adaptor."); } } //WorkspaceViewModel.Instance.ExecutingCompileTask = false; }); } break; case Perspective.Debug: // Begin dispatch otherwise UI is awaiting debugger. Inversion of control. //WorkspaceViewModel.Instance.BeginDispatchDebug(() => { PrepareToRun(); await CurrentDebugger.ContinueAsync(); } //); break; } } /*, (o) => * { * bool result = false; * * switch (WorkspaceViewModel.Instance.CurrentPerspective) * { * case Perspective.Editor: * if (WorkspaceViewModel.Instance.SolutionExplorer.SelectedProject != null && !WorkspaceViewModel.Instance.ExecutingCompileTask) * { * result = true; * } * break; * * case Perspective.Debug: * result = StepCommandsCanExecute(o); * break; * } * * return result; * }*/ ); RestartDebuggingCommand = ReactiveCommand.Create(); //(o) => WorkspaceViewModel.Instance.CurrentPerspective == Perspective.Debug && Debugger != null && !IsUpdating); RestartDebuggingCommand.Subscribe(_ => { SetDebuggers(currentDebugger); // Begin dispatch other wise ui thread is awaiting the debug thread. Inversion of control. //WorkspaceViewModel.Instance.BeginDispatchDebug(() => { PrepareToRun(); //Debugger.Reset(project.UserData.RunImmediately); } //); }); StopDebuggingCommand = ReactiveCommand.Create(); //(o) => WorkspaceViewModel.Instance.CurrentPerspective == Perspective.Debug && Debugger != null && !IsUpdating); StopDebuggingCommand.Subscribe(_ => { Stop(); }); InterruptDebuggingCommand = ReactiveCommand.Create(); //, (o) => WorkspaceViewModel.Instance.CurrentPerspective == Perspective.Debug && Debugger != null && Debugger.State == DebuggerState.Running && !IsUpdating); InterruptDebuggingCommand.Subscribe(async _ => { await CurrentDebugger.PauseAsync(); }); StepIntoCommand = ReactiveCommand.Create(); //stepcommand can execute. StepIntoCommand.Subscribe(_ => { StepInto(); }); StepInstructionCommand = ReactiveCommand.Create(); // }, StepCommandsCanExecute); StepInstructionCommand.Subscribe(_ => { StepInstruction(); }); StepOverCommand = ReactiveCommand.Create(); // }, StepCommandsCanExecute); StepOverCommand.Subscribe(_ => { StepOver(); }); StepOutCommand = ReactiveCommand.Create(); // , StepCommandsCanExecute); StepOutCommand.Subscribe(_ => { StepOut(); }); }