Esempio n. 1
0
        private void ctrlDebuggerCode_OnSetNextStatement(ctrlDebuggerCode sender, AddressEventArgs args)
        {
            UInt16 addr = (UInt16)args.Address;

            InteropEmu.DebugSetNextStatement(addr);
            this.UpdateDebugger();
        }
Esempio n. 2
0
        private void UpdateDebugger()
        {
            if (InteropEmu.DebugIsCodeChanged())
            {
                string code = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(InteropEmu.DebugGetCode());
                ctrlDebuggerCode.Code      = code;
                ctrlDebuggerCodeSplit.Code = code;
            }

            DebugState state = new DebugState();

            InteropEmu.DebugGetState(ref state);

            if (UpdateSplitView())
            {
                ctrlDebuggerCodeSplit.UpdateCode(true);
            }
            else
            {
                _lastCodeWindow = ctrlDebuggerCode;
            }

            ctrlDebuggerCode.SelectActiveAddress(state.CPU.DebugPC);
            ctrlDebuggerCodeSplit.SetActiveAddress(state.CPU.DebugPC);
            RefreshBreakpoints();

            ctrlConsoleStatus.UpdateStatus(ref state);
            ctrlWatch.UpdateWatch();
            ctrlCallstack.UpdateCallstack();

            ctrlCpuMemoryMapping.UpdateCpuRegions(state.Cartridge);
            ctrlPpuMemoryMapping.UpdatePpuRegions(state.Cartridge);

            this.BringToFront();
        }
Esempio n. 3
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            tlpMain.SuspendLayout();
            int i = 0;

            foreach (KeyValuePair <string, string> kvp in _values)
            {
                tlpMain.RowStyles.Insert(1, new RowStyle());
                Label lbl = new Label();
                lbl.Margin   = new Padding(2, 3, 2, 2);
                lbl.Text     = kvp.Key + ":";
                lbl.Font     = new Font(lbl.Font, FontStyle.Bold);
                lbl.AutoSize = true;
                tlpMain.SetRow(lbl, i);
                tlpMain.SetColumn(lbl, 0);
                tlpMain.Controls.Add(lbl);

                lbl          = new Label();
                lbl.Font     = new Font(BaseControl.MonospaceFontFamily, 10);
                lbl.Margin   = new Padding(2);
                lbl.AutoSize = true;
                lbl.Text     = kvp.Value;
                tlpMain.SetRow(lbl, i);
                tlpMain.SetColumn(lbl, 1);
                tlpMain.Controls.Add(lbl);

                i++;
            }

            if (_previewAddress >= 0)
            {
                tlpMain.RowStyles.Insert(1, new RowStyle());

                _codeWindow = new ctrlDebuggerCode();
                _codeWindow.HideSelection = true;
                _codeWindow.SetConfig(ConfigManager.Config.DebugInfo.LeftView);
                _codeWindow.Code           = _code;
                _codeWindow.Dock           = DockStyle.Fill;
                _codeWindow.ShowScrollbars = false;
                _codeWindow.ScrollToLineNumber(_previewAddress, true);

                tlpMain.SetRow(_codeWindow, i);
                tlpMain.SetColumn(_codeWindow, 0);
                tlpMain.SetColumnSpan(_codeWindow, 2);
                tlpMain.Controls.Add(_codeWindow);
            }
            tlpMain.ResumeLayout();
            this.Width  = this.tlpMain.Width;
            this.Height = this.tlpMain.Height;
        }
