Debugger: Added right-click options to label/function lists to add a watch/breakpoint
This commit is contained in:
parent
9654cbc5af
commit
0cef4939a4
5 changed files with 134 additions and 15 deletions
|
@ -34,8 +34,10 @@
|
||||||
this.colMemoryAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.colMemoryAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
|
this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||||
this.mnuEditLabel = new System.Windows.Forms.ToolStripMenuItem();
|
this.mnuEditLabel = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.mnuFindOccurrences = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
|
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
|
this.mnuAddBreakpoint = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
|
this.mnuFindOccurrences = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.contextMenuStrip.SuspendLayout();
|
this.contextMenuStrip.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
@ -81,9 +83,11 @@
|
||||||
this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.mnuEditLabel,
|
this.mnuEditLabel,
|
||||||
this.toolStripMenuItem1,
|
this.toolStripMenuItem1,
|
||||||
|
this.mnuAddBreakpoint,
|
||||||
|
this.toolStripMenuItem2,
|
||||||
this.mnuFindOccurrences});
|
this.mnuFindOccurrences});
|
||||||
this.contextMenuStrip.Name = "contextMenuStrip";
|
this.contextMenuStrip.Name = "contextMenuStrip";
|
||||||
this.contextMenuStrip.Size = new System.Drawing.Size(167, 76);
|
this.contextMenuStrip.Size = new System.Drawing.Size(167, 104);
|
||||||
this.contextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip_Opening);
|
this.contextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip_Opening);
|
||||||
//
|
//
|
||||||
// mnuEditLabel
|
// mnuEditLabel
|
||||||
|
@ -95,6 +99,24 @@
|
||||||
this.mnuEditLabel.Text = "Edit Label";
|
this.mnuEditLabel.Text = "Edit Label";
|
||||||
this.mnuEditLabel.Click += new System.EventHandler(this.mnuEditLabel_Click);
|
this.mnuEditLabel.Click += new System.EventHandler(this.mnuEditLabel_Click);
|
||||||
//
|
//
|
||||||
|
// toolStripMenuItem1
|
||||||
|
//
|
||||||
|
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||||
|
this.toolStripMenuItem1.Size = new System.Drawing.Size(163, 6);
|
||||||
|
//
|
||||||
|
// mnuAddBreakpoint
|
||||||
|
//
|
||||||
|
this.mnuAddBreakpoint.Image = global::Mesen.GUI.Properties.Resources.Breakpoint;
|
||||||
|
this.mnuAddBreakpoint.Name = "mnuAddBreakpoint";
|
||||||
|
this.mnuAddBreakpoint.Size = new System.Drawing.Size(166, 22);
|
||||||
|
this.mnuAddBreakpoint.Text = "Add breakpoint";
|
||||||
|
this.mnuAddBreakpoint.Click += new System.EventHandler(this.mnuAddBreakpoint_Click);
|
||||||
|
//
|
||||||
|
// toolStripMenuItem2
|
||||||
|
//
|
||||||
|
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
|
||||||
|
this.toolStripMenuItem2.Size = new System.Drawing.Size(163, 6);
|
||||||
|
//
|
||||||
// mnuFindOccurrences
|
// mnuFindOccurrences
|
||||||
//
|
//
|
||||||
this.mnuFindOccurrences.Image = global::Mesen.GUI.Properties.Resources.Find;
|
this.mnuFindOccurrences.Image = global::Mesen.GUI.Properties.Resources.Find;
|
||||||
|
@ -103,11 +125,6 @@
|
||||||
this.mnuFindOccurrences.Text = "Find Occurrences";
|
this.mnuFindOccurrences.Text = "Find Occurrences";
|
||||||
this.mnuFindOccurrences.Click += new System.EventHandler(this.mnuFindOccurrences_Click);
|
this.mnuFindOccurrences.Click += new System.EventHandler(this.mnuFindOccurrences_Click);
|
||||||
//
|
//
|
||||||
// toolStripMenuItem1
|
|
||||||
//
|
|
||||||
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
|
||||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(163, 6);
|
|
||||||
//
|
|
||||||
// ctrlFunctionList
|
// ctrlFunctionList
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
@ -130,5 +147,7 @@
|
||||||
private System.Windows.Forms.ToolStripMenuItem mnuEditLabel;
|
private System.Windows.Forms.ToolStripMenuItem mnuEditLabel;
|
||||||
private System.Windows.Forms.ToolStripMenuItem mnuFindOccurrences;
|
private System.Windows.Forms.ToolStripMenuItem mnuFindOccurrences;
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
|
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem mnuAddBreakpoint;
|
||||||
|
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,12 +137,14 @@ namespace Mesen.GUI.Debugger.Controls
|
||||||
|
|
||||||
private void mnuFindOccurrences_Click(object sender, EventArgs e)
|
private void mnuFindOccurrences_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
CodeLabel label = lstFunctions.SelectedItems[0].Tag as CodeLabel;
|
if(lstFunctions.SelectedItems.Count > 0) {
|
||||||
if(label != null) {
|
CodeLabel label = lstFunctions.SelectedItems[0].Tag as CodeLabel;
|
||||||
OnFindOccurrence?.Invoke(label.Label, null);
|
if(label != null) {
|
||||||
} else {
|
OnFindOccurrence?.Invoke(label.Label, null);
|
||||||
OnFindOccurrence?.Invoke("$" + ((int)lstFunctions.SelectedItems[0].SubItems[1].Tag).ToString("X4"), null);
|
} else {
|
||||||
}
|
OnFindOccurrence?.Invoke("$" + ((int)lstFunctions.SelectedItems[0].SubItems[1].Tag).ToString("X4"), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void contextMenuStrip_Opening(object sender, CancelEventArgs e)
|
private void contextMenuStrip_Opening(object sender, CancelEventArgs e)
|
||||||
|
@ -150,5 +152,23 @@ namespace Mesen.GUI.Debugger.Controls
|
||||||
mnuEditLabel.Enabled = lstFunctions.SelectedItems.Count == 1;
|
mnuEditLabel.Enabled = lstFunctions.SelectedItems.Count == 1;
|
||||||
mnuFindOccurrences.Enabled = lstFunctions.SelectedItems.Count == 1;
|
mnuFindOccurrences.Enabled = lstFunctions.SelectedItems.Count == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void mnuAddBreakpoint_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if(lstFunctions.SelectedItems.Count > 0) {
|
||||||
|
CodeLabel label = lstFunctions.SelectedItems[0].Tag as CodeLabel;
|
||||||
|
int absoluteAddress = (int)lstFunctions.SelectedItems[0].SubItems[2].Tag;
|
||||||
|
BreakpointManager.AddBreakpoint(new Breakpoint() {
|
||||||
|
BreakOnExec = true,
|
||||||
|
BreakOnRead = false,
|
||||||
|
BreakOnWrite = false,
|
||||||
|
Address = (UInt32)absoluteAddress,
|
||||||
|
StartAddress = (UInt32)absoluteAddress,
|
||||||
|
EndAddress = (UInt32)absoluteAddress,
|
||||||
|
AddressType = BreakpointAddressType.SingleAddress,
|
||||||
|
IsAbsoluteAddress = true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
32
GUI.NET/Debugger/Controls/ctrlLabelList.Designer.cs
generated
32
GUI.NET/Debugger/Controls/ctrlLabelList.Designer.cs
generated
|
@ -38,6 +38,9 @@
|
||||||
this.colFunctionLabel = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.colFunctionLabel = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.colFunctionAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.colFunctionAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.colMemoryAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.colMemoryAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
|
this.mnuAddToWatch = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.mnuAddBreakpoint = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
this.contextMenu.SuspendLayout();
|
this.contextMenu.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
@ -48,9 +51,12 @@
|
||||||
this.mnuEdit,
|
this.mnuEdit,
|
||||||
this.mnuDelete,
|
this.mnuDelete,
|
||||||
this.toolStripMenuItem1,
|
this.toolStripMenuItem1,
|
||||||
|
this.mnuAddBreakpoint,
|
||||||
|
this.mnuAddToWatch,
|
||||||
|
this.toolStripMenuItem2,
|
||||||
this.mnuFindOccurrences});
|
this.mnuFindOccurrences});
|
||||||
this.contextMenu.Name = "contextMenu";
|
this.contextMenu.Name = "contextMenu";
|
||||||
this.contextMenu.Size = new System.Drawing.Size(167, 120);
|
this.contextMenu.Size = new System.Drawing.Size(167, 170);
|
||||||
this.contextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.mnuActions_Opening);
|
this.contextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.mnuActions_Opening);
|
||||||
//
|
//
|
||||||
// mnuAdd
|
// mnuAdd
|
||||||
|
@ -128,6 +134,27 @@
|
||||||
this.colMemoryAddress.Text = "ROM Addr";
|
this.colMemoryAddress.Text = "ROM Addr";
|
||||||
this.colMemoryAddress.Width = 84;
|
this.colMemoryAddress.Width = 84;
|
||||||
//
|
//
|
||||||
|
// mnuAddToWatch
|
||||||
|
//
|
||||||
|
this.mnuAddToWatch.Image = global::Mesen.GUI.Properties.Resources.Add;
|
||||||
|
this.mnuAddToWatch.Name = "mnuAddToWatch";
|
||||||
|
this.mnuAddToWatch.Size = new System.Drawing.Size(166, 22);
|
||||||
|
this.mnuAddToWatch.Text = "Add to watch";
|
||||||
|
this.mnuAddToWatch.Click += new System.EventHandler(this.mnuAddToWatch_Click);
|
||||||
|
//
|
||||||
|
// mnuAddBreakpoint
|
||||||
|
//
|
||||||
|
this.mnuAddBreakpoint.Image = global::Mesen.GUI.Properties.Resources.Breakpoint;
|
||||||
|
this.mnuAddBreakpoint.Name = "mnuAddBreakpoint";
|
||||||
|
this.mnuAddBreakpoint.Size = new System.Drawing.Size(166, 22);
|
||||||
|
this.mnuAddBreakpoint.Text = "Add breakpoint";
|
||||||
|
this.mnuAddBreakpoint.Click += new System.EventHandler(this.mnuAddBreakpoint_Click);
|
||||||
|
//
|
||||||
|
// toolStripMenuItem2
|
||||||
|
//
|
||||||
|
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
|
||||||
|
this.toolStripMenuItem2.Size = new System.Drawing.Size(163, 6);
|
||||||
|
//
|
||||||
// ctrlLabelList
|
// ctrlLabelList
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
@ -152,5 +179,8 @@
|
||||||
private System.Windows.Forms.ToolStripMenuItem mnuEdit;
|
private System.Windows.Forms.ToolStripMenuItem mnuEdit;
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
|
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
|
||||||
private System.Windows.Forms.ToolStripMenuItem mnuFindOccurrences;
|
private System.Windows.Forms.ToolStripMenuItem mnuFindOccurrences;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem mnuAddBreakpoint;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem mnuAddToWatch;
|
||||||
|
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ namespace Mesen.GUI.Debugger.Controls
|
||||||
if(label.Label.Length > 0) {
|
if(label.Label.Length > 0) {
|
||||||
ListViewItem item = new ListViewItem(label.Label);
|
ListViewItem item = new ListViewItem(label.Label);
|
||||||
|
|
||||||
Int32 relativeAddress = InteropEmu.DebugGetRelativeAddress(label.Address, label.AddressType);
|
Int32 relativeAddress = label.GetRelativeAddress();
|
||||||
if(relativeAddress >= 0) {
|
if(relativeAddress >= 0) {
|
||||||
item.SubItems.Add("$" + relativeAddress.ToString("X4"));
|
item.SubItems.Add("$" + relativeAddress.ToString("X4"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -149,6 +149,8 @@ namespace Mesen.GUI.Debugger.Controls
|
||||||
mnuDelete.Enabled = lstLabels.SelectedItems.Count > 0;
|
mnuDelete.Enabled = lstLabels.SelectedItems.Count > 0;
|
||||||
mnuEdit.Enabled = lstLabels.SelectedItems.Count == 1;
|
mnuEdit.Enabled = lstLabels.SelectedItems.Count == 1;
|
||||||
mnuFindOccurrences.Enabled = lstLabels.SelectedItems.Count == 1;
|
mnuFindOccurrences.Enabled = lstLabels.SelectedItems.Count == 1;
|
||||||
|
mnuAddToWatch.Enabled = lstLabels.SelectedItems.Count == 1;
|
||||||
|
mnuAddBreakpoint.Enabled = lstLabels.SelectedItems.Count == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mnuDelete_Click(object sender, EventArgs e)
|
private void mnuDelete_Click(object sender, EventArgs e)
|
||||||
|
@ -209,5 +211,48 @@ namespace Mesen.GUI.Debugger.Controls
|
||||||
lstLabels.ListViewItemSorter = new LabelComparer(e.Column, _descSort);
|
lstLabels.ListViewItemSorter = new LabelComparer(e.Column, _descSort);
|
||||||
_prevSortColumn = e.Column;
|
_prevSortColumn = e.Column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void mnuAddBreakpoint_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if(lstLabels.SelectedItems.Count > 0) {
|
||||||
|
CodeLabel label = (CodeLabel)lstLabels.SelectedItems[0].SubItems[1].Tag;
|
||||||
|
if(label.AddressType == AddressType.PrgRom) {
|
||||||
|
BreakpointManager.AddBreakpoint(new Breakpoint() {
|
||||||
|
BreakOnExec = true,
|
||||||
|
BreakOnRead = true,
|
||||||
|
BreakOnWrite = false,
|
||||||
|
Address = label.Address,
|
||||||
|
StartAddress = label.Address,
|
||||||
|
EndAddress = label.Address,
|
||||||
|
AddressType = BreakpointAddressType.SingleAddress,
|
||||||
|
IsAbsoluteAddress = true
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
int address = label.GetRelativeAddress();
|
||||||
|
if(address >= 0) {
|
||||||
|
if(BreakpointManager.GetMatchingBreakpoint(address) == null) {
|
||||||
|
BreakpointManager.AddBreakpoint(new Breakpoint() {
|
||||||
|
BreakOnExec = true,
|
||||||
|
BreakOnRead = true,
|
||||||
|
BreakOnWrite = true,
|
||||||
|
Address = (UInt32)address,
|
||||||
|
StartAddress = (UInt32)address,
|
||||||
|
EndAddress = (UInt32)address,
|
||||||
|
AddressType = BreakpointAddressType.SingleAddress,
|
||||||
|
IsAbsoluteAddress = true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mnuAddToWatch_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if(lstLabels.SelectedItems.Count > 0) {
|
||||||
|
CodeLabel label = (CodeLabel)lstLabels.SelectedItems[0].SubItems[1].Tag;
|
||||||
|
WatchManager.AddWatch("[" + label.Label + "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,11 @@ namespace Mesen.GUI.Debugger
|
||||||
}
|
}
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetRelativeAddress()
|
||||||
|
{
|
||||||
|
return InteropEmu.DebugGetRelativeAddress(this.Address, this.AddressType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LabelManager
|
public class LabelManager
|
||||||
|
|
Loading…
Add table
Reference in a new issue