Пример #1
0
        public static void ToggleBreakpoint(AddressInfo info)
        {
            if (info.Address < 0)
            {
                return;
            }

            Breakpoint breakpoint = BreakpointManager.GetMatchingBreakpoint(info);

            if (breakpoint != null)
            {
                BreakpointManager.RemoveBreakpoint(breakpoint);
            }
            else
            {
                breakpoint = new Breakpoint()
                {
                    Enabled     = true,
                    BreakOnExec = true,
                    Address     = (UInt32)info.Address
                };

                if (info.Type != SnesMemoryType.PrgRom)
                {
                    breakpoint.BreakOnRead  = true;
                    breakpoint.BreakOnWrite = true;
                }

                breakpoint.MemoryType = info.Type;
                BreakpointManager.AddBreakpoint(breakpoint);
            }
        }
Пример #2
0
 public static void ToggleBreakpoint(int address, bool toggleEnabled)
 {
     if (address >= 0)
     {
         Breakpoint breakpoint = BreakpointManager.GetMatchingBreakpoint(address);
         if (breakpoint != null)
         {
             if (toggleEnabled)
             {
                 breakpoint.SetEnabled(!breakpoint.Enabled);
             }
             else
             {
                 BreakpointManager.RemoveBreakpoint(breakpoint);
             }
         }
         else
         {
             breakpoint = new Breakpoint()
             {
                 BreakOnExec       = true,
                 Address           = (UInt32)address,
                 IsAbsoluteAddress = false,
                 Enabled           = true
             };
             BreakpointManager.AddBreakpoint(breakpoint);
         }
     }
 }
Пример #3
0
        public static void EnableDisableBreakpoint(AddressInfo info)
        {
            Breakpoint breakpoint = BreakpointManager.GetMatchingBreakpoint(info);

            if (breakpoint != null)
            {
                breakpoint.SetEnabled(!breakpoint.Enabled);
            }
        }
Пример #4
0
		public static bool EnableDisableBreakpoint(AddressInfo info, CpuType cpuType)
		{
			Breakpoint breakpoint = BreakpointManager.GetMatchingBreakpoint(info, cpuType);
			if(breakpoint != null) {
				breakpoint.SetEnabled(!breakpoint.Enabled);
				return true;
			}
			return false;
		}
Пример #5
0
        private Breakpoint GetCurrentLineBreakpoint()
        {
            AddressTypeInfo addressInfo = GetAddressInfo(ctrlCodeViewer.SelectedLine);

            if (addressInfo.Address >= 0)
            {
                int relativeAddress = InteropEmu.DebugGetRelativeAddress((uint)addressInfo.Address, addressInfo.Type);
                return(BreakpointManager.GetMatchingBreakpoint(relativeAddress, addressInfo));
            }
            return(null);
        }
Пример #6
0
        public static bool EnableDisableBreakpoint(AddressInfo info)
        {
            Breakpoint breakpoint = BreakpointManager.GetMatchingBreakpoint(info);

            if (breakpoint != null)
            {
                breakpoint.SetEnabled(!breakpoint.Enabled);
                return(true);
            }
            return(false);
        }
Пример #7
0
        public static void ToggleBreakpoint(int relativeAddress, AddressTypeInfo info, bool toggleEnabled)
        {
            if (relativeAddress >= 0 || info.Address >= 0)
            {
                Breakpoint breakpoint = BreakpointManager.GetMatchingBreakpoint(relativeAddress, info);
                if (breakpoint != null)
                {
                    if (toggleEnabled)
                    {
                        breakpoint.SetEnabled(!breakpoint.Enabled);
                    }
                    else
                    {
                        BreakpointManager.RemoveBreakpoint(breakpoint);
                    }
                }
                else
                {
                    if (info.Address < 0 || info.Type == AddressType.InternalRam)
                    {
                        breakpoint = new Breakpoint()
                        {
                            MemoryType   = DebugMemoryType.CpuMemory,
                            BreakOnExec  = true,
                            BreakOnRead  = true,
                            BreakOnWrite = true,
                            Address      = (UInt32)relativeAddress,
                            Enabled      = true
                        };
                    }
                    else
                    {
                        breakpoint = new Breakpoint()
                        {
                            Enabled     = true,
                            BreakOnExec = true,
                            Address     = (UInt32)info.Address
                        };

                        if (info.Type != AddressType.PrgRom)
                        {
                            breakpoint.BreakOnRead  = true;
                            breakpoint.BreakOnWrite = true;
                        }

                        breakpoint.MemoryType = info.Type.ToMemoryType();
                    }
                    BreakpointManager.AddBreakpoint(breakpoint);
                }
            }
        }
