Debugger: Added "Go To Program Counter" menus

This commit is contained in:
Sour 2018-03-03 10:53:38 -05:00
parent 2722e63251
commit 99b470046b
5 changed files with 101 additions and 32 deletions

View file

@ -122,6 +122,8 @@
this.mnuGoToResetHandler = new System.Windows.Forms.ToolStripMenuItem();
this.mnuGoToInitHandler = new System.Windows.Forms.ToolStripMenuItem();
this.mnuGoToPlayHandler = new System.Windows.Forms.ToolStripMenuItem();
this.mnuGoToProgramCounter = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.tableLayoutPanel2.SuspendLayout();
this.grpPPUStatus.SuspendLayout();
this.tableLayoutPanel8.SuspendLayout();
@ -1290,46 +1292,61 @@
this.mnuGoToNmiHandler,
this.mnuGoToResetHandler,
this.mnuGoToInitHandler,
this.mnuGoToPlayHandler});
this.mnuGoToPlayHandler,
this.toolStripMenuItem1,
this.mnuGoToProgramCounter});
this.contextGoTo.Name = "contextGoTo";
this.contextGoTo.Size = new System.Drawing.Size(148, 114);
this.contextGoTo.Size = new System.Drawing.Size(167, 164);
this.contextGoTo.Opening += new System.ComponentModel.CancelEventHandler(this.contextGoTo_Opening);
//
// mnuGoToIrqHandler
//
this.mnuGoToIrqHandler.Name = "mnuGoToIrqHandler";
this.mnuGoToIrqHandler.Size = new System.Drawing.Size(147, 22);
this.mnuGoToIrqHandler.Size = new System.Drawing.Size(166, 22);
this.mnuGoToIrqHandler.Text = "IRQ Handler";
this.mnuGoToIrqHandler.Click += new System.EventHandler(this.mnuGoToIrqHandler_Click);
//
// mnuGoToNmiHandler
//
this.mnuGoToNmiHandler.Name = "mnuGoToNmiHandler";
this.mnuGoToNmiHandler.Size = new System.Drawing.Size(147, 22);
this.mnuGoToNmiHandler.Size = new System.Drawing.Size(166, 22);
this.mnuGoToNmiHandler.Text = "NMI Handler";
this.mnuGoToNmiHandler.Click += new System.EventHandler(this.mnuGoToNmiHandler_Click);
//
// mnuGoToResetHandler
//
this.mnuGoToResetHandler.Name = "mnuGoToResetHandler";
this.mnuGoToResetHandler.Size = new System.Drawing.Size(147, 22);
this.mnuGoToResetHandler.Size = new System.Drawing.Size(166, 22);
this.mnuGoToResetHandler.Text = "Reset Handler";
this.mnuGoToResetHandler.Click += new System.EventHandler(this.mnuGoToResetHandler_Click);
//
// mnuGoToInitHandler
//
this.mnuGoToInitHandler.Name = "mnuGoToInitHandler";
this.mnuGoToInitHandler.Size = new System.Drawing.Size(147, 22);
this.mnuGoToInitHandler.Size = new System.Drawing.Size(166, 22);
this.mnuGoToInitHandler.Text = "Init Handler";
this.mnuGoToInitHandler.Click += new System.EventHandler(this.mnuGoToInitHandler_Click);
//
// mnuGoToPlayHandler
//
this.mnuGoToPlayHandler.Name = "mnuGoToPlayHandler";
this.mnuGoToPlayHandler.Size = new System.Drawing.Size(147, 22);
this.mnuGoToPlayHandler.Size = new System.Drawing.Size(166, 22);
this.mnuGoToPlayHandler.Text = "Play Handler";
this.mnuGoToPlayHandler.Click += new System.EventHandler(this.mnuGoToPlayHandler_Click);
//
// mnuGoToProgramCounter
//
this.mnuGoToProgramCounter.Name = "mnuGoToProgramCounter";
this.mnuGoToProgramCounter.Size = new System.Drawing.Size(166, 22);
this.mnuGoToProgramCounter.Text = "Program Counter";
this.mnuGoToProgramCounter.ToolTipText = "Alt+*";
this.mnuGoToProgramCounter.Click += new System.EventHandler(this.mnuGoToProgramCounter_Click);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(163, 6);
//
// ctrlConsoleStatus
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -1471,5 +1488,7 @@
private System.Windows.Forms.TextBox txtXScroll;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtTmpAddr;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem mnuGoToProgramCounter;
}
}