Esempio n. 4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.mnuSplitView.Checked            = ConfigManager.Config.DebugInfo.SplitView;
            this.mnuPpuPartialDraw.Checked       = ConfigManager.Config.DebugInfo.PpuPartialDraw;
            this.mnuShowCpuMemoryMapping.Checked = ConfigManager.Config.DebugInfo.ShowCpuMemoryMapping;
            this.mnuShowPpuMemoryMapping.Checked = ConfigManager.Config.DebugInfo.ShowPpuMemoryMapping;

            _lastCodeWindow = ctrlDebuggerCode;

            this.ctrlDebuggerCode.SetConfig(ConfigManager.Config.DebugInfo.LeftView);
            this.ctrlDebuggerCodeSplit.SetConfig(ConfigManager.Config.DebugInfo.RightView);

            BreakpointManager.Breakpoints.Clear();
            BreakpointManager.Breakpoints.AddRange(ConfigManager.Config.DebugInfo.Breakpoints);
            BreakpointManager.BreakpointsChanged += BreakpointManager_BreakpointsChanged;
            this.ctrlBreakpoints.RefreshList();
            RefreshBreakpoints();

            this.toolTip.SetToolTip(this.picWatchHelp,
                                    "Most expressions/operators are accepted (C++ syntax)." + Environment.NewLine +
                                    "Note: Use the $ prefix to denote hexadecimal values." + Environment.NewLine + Environment.NewLine +
                                    "A/X/Y/PS/SP: Value of registers" + Environment.NewLine +
                                    "Irq/Nmi: True if the Irq/Nmi flags are set" + Environment.NewLine +
                                    "Cycle/Scanline: Current cycle (0-340)/scanline(-1 to 260) of the PPU" + Environment.NewLine +
                                    "Value: Current value being read/written from/to memory" + Environment.NewLine +
                                    "[<address>]: Value at address (CPU)" + Environment.NewLine + Environment.NewLine +

                                    "Examples:" + Environment.NewLine +
                                    "a == 10 || x == $23" + Environment.NewLine +
                                    "scanline == 10 && (cycle >= 55 && cycle <= 100)" + Environment.NewLine +
                                    "x == [$150] || y == [10]" + Environment.NewLine +
                                    "[[$15] + y]   -> Reads the value at address $15, adds Y to it and reads the value at the resulting address."
                                    );

            _notifListener = new InteropEmu.NotificationListener();
            _notifListener.OnNotification += _notifListener_OnNotification;

            InteropEmu.DebugInitialize();

            //Pause a few frames later to give the debugger a chance to disassemble some code
            InteropEmu.DebugStep(30000);

            UpdateCdlRatios();
            tmrCdlRatios.Start();
        }
Esempio n. 5
0
        private void ctrlDebuggerCode_OnScrollToAddress(ctrlDebuggerCode sender, AddressEventArgs args)
        {
            UInt16 addr = (UInt16)args.Address;

            if (sender == ctrlDebuggerCode)
            {
                if (!ConfigManager.Config.DebugInfo.SplitView)
                {
                    mnuSplitView.Checked = true;
                    ConfigManager.Config.DebugInfo.SplitView = true;
                    ConfigManager.ApplyChanges();
                    UpdateDebugger(false);
                }
                ctrlDebuggerCodeSplit.ScrollToLineNumber(addr);
            }
            else
            {
                ctrlDebuggerCode.ScrollToLineNumber(addr);
            }
        }
Esempio n. 6
0
            public ScrollbarColorProvider(ctrlDebuggerCode code)
            {
                _code = code;
                DebugInfo info = ConfigManager.Config.DebugInfo;
                int       len  = _code._code.AbsoluteLineNumbers.Length;

                AddressTypeInfo addressInfo = new AddressTypeInfo();

                Breakpoint[] breakpoints = BreakpointManager.Breakpoints.ToArray();
                for (int i = 0; i < len; i++)
                {
                    _code.SetAddressInfo(addressInfo, i);
                    for (int j = 0; j < breakpoints.Length; j++)
                    {
                        if (breakpoints[j].Matches(_code._code.LineNumbers[i], addressInfo))
                        {
                            Color bpColor = breakpoints[j].BreakOnExec ? info.CodeExecBreakpointColor : (breakpoints[j].BreakOnWrite ? info.CodeWriteBreakpointColor : info.CodeReadBreakpointColor);
                            _breakpointColors[i] = bpColor;
                            break;
                        }
                    }
                }
            }
Esempio n. 7
0
            public ScrollbarColorProvider(ctrlDebuggerCode code)
            {
                _code = code;
                DebugInfo info = ConfigManager.Config.DebugInfo;
                int       len  = _code._absoluteLineNumbers.Count;

                AddressTypeInfo[] addressInfo = new AddressTypeInfo[len];
                for (int i = 0; i < len; i++)
                {
                    addressInfo[i] = _code.GetAddressInfo(i);
                }

                foreach (Breakpoint breakpoint in BreakpointManager.Breakpoints)
                {
                    for (int i = 0; i < len; i++)
                    {
                        if (breakpoint.Matches(_code._lineNumbers[i], ref addressInfo[i]))
                        {
                            Color bpColor = breakpoint.BreakOnExec ? info.CodeExecBreakpointColor : (breakpoint.BreakOnWrite ? info.CodeWriteBreakpointColor : info.CodeReadBreakpointColor);
                            _breakpointColors[i] = bpColor;
                        }
                    }
                }
            }
Esempio n. 8
0
 public LineStyleProvider(ctrlDebuggerCode code)
 {
     _code = code;
 }
Esempio n. 9
0
 private void ctrlDebuggerCodeSplit_Enter(object sender, EventArgs e)
 {
     _lastCodeWindow = ctrlDebuggerCodeSplit;
 }