Пример #8
0
        private void ctrlCodeViewer_MouseDown(object sender, MouseEventArgs e)
        {
            _tooltipManager.Close(true);

            int             relativeAddress = ctrlCodeViewer.GetLineNumberAtPosition(e.Y);
            AddressTypeInfo info            = GetAddressInfo(ctrlCodeViewer.GetLineIndexAtPosition(e.Y));

            _lineBreakpoint = BreakpointManager.GetMatchingBreakpoint(relativeAddress, info);

            if (e.Button == MouseButtons.Left && e.Location.X < this.ctrlCodeViewer.CodeMargin / 4)
            {
                BreakpointManager.ToggleBreakpoint(relativeAddress, info, false);
            }
        }
Пример #9
0
        private void ctrlCodeViewer_MouseDown(object sender, MouseEventArgs e)
        {
            if (_codeTooltip != null)
            {
                _codeTooltip.Close();
                _codeTooltip = null;
            }

            int address = ctrlCodeViewer.GetLineNumberAtPosition(e.Y);

            _lineBreakpoint = BreakpointManager.GetMatchingBreakpoint(address);

            if (e.Button == MouseButtons.Left && e.Location.X < this.ctrlCodeViewer.CodeMargin / 4)
            {
                BreakpointManager.ToggleBreakpoint(address, false);
            }
        }
Пример #10
0
        private void ctrlCodeViewer_MouseDown(object sender, MouseEventArgs e)
        {
            int address = ctrlCodeViewer.GetLineNumberAtPosition(e.Y);

            _lineBreakpoint = BreakpointManager.GetMatchingBreakpoint(address);

            if (e.Location.X < this.ctrlCodeViewer.CodeMargin / 5)
            {
                if (e.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    if (_lineBreakpoint == null)
                    {
                        Breakpoint bp = new Breakpoint();
                        bp.Address     = (UInt32)address;
                        bp.BreakOnExec = true;
                        BreakpointManager.AddBreakpoint(bp);
                    }
                    else
                    {
                        BreakpointManager.RemoveBreakpoint(_lineBreakpoint);
                    }
                }
            }
        }