View file

@ -281,6 +281,13 @@ namespace Mesen.GUI.Debugger
{
this.OnGotoLocation?.Invoke((int)InteropEmu.NsfGetHeader().PlayAddress, null);
}
private void mnuGoToProgramCounter_Click(object sender, EventArgs e)
{
DebugState state = new DebugState();
InteropEmu.DebugGetState(ref state);
this.OnGotoLocation((int)state.CPU.DebugPC, null);
}
private void contextGoTo_Opening(object sender, CancelEventArgs e)
{

View file

@ -169,6 +169,13 @@ namespace Mesen.GUI.Debugger
this.ctrlCodeViewer.ScrollToLineNumber((int)address, eHistoryType.OnScroll);
}
public void ScrollToActiveAddress()
{
if(_currentActiveAddress.HasValue) {
this.ctrlCodeViewer.ScrollToLineNumber((int)_currentActiveAddress.Value);
}
}
public void SetActiveAddress(UInt32 address)
{
_currentActiveAddress = address;
@ -730,7 +737,7 @@ namespace Mesen.GUI.Debugger
private void mnuShowNextStatement_Click(object sender, EventArgs e)
{
this.ctrlCodeViewer.ScrollToLineNumber((int)_currentActiveAddress.Value);
this.ScrollToActiveAddress();
}
private void mnuShowLineNotes_Click(object sender, EventArgs e)

View file

@ -93,9 +93,12 @@ namespace Mesen.GUI.Debugger
this.mnuFindAllOccurrences = new System.Windows.Forms.ToolStripMenuItem();
this.mnuGoTo = new System.Windows.Forms.ToolStripMenuItem();
this.mnuGoToAddress = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem22 = new System.Windows.Forms.ToolStripSeparator();
this.mnuGoToIrqHandler = new System.Windows.Forms.ToolStripMenuItem();
this.mnuGoToNmiHandler = new System.Windows.Forms.ToolStripMenuItem();
this.mnuGoToResetHandler = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem23 = new System.Windows.Forms.ToolStripSeparator();
this.mnuGoToProgramCount = new System.Windows.Forms.ToolStripMenuItem();
this.mnuOptions = new System.Windows.Forms.ToolStripMenuItem();
this.mnuDisassemblyOptions = new System.Windows.Forms.ToolStripMenuItem();
this.mnuDisassemble = new System.Windows.Forms.ToolStripMenuItem();
@ -221,7 +224,7 @@ namespace Mesen.GUI.Debugger
this.splitContainer.Panel2.Controls.Add(this.tableLayoutPanel10);
this.splitContainer.Panel2MinSize = 100;
this.splitContainer.Size = new System.Drawing.Size(1172, 573);
this.splitContainer.SplitterDistance = 419;
this.splitContainer.SplitterDistance = 413;
this.splitContainer.SplitterWidth = 7;
this.splitContainer.TabIndex = 1;
this.splitContainer.TabStop = false;
@ -244,7 +247,7 @@ namespace Mesen.GUI.Debugger
//
this.ctrlSplitContainerTop.Panel2.Controls.Add(this.tlpFunctionLabelLists);
this.ctrlSplitContainerTop.Panel2MinSize = 150;
this.ctrlSplitContainerTop.Size = new System.Drawing.Size(1172, 419);
this.ctrlSplitContainerTop.Size = new System.Drawing.Size(1172, 413);
this.ctrlSplitContainerTop.SplitterDistance = 750;
this.ctrlSplitContainerTop.SplitterWidth = 7;
this.ctrlSplitContainerTop.TabIndex = 3;
@ -266,7 +269,7 @@ namespace Mesen.GUI.Debugger
this.tlpTop.Name = "tlpTop";
this.tlpTop.RowCount = 1;
this.tlpTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tlpTop.Size = new System.Drawing.Size(750, 419);
this.tlpTop.Size = new System.Drawing.Size(750, 413);
this.tlpTop.TabIndex = 2;
//
// ctrlDebuggerCode
@ -278,8 +281,9 @@ namespace Mesen.GUI.Debugger
this.ctrlDebuggerCode.Name = "ctrlDebuggerCode";
this.ctrlDebuggerCode.ShowMemoryValues = false;
this.ctrlDebuggerCode.ShowScrollbars = true;
this.ctrlDebuggerCode.Size = new System.Drawing.Size(286, 413);
this.ctrlDebuggerCode.Size = new System.Drawing.Size(286, 407);
this.ctrlDebuggerCode.TabIndex = 2;
this.ctrlDebuggerCode.TextZoom = 100;
this.ctrlDebuggerCode.OnEditCode += new Mesen.GUI.Debugger.ctrlDebuggerCode.AssemblerEventHandler(this.ctrlDebuggerCode_OnEditCode);
this.ctrlDebuggerCode.OnSetNextStatement += new Mesen.GUI.Debugger.ctrlDebuggerCode.AddressEventHandler(this.ctrlDebuggerCode_OnSetNextStatement);
this.ctrlDebuggerCode.OnScrollToAddress += new Mesen.GUI.Debugger.ctrlDebuggerCode.AddressEventHandler(this.ctrlDebuggerCode_OnScrollToAddress);
@ -291,7 +295,7 @@ namespace Mesen.GUI.Debugger
this.ctrlConsoleStatus.Location = new System.Drawing.Point(292, 0);
this.ctrlConsoleStatus.Margin = new System.Windows.Forms.Padding(0);
this.ctrlConsoleStatus.Name = "ctrlConsoleStatus";
this.ctrlConsoleStatus.Size = new System.Drawing.Size(458, 419);
this.ctrlConsoleStatus.Size = new System.Drawing.Size(458, 413);
this.ctrlConsoleStatus.TabIndex = 3;
this.ctrlConsoleStatus.OnGotoLocation += new System.EventHandler(this.ctrlConsoleStatus_OnGotoLocation);
//
@ -304,8 +308,9 @@ namespace Mesen.GUI.Debugger
this.ctrlDebuggerCodeSplit.Name = "ctrlDebuggerCodeSplit";
this.ctrlDebuggerCodeSplit.ShowMemoryValues = false;
this.ctrlDebuggerCodeSplit.ShowScrollbars = true;
this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 413);
this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 407);
this.ctrlDebuggerCodeSplit.TabIndex = 4;
this.ctrlDebuggerCodeSplit.TextZoom = 100;
this.ctrlDebuggerCodeSplit.Visible = false;
this.ctrlDebuggerCodeSplit.OnEditCode += new Mesen.GUI.Debugger.ctrlDebuggerCode.AssemblerEventHandler(this.ctrlDebuggerCode_OnEditCode);
this.ctrlDebuggerCodeSplit.OnSetNextStatement += new Mesen.GUI.Debugger.ctrlDebuggerCode.AddressEventHandler(this.ctrlDebuggerCode_OnSetNextStatement);
@ -325,16 +330,16 @@ namespace Mesen.GUI.Debugger
this.tlpFunctionLabelLists.RowCount = 2;
this.tlpFunctionLabelLists.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tlpFunctionLabelLists.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tlpFunctionLabelLists.Size = new System.Drawing.Size(415, 419);
this.tlpFunctionLabelLists.Size = new System.Drawing.Size(415, 413);
this.tlpFunctionLabelLists.TabIndex = 5;
//
// grpLabels
//
this.grpLabels.Controls.Add(this.ctrlLabelList);
this.grpLabels.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpLabels.Location = new System.Drawing.Point(3, 212);
this.grpLabels.Location = new System.Drawing.Point(3, 209);
this.grpLabels.Name = "grpLabels";
this.grpLabels.Size = new System.Drawing.Size(409, 204);
this.grpLabels.Size = new System.Drawing.Size(409, 201);
this.grpLabels.TabIndex = 6;
this.grpLabels.TabStop = false;
this.grpLabels.Text = "Labels";
@ -344,7 +349,7 @@ namespace Mesen.GUI.Debugger
this.ctrlLabelList.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlLabelList.Location = new System.Drawing.Point(3, 16);
this.ctrlLabelList.Name = "ctrlLabelList";
this.ctrlLabelList.Size = new System.Drawing.Size(403, 185);
this.ctrlLabelList.Size = new System.Drawing.Size(403, 182);
this.ctrlLabelList.TabIndex = 0;
this.ctrlLabelList.OnFindOccurrence += new System.EventHandler(this.ctrlLabelList_OnFindOccurrence);
this.ctrlLabelList.OnLabelSelected += new System.EventHandler(this.ctrlLabelList_OnLabelSelected);
@ -355,7 +360,7 @@ namespace Mesen.GUI.Debugger
this.grpFunctions.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpFunctions.Location = new System.Drawing.Point(3, 3);
this.grpFunctions.Name = "grpFunctions";
this.grpFunctions.Size = new System.Drawing.Size(409, 203);
this.grpFunctions.Size = new System.Drawing.Size(409, 200);
this.grpFunctions.TabIndex = 5;
this.grpFunctions.TabStop = false;
this.grpFunctions.Text = "Functions";
@ -365,7 +370,7 @@ namespace Mesen.GUI.Debugger
this.ctrlFunctionList.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlFunctionList.Location = new System.Drawing.Point(3, 16);
this.ctrlFunctionList.Name = "ctrlFunctionList";
this.ctrlFunctionList.Size = new System.Drawing.Size(403, 184);
this.ctrlFunctionList.Size = new System.Drawing.Size(403, 181);
this.ctrlFunctionList.TabIndex = 0;
this.ctrlFunctionList.OnFindOccurrence += new System.EventHandler(this.ctrlFunctionList_OnFindOccurrence);
this.ctrlFunctionList.OnFunctionSelected += new System.EventHandler(this.ctrlFunctionList_OnFunctionSelected);
@ -396,7 +401,7 @@ namespace Mesen.GUI.Debugger
this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel10.Size = new System.Drawing.Size(1172, 147);
this.tableLayoutPanel10.Size = new System.Drawing.Size(1172, 153);
this.tableLayoutPanel10.TabIndex = 0;
//
// grpWatch
@ -405,7 +410,7 @@ namespace Mesen.GUI.Debugger
this.grpWatch.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpWatch.Location = new System.Drawing.Point(3, 3);
this.grpWatch.Name = "grpWatch";
this.grpWatch.Size = new System.Drawing.Size(384, 141);
this.grpWatch.Size = new System.Drawing.Size(384, 147);
this.grpWatch.TabIndex = 2;
this.grpWatch.TabStop = false;
this.grpWatch.Text = "Watch";
@ -415,7 +420,7 @@ namespace Mesen.GUI.Debugger
this.ctrlWatch.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlWatch.Location = new System.Drawing.Point(3, 16);
this.ctrlWatch.Name = "ctrlWatch";
this.ctrlWatch.Size = new System.Drawing.Size(378, 122);
this.ctrlWatch.Size = new System.Drawing.Size(378, 128);
this.ctrlWatch.TabIndex = 0;
//
// grpBreakpoints
@ -424,7 +429,7 @@ namespace Mesen.GUI.Debugger
this.grpBreakpoints.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpBreakpoints.Location = new System.Drawing.Point(393, 3);
this.grpBreakpoints.Name = "grpBreakpoints";
this.grpBreakpoints.Size = new System.Drawing.Size(384, 141);
this.grpBreakpoints.Size = new System.Drawing.Size(384, 147);
this.grpBreakpoints.TabIndex = 3;
this.grpBreakpoints.TabStop = false;
this.grpBreakpoints.Text = "Breakpoints";
@ -434,7 +439,7 @@ namespace Mesen.GUI.Debugger
this.ctrlBreakpoints.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlBreakpoints.Location = new System.Drawing.Point(3, 16);
this.ctrlBreakpoints.Name = "ctrlBreakpoints";
this.ctrlBreakpoints.Size = new System.Drawing.Size(378, 122);
this.ctrlBreakpoints.Size = new System.Drawing.Size(378, 128);
this.ctrlBreakpoints.TabIndex = 0;
this.ctrlBreakpoints.BreakpointNavigation += new System.EventHandler(this.ctrlBreakpoints_BreakpointNavigation);
//
@ -444,7 +449,7 @@ namespace Mesen.GUI.Debugger
this.grpCallstack.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpCallstack.Location = new System.Drawing.Point(783, 3);
this.grpCallstack.Name = "grpCallstack";
this.grpCallstack.Size = new System.Drawing.Size(386, 141);
this.grpCallstack.Size = new System.Drawing.Size(386, 147);
this.grpCallstack.TabIndex = 4;
this.grpCallstack.TabStop = false;
this.grpCallstack.Text = "Call Stack";
@ -454,7 +459,7 @@ namespace Mesen.GUI.Debugger
this.ctrlCallstack.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlCallstack.Location = new System.Drawing.Point(3, 16);
this.ctrlCallstack.Name = "ctrlCallstack";
this.ctrlCallstack.Size = new System.Drawing.Size(380, 122);
this.ctrlCallstack.Size = new System.Drawing.Size(380, 128);
this.ctrlCallstack.TabIndex = 0;
this.ctrlCallstack.FunctionSelected += new System.EventHandler(this.ctrlCallstack_FunctionSelected);
//
@ -825,9 +830,12 @@ namespace Mesen.GUI.Debugger
//
this.mnuGoTo.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuGoToAddress,
this.toolStripMenuItem22,
this.mnuGoToIrqHandler,
this.mnuGoToNmiHandler,
this.mnuGoToResetHandler});
this.mnuGoToResetHandler,
this.toolStripMenuItem23,
this.mnuGoToProgramCount});
this.mnuGoTo.Name = "mnuGoTo";
this.mnuGoTo.Size = new System.Drawing.Size(255, 22);
this.mnuGoTo.Text = "Go To...";
@ -836,31 +844,49 @@ namespace Mesen.GUI.Debugger
//
this.mnuGoToAddress.Name = "mnuGoToAddress";
this.mnuGoToAddress.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G)));
this.mnuGoToAddress.Size = new System.Drawing.Size(158, 22);
this.mnuGoToAddress.Size = new System.Drawing.Size(201, 22);
this.mnuGoToAddress.Text = "Address";
this.mnuGoToAddress.Click += new System.EventHandler(this.mnuGoToAddress_Click);
//
// toolStripMenuItem22
//
this.toolStripMenuItem22.Name = "toolStripMenuItem22";
this.toolStripMenuItem22.Size = new System.Drawing.Size(198, 6);
//
// mnuGoToIrqHandler
//
this.mnuGoToIrqHandler.Name = "mnuGoToIrqHandler";
this.mnuGoToIrqHandler.Size = new System.Drawing.Size(158, 22);
this.mnuGoToIrqHandler.Size = new System.Drawing.Size(201, 22);
this.mnuGoToIrqHandler.Text = "IRQ Handler";
this.mnuGoToIrqHandler.Click += new System.EventHandler(this.mnuGoToIrqHandler_Click);
//
// mnuGoToNmiHandler
//
this.mnuGoToNmiHandler.Name = "mnuGoToNmiHandler";
this.mnuGoToNmiHandler.Size = new System.Drawing.Size(158, 22);
this.mnuGoToNmiHandler.Size = new System.Drawing.Size(201, 22);
this.mnuGoToNmiHandler.Text = "NMI Handler";
this.mnuGoToNmiHandler.Click += new System.EventHandler(this.mnuGoToNmiHandler_Click);
//
// mnuGoToResetHandler
//
this.mnuGoToResetHandler.Name = "mnuGoToResetHandler";
this.mnuGoToResetHandler.Size = new System.Drawing.Size(158, 22);
this.mnuGoToResetHandler.Size = new System.Drawing.Size(201, 22);
this.mnuGoToResetHandler.Text = "Reset Handler";
this.mnuGoToResetHandler.Click += new System.EventHandler(this.mnuGoToResetHandler_Click);
//
// toolStripMenuItem23
//
this.toolStripMenuItem23.Name = "toolStripMenuItem23";
this.toolStripMenuItem23.Size = new System.Drawing.Size(198, 6);
//
// mnuGoToProgramCount
//
this.mnuGoToProgramCount.Name = "mnuGoToProgramCount";
this.mnuGoToProgramCount.ShortcutKeyDisplayString = "Alt+*";
this.mnuGoToProgramCount.Size = new System.Drawing.Size(201, 22);
this.mnuGoToProgramCount.Text = "Program Counter";
this.mnuGoToProgramCount.Click += new System.EventHandler(this.mnuGoToProgramCount_Click);
//
// mnuOptions
//
this.mnuOptions.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -1729,5 +1755,8 @@ namespace Mesen.GUI.Debugger
private System.Windows.Forms.ToolStripMenuItem mnuBringToFrontOnBreak;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem21;
private System.Windows.Forms.ToolStripMenuItem mnuSelectFont;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem22;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem23;
private System.Windows.Forms.ToolStripMenuItem mnuGoToProgramCount;
}
}

View file

@ -641,6 +641,13 @@ namespace Mesen.GUI.Debugger
int address = (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFD) << 8) | InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFC);
_lastCodeWindow.ScrollToLineNumber(address);
}
private void mnuGoToProgramCount_Click(object sender, EventArgs e)
{
DebugState state = new DebugState();
InteropEmu.DebugGetState(ref state);
_lastCodeWindow.ScrollToActiveAddress();
}
private void mnuIncreaseFontSize_Click(object sender, EventArgs e)
{