Esempio n. 10
0
        public void UpdateDebugger(bool updateActiveAddress = true, bool bringToFront = true)
        {
            if (!_debuggerInitialized)
            {
                return;
            }

            ctrlBreakpoints.RefreshListAddresses();
            ctrlLabelList.UpdateLabelListAddresses();
            ctrlFunctionList.UpdateFunctionList(false);
            UpdateDebuggerFlags();
            UpdateVectorAddresses();

            string newCode = InteropEmu.DebugGetCode(_firstBreak);

            if (newCode != null)
            {
                ctrlDebuggerCode.Code = newCode;
            }

            DebugState state = new DebugState();

            InteropEmu.DebugGetState(ref state);

            lblCyclesElapsedCount.Text = (state.CPU.CycleCount - _previousCycle).ToString();
            _previousCycle             = state.CPU.CycleCount;

            if (UpdateSplitView())
            {
                if (newCode != null || ctrlDebuggerCodeSplit.Code == null)
                {
                    ctrlDebuggerCodeSplit.Code = ctrlDebuggerCode.Code;
                }
                ctrlDebuggerCodeSplit.UpdateCode(true);
            }
            else
            {
                _lastCodeWindow = ctrlDebuggerCode;
            }

            if (updateActiveAddress)
            {
                _lastCodeWindow.SelectActiveAddress(state.CPU.DebugPC);
            }

            ctrlDebuggerCode.SetActiveAddress(state.CPU.DebugPC);
            ctrlDebuggerCode.UpdateLineColors();

            if (UpdateSplitView())
            {
                ctrlDebuggerCodeSplit.SetActiveAddress(state.CPU.DebugPC);
                ctrlDebuggerCodeSplit.UpdateLineColors();
            }

            ctrlConsoleStatus.UpdateStatus(ref state);
            ctrlWatch.UpdateWatch();
            ctrlCallstack.UpdateCallstack();

            ctrlCpuMemoryMapping.UpdateCpuRegions(state.Cartridge);
            ctrlPpuMemoryMapping.UpdatePpuRegions(state.Cartridge);

            if (bringToFront)
            {
                this.BringToFront();
            }

            if (_firstBreak)
            {
                InteropEmu.SetFlag(EmulationFlags.ForceMaxSpeed, false);
                if (!ConfigManager.Config.DebugInfo.BreakOnOpen)
                {
                    ResumeExecution();
                }
                _firstBreak = false;
            }
        }
