public static void RemoveBreakpoint(Breakpoint bp) { _breakpoints.Remove(bp); RefreshBreakpoints(bp); }
public static void AddBreakpoint(Breakpoint bp) { _breakpoints.Add(bp); RefreshBreakpoints(bp); }
private ListViewItem CreateListViewItem(int index) { DebugEventInfo evt = _debugEvents[index]; bool isDma = evt.Operation.Type == MemoryOperationType.DmaWrite || evt.Operation.Type == MemoryOperationType.DmaRead; string details = ""; if (evt.Type == DebugEventType.Breakpoint) { if (evt.BreakpointId >= 0 && evt.BreakpointId < _breakpoints.Count) { Breakpoint bp = _breakpoints[evt.BreakpointId]; details += " Type: " + bp.ToReadableType(); details += " Addresses: " + bp.GetAddressString(true); if (bp.Condition.Length > 0) { details += " Condition: " + bp.Condition; } } } if (isDma) { bool indirectHdma = false; if ((evt.DmaChannel & ctrlEventViewerPpuView.HdmaChannelFlag) != 0) { indirectHdma = evt.DmaChannelInfo.HdmaIndirectAddressing; details += "HDMA #" + (evt.DmaChannel & 0x07).ToString(); details += indirectHdma ? " (indirect)" : ""; } else { details += "DMA #" + (evt.DmaChannel & 0x07).ToString(); } int aBusAddress; if (indirectHdma) { aBusAddress = (evt.DmaChannelInfo.SrcBank << 16) | evt.DmaChannelInfo.TransferSize; } else { aBusAddress = (evt.DmaChannelInfo.SrcBank << 16) | evt.DmaChannelInfo.SrcAddress; } if (!evt.DmaChannelInfo.InvertDirection) { details += " - $" + aBusAddress.ToString("X4") + " -> $" + (0x2100 | evt.DmaChannelInfo.DestAddress).ToString("X4"); } else { details += " - $" + aBusAddress.ToString("X4") + " <- $" + (0x2100 | evt.DmaChannelInfo.DestAddress).ToString("X4"); } } return(new ListViewItem(new string[] { evt.ProgramCounter.ToString("X4"), evt.Scanline.ToString(), evt.Cycle.ToString(), evt.Type.ToString(), evt.Type == DebugEventType.Register ? ("$" + evt.Operation.Address.ToString("X4")) : "", evt.Type == DebugEventType.Register ? ("$" + evt.Operation.Value.ToString("X2")) : "", details })); }
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 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; } 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); }
private void mnuDisableBreakpoint_Click(object sender, EventArgs e) { Breakpoint bp = GetCurrentLineBreakpoint(); bp.SetEnabled(!bp.Enabled); }
public static void EditBreakpoint(Breakpoint bp) { new frmBreakpoint(bp).ShowDialog(); RefreshBreakpoints(bp); }
public frmBreakpoint(Breakpoint breakpoint) { InitializeComponent(); Entity = breakpoint; switch (breakpoint.AddressType) { case BreakpointAddressType.AnyAddress: radAnyAddress.Checked = true; break; case BreakpointAddressType.SingleAddress: radSpecificAddress.Checked = true; break; case BreakpointAddressType.AddressRange: radRange.Checked = true; break; } AddBinding("MemoryType", cboBreakpointType); AddBinding("Enabled", chkEnabled); AddBinding("MarkEvent", chkMarkOnEventViewer); AddBinding("Address", txtAddress); AddBinding("StartAddress", txtFrom); AddBinding("EndAddress", txtTo); AddBinding("BreakOnRead", chkRead); AddBinding("BreakOnWrite", chkWrite); AddBinding("BreakOnExec", chkExec); AddBinding("Condition", txtCondition); cboBreakpointType.Items.Clear(); cboBreakpointType.Items.Add(ResourceHelper.GetEnumText(DebugMemoryType.CpuMemory)); cboBreakpointType.Items.Add(ResourceHelper.GetEnumText(DebugMemoryType.PpuMemory)); cboBreakpointType.Items.Add("-"); if (InteropEmu.DebugGetMemorySize(DebugMemoryType.PrgRom) > 0) { cboBreakpointType.Items.Add(ResourceHelper.GetEnumText(DebugMemoryType.PrgRom)); } if (InteropEmu.DebugGetMemorySize(DebugMemoryType.WorkRam) > 0) { cboBreakpointType.Items.Add(ResourceHelper.GetEnumText(DebugMemoryType.WorkRam)); } if (InteropEmu.DebugGetMemorySize(DebugMemoryType.SaveRam) > 0) { cboBreakpointType.Items.Add(ResourceHelper.GetEnumText(DebugMemoryType.SaveRam)); } if (cboBreakpointType.Items.Count > 3) { cboBreakpointType.Items.Add("-"); } if (InteropEmu.DebugGetMemorySize(DebugMemoryType.ChrRom) > 0) { cboBreakpointType.Items.Add(ResourceHelper.GetEnumText(DebugMemoryType.ChrRom)); } if (InteropEmu.DebugGetMemorySize(DebugMemoryType.ChrRam) > 0) { cboBreakpointType.Items.Add(ResourceHelper.GetEnumText(DebugMemoryType.ChrRam)); } cboBreakpointType.Items.Add(ResourceHelper.GetEnumText(DebugMemoryType.PaletteMemory)); this.toolTip.SetToolTip(this.picExpressionWarning, "Condition contains invalid syntax or symbols."); this.toolTip.SetToolTip(this.picHelp, frmBreakpoint.GetConditionTooltip(false)); }