Exemplo n.º 1
0
        private void SetDebuggers(IDebugger debugger)
        {
            BreakPointManager.SetDebugger(debugger);

            if (DebuggerChanged != null)
            {
                DebuggerChanged(this, new EventArgs());
            }
        }
Exemplo n.º 2
0
        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.");
            }
        }
Exemplo n.º 3
0
        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(); });
        }