Пример #11
0
        private void ctrlHexViewer_InitializeContextMenu(object sender, EventArgs evt)
        {
            HexBox hexBox = (HexBox)sender;

            var mnuEditLabel = new ToolStripMenuItem();

            mnuEditLabel.Click += (s, e) => {
                UInt32 address = (UInt32)hexBox.SelectionStart;
                if (this._memoryType == DebugMemoryType.CpuMemory)
                {
                    AddressTypeInfo info = new AddressTypeInfo();
                    InteropEmu.DebugGetAbsoluteAddressAndType(address, ref info);
                    ctrlLabelList.EditLabel((UInt32)info.Address, info.Type);
                }
                else
                {
                    ctrlLabelList.EditLabel(address, GetAddressType().Value);
                }
            };

            var mnuEditBreakpoint = new ToolStripMenuItem();

            mnuEditBreakpoint.Click += (s, e) => {
                UInt32 startAddress = (UInt32)hexBox.SelectionStart;
                UInt32 endAddress   = (UInt32)(hexBox.SelectionStart + (hexBox.SelectionLength == 0 ? 0 : (hexBox.SelectionLength - 1)));
                BreakpointAddressType addressType = startAddress == endAddress ? BreakpointAddressType.SingleAddress : BreakpointAddressType.AddressRange;

                Breakpoint bp = BreakpointManager.GetMatchingBreakpoint(startAddress, endAddress, this._memoryType == DebugMemoryType.PpuMemory);
                if (bp == null)
                {
                    bp = new Breakpoint()
                    {
                        Address = startAddress, StartAddress = startAddress, EndAddress = endAddress, AddressType = addressType, IsAbsoluteAddress = false
                    };
                    if (this._memoryType == DebugMemoryType.CpuMemory)
                    {
                        bp.BreakOnWrite = bp.BreakOnRead = true;
                    }
                    else
                    {
                        bp.BreakOnWriteVram = bp.BreakOnReadVram = true;
                    }
                }
                BreakpointManager.EditBreakpoint(bp);
            };

            var mnuAddWatch = new ToolStripMenuItem();

            mnuAddWatch.Click += (s, e) => {
                UInt32   startAddress = (UInt32)hexBox.SelectionStart;
                UInt32   endAddress   = (UInt32)(hexBox.SelectionStart + (hexBox.SelectionLength == 0 ? 0 : (hexBox.SelectionLength - 1)));
                string[] toAdd        = Enumerable.Range((int)startAddress, (int)(endAddress - startAddress + 1)).Select((num) => $"[${num.ToString("X4")}]").ToArray();
                WatchManager.AddWatch(toAdd);
            };

            var mnuMarkSelectionAs = new ToolStripMenuItem();
            var mnuMarkAsCode      = new ToolStripMenuItem();

            mnuMarkAsCode.Text   = "Verified Code";
            mnuMarkAsCode.Click += (s, e) => {
                int startAddress = (int)hexBox.SelectionStart;
                int endAddress   = (int)(hexBox.SelectionStart + (hexBox.SelectionLength == 0 ? 0 : (hexBox.SelectionLength - 1)));
                this.MarkSelectionAs(startAddress, endAddress, CdlPrgFlags.Code);
            };
            var mnuMarkAsData = new ToolStripMenuItem();

            mnuMarkAsData.Text   = "Verified Data";
            mnuMarkAsData.Click += (s, e) => {
                int startAddress = (int)hexBox.SelectionStart;
                int endAddress   = (int)(hexBox.SelectionStart + (hexBox.SelectionLength == 0 ? 0 : (hexBox.SelectionLength - 1)));
                this.MarkSelectionAs(startAddress, endAddress, CdlPrgFlags.Data);
            };
            var mnuMarkAsUnidentifiedData = new ToolStripMenuItem();

            mnuMarkAsUnidentifiedData.Text   = "Unidentified Code/Data";
            mnuMarkAsUnidentifiedData.Click += (s, e) => {
                int startAddress = (int)hexBox.SelectionStart;
                int endAddress   = (int)(hexBox.SelectionStart + (hexBox.SelectionLength == 0 ? 0 : (hexBox.SelectionLength - 1)));
                this.MarkSelectionAs(startAddress, endAddress, CdlPrgFlags.None);
            };

            mnuMarkSelectionAs.DropDownItems.Add(mnuMarkAsCode);
            mnuMarkSelectionAs.DropDownItems.Add(mnuMarkAsData);
            mnuMarkSelectionAs.DropDownItems.Add(mnuMarkAsUnidentifiedData);

            var mnuFreeze = new ToolStripMenuItem();

            mnuFreeze.Click += (s, e) => {
                UInt32 startAddress = (UInt32)hexBox.SelectionStart;
                UInt32 endAddress   = (UInt32)(hexBox.SelectionStart + (hexBox.SelectionLength == 0 ? 0 : (hexBox.SelectionLength - 1)));

                for (UInt32 i = startAddress; i <= endAddress; i++)
                {
                    InteropEmu.DebugSetFreezeState((UInt16)i, (bool)mnuFreeze.Tag);
                }
            };

            hexBox.ContextMenuStrip.Opening += (s, e) => {
                UInt32 startAddress = (UInt32)hexBox.SelectionStart;
                UInt32 endAddress   = (UInt32)(hexBox.SelectionStart + (hexBox.SelectionLength == 0 ? 0 : (hexBox.SelectionLength - 1)));

                string address = "$" + startAddress.ToString("X4");
                string addressRange;
                if (startAddress != endAddress)
                {
                    addressRange = "$" + startAddress.ToString("X4") + "-$" + endAddress.ToString("X4");
                }
                else
                {
                    addressRange = address;
                }

                mnuEditLabel.Text      = $"Edit Label ({address})";
                mnuEditBreakpoint.Text = $"Edit Breakpoint ({addressRange})";
                mnuAddWatch.Text       = $"Add to Watch ({addressRange})";

                if (this._memoryType == DebugMemoryType.CpuMemory)
                {
                    bool[] freezeState = InteropEmu.DebugGetFreezeState((UInt16)startAddress, (UInt16)(endAddress - startAddress + 1));
                    if (freezeState.All((frozen) => frozen))
                    {
                        mnuFreeze.Text = $"Unfreeze ({addressRange})";
                        mnuFreeze.Tag  = false;
                    }
                    else
                    {
                        mnuFreeze.Text = $"Freeze ({addressRange})";
                        mnuFreeze.Tag  = true;
                    }
                }
                else
                {
                    mnuFreeze.Text = $"Freeze";
                    mnuFreeze.Tag  = false;
                }

                if (this._memoryType == DebugMemoryType.CpuMemory)
                {
                    int absStart = InteropEmu.DebugGetAbsoluteAddress(startAddress);
                    int absEnd   = InteropEmu.DebugGetAbsoluteAddress(endAddress);

                    if (absStart >= 0 && absEnd >= 0 && absStart <= absEnd)
                    {
                        mnuMarkSelectionAs.Text    = "Mark selection as... (" + addressRange + ")";
                        mnuMarkSelectionAs.Enabled = true;
                    }
                    else
                    {
                        mnuMarkSelectionAs.Text    = "Mark selection as...";
                        mnuMarkSelectionAs.Enabled = false;
                    }
                }
                else if (this._memoryType == DebugMemoryType.PrgRom)
                {
                    mnuMarkSelectionAs.Text    = "Mark selection as... (" + addressRange + ")";
                    mnuMarkSelectionAs.Enabled = true;
                }
                else
                {
                    mnuMarkSelectionAs.Text    = "Mark selection as...";
                    mnuMarkSelectionAs.Enabled = false;
                }

                bool disableEditLabel = false;
                if (this._memoryType == DebugMemoryType.CpuMemory)
                {
                    AddressTypeInfo info = new AddressTypeInfo();
                    InteropEmu.DebugGetAbsoluteAddressAndType(startAddress, ref info);
                    disableEditLabel = info.Address == -1;
                }

                mnuEditLabel.Enabled      = !disableEditLabel && (this._memoryType == DebugMemoryType.CpuMemory || this.GetAddressType().HasValue);
                mnuEditBreakpoint.Enabled = (this._memoryType == DebugMemoryType.CpuMemory || this._memoryType == DebugMemoryType.PpuMemory) && DebugWindowManager.GetDebugger() != null;
                mnuAddWatch.Enabled       = this._memoryType == DebugMemoryType.CpuMemory;
                mnuFreeze.Enabled         = this._memoryType == DebugMemoryType.CpuMemory;
            };

            hexBox.ContextMenuStrip.Items.Insert(0, new ToolStripSeparator());
            hexBox.ContextMenuStrip.Items.Insert(0, mnuFreeze);
            hexBox.ContextMenuStrip.Items.Insert(0, mnuEditLabel);
            hexBox.ContextMenuStrip.Items.Insert(0, mnuEditBreakpoint);
            hexBox.ContextMenuStrip.Items.Insert(0, mnuAddWatch);
            hexBox.ContextMenuStrip.Items.Insert(0, new ToolStripSeparator());
            hexBox.ContextMenuStrip.Items.Insert(0, mnuMarkSelectionAs);
        }