Esempio n. 11
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            _minimumSize = this.MinimumSize;

            if (Program.IsMono)
            {
                //This doesn't work in Mono (menu is blank) - hide it for now
                mnuCode.Visible = false;
            }

            bool debuggerAlreadyRunning = InteropEmu.DebugIsDebuggerRunning();

            ctrlConsoleStatus.OnStateChanged     += ctrlConsoleStatus_OnStateChanged;
            LabelManager.OnLabelUpdated          += LabelManager_OnLabelUpdated;
            BreakpointManager.BreakpointsChanged += BreakpointManager_BreakpointsChanged;
            ctrlProfiler.OnFunctionSelected      += ctrlProfiler_OnFunctionSelected;

            this.InitToolbar();

            this.UpdateWorkspace();
            this.AutoLoadCdlFiles();
            this.AutoLoadDbgFiles(true);

            this.mnuSplitView.Checked                 = ConfigManager.Config.DebugInfo.SplitView;
            this.mnuPpuPartialDraw.Checked            = ConfigManager.Config.DebugInfo.PpuPartialDraw;
            this.mnuPpuShowPreviousFrame.Checked      = ConfigManager.Config.DebugInfo.PpuShowPreviousFrame;
            this.mnuShowEffectiveAddresses.Checked    = ConfigManager.Config.DebugInfo.ShowEffectiveAddresses;
            this.mnuShowCodePreview.Checked           = ConfigManager.Config.DebugInfo.ShowCodePreview;
            this.mnuShowToolbar.Checked               = ConfigManager.Config.DebugInfo.ShowToolbar;
            this.mnuShowCpuMemoryMapping.Checked      = ConfigManager.Config.DebugInfo.ShowCpuMemoryMapping;
            this.mnuShowPpuMemoryMapping.Checked      = ConfigManager.Config.DebugInfo.ShowPpuMemoryMapping;
            this.mnuAutoLoadDbgFiles.Checked          = ConfigManager.Config.DebugInfo.AutoLoadDbgFiles;
            this.mnuAutoLoadCdlFiles.Checked          = ConfigManager.Config.DebugInfo.AutoLoadCdlFiles;
            this.mnuBreakOnReset.Checked              = ConfigManager.Config.DebugInfo.BreakOnReset;
            this.mnuBreakOnOpen.Checked               = ConfigManager.Config.DebugInfo.BreakOnOpen;
            this.mnuBreakOnUnofficialOpcodes.Checked  = ConfigManager.Config.DebugInfo.BreakOnUnofficialOpcodes;
            this.mnuBreakOnBrk.Checked                = ConfigManager.Config.DebugInfo.BreakOnBrk;
            this.mnuBreakOnDebuggerFocus.Checked      = ConfigManager.Config.DebugInfo.BreakOnDebuggerFocus;
            this.mnuDisplayOpCodesInLowerCase.Checked = ConfigManager.Config.DebugInfo.DisplayOpCodesInLowerCase;

            this.mnuDisassembleVerifiedData.Checked     = ConfigManager.Config.DebugInfo.DisassembleVerifiedData;
            this.mnuDisassembleUnidentifiedData.Checked = ConfigManager.Config.DebugInfo.DisassembleUnidentifiedData;

            this.mnuShowVerifiedData.Checked     = ConfigManager.Config.DebugInfo.ShowVerifiedData;
            this.mnuShowUnidentifiedData.Checked = ConfigManager.Config.DebugInfo.ShowUnidentifiedData;

            this.mnuRefreshWatchWhileRunning.Checked = ConfigManager.Config.DebugInfo.RefreshWatchWhileRunning;
            this.mnuShowMemoryValues.Checked         = ConfigManager.Config.DebugInfo.ShowMemoryValuesInCodeWindow;
            ctrlDebuggerCode.ShowMemoryValues        = mnuShowMemoryValues.Checked;
            ctrlDebuggerCodeSplit.ShowMemoryValues   = mnuShowMemoryValues.Checked;

            if (ConfigManager.Config.DebugInfo.WindowWidth > -1)
            {
                this.Width  = ConfigManager.Config.DebugInfo.WindowWidth;
                this.Height = ConfigManager.Config.DebugInfo.WindowHeight;
            }

            tsToolbar.Visible            = mnuShowToolbar.Checked;
            ctrlCpuMemoryMapping.Visible = mnuShowCpuMemoryMapping.Checked;
            ctrlPpuMemoryMapping.Visible = mnuShowPpuMemoryMapping.Checked;

            if (ConfigManager.Config.DebugInfo.LeftPanelWidth > 0)
            {
                this.ctrlSplitContainerTop.SplitterDistance = ConfigManager.Config.DebugInfo.LeftPanelWidth;
            }
            if (ConfigManager.Config.DebugInfo.TopPanelHeight > 0)
            {
                this.splitContainer.SplitterDistance = ConfigManager.Config.DebugInfo.TopPanelHeight;
            }

            if (!ConfigManager.Config.DebugInfo.ShowRightPanel)
            {
                ctrlSplitContainerTop.CollapsePanel();
            }
            else
            {
                mnuShowFunctionLabelLists.Checked = true;
            }

            if (!ConfigManager.Config.DebugInfo.ShowBottomPanel)
            {
                splitContainer.CollapsePanel();
            }
            else
            {
                mnuShowBottomPanel.Checked = true;
            }

            _lastCodeWindow = ctrlDebuggerCode;

            this.ctrlDebuggerCode.SetConfig(ConfigManager.Config.DebugInfo.LeftView);
            this.ctrlDebuggerCodeSplit.SetConfig(ConfigManager.Config.DebugInfo.RightView);

            this.toolTip.SetToolTip(this.picWatchHelp, frmBreakpoint.GetConditionTooltip(true));

            _notifListener = new InteropEmu.NotificationListener();
            _notifListener.OnNotification += _notifListener_OnNotification;

            InteropEmu.DebugInitialize();

            _debuggerInitialized = true;

            DebugState state = new DebugState();

            InteropEmu.DebugGetState(ref state);
            _previousCycle = state.CPU.CycleCount;

            //Pause a few frames later to give the debugger a chance to disassemble some code
            _firstBreak = true;
            if (!debuggerAlreadyRunning)
            {
                InteropEmu.SetFlag(EmulationFlags.ForceMaxSpeed, true);
                InteropEmu.DebugStep(5000);
            }
            else
            {
                //Break once to show code and then resume execution
                InteropEmu.DebugStep(1);
            }
            InteropEmu.SetFlag(EmulationFlags.Paused, false);

            UpdateDebuggerFlags();
            UpdateCdlRatios();
            UpdateFileOptions();

            tmrCdlRatios.Start();
        }