Debugger: Added "Break On" (scanline) feature

This commit is contained in:
Sour 2018-03-15 18:34:00 -04:00
parent 84d158cd90
commit b6e10bc810
9 changed files with 328 additions and 3 deletions

View file

@ -222,6 +222,8 @@ namespace Mesen.GUI.Config
public int BreakInCount = 1;
public BreakInMetric BreakInMetric = BreakInMetric.CpuCycles;
public int BreakOnValue = 241;
public bool FindOccurrencesMatchCase = false;
public bool FindOccurrencesMatchWholeWord = false;
public string FindOccurrencesLastSearch = string.Empty;

View file

@ -93,6 +93,9 @@ namespace Mesen.GUI.Config
[ShortcutName("Break In...")]
public XmlKeys BreakIn = Keys.Control | Keys.B;
[ShortcutName("Break On...")]
public XmlKeys BreakOn = Keys.Alt | Keys.B;
[ShortcutName("Find Occurrences")]
public XmlKeys FindOccurrences = Keys.Control | Keys.Shift | Keys.F;
[ShortcutName("Go To Program Counter")]

127
GUI.NET/Debugger/frmBreakOn.Designer.cs generated Normal file
View file

@ -0,0 +1,127 @@
using Mesen.GUI.Controls;
namespace Mesen.GUI.Debugger
{
partial class frmBreakOn
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if(disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nudCount = new Mesen.GUI.Controls.MesenNumericUpDown();
this.lblBreakOn = new System.Windows.Forms.Label();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// baseConfigPanel
//
this.baseConfigPanel.Location = new System.Drawing.Point(0, 29);
this.baseConfigPanel.Size = new System.Drawing.Size(186, 29);
//
// nudCount
//
this.nudCount.DecimalPlaces = 0;
this.nudCount.Increment = new decimal(new int[] {
1,
0,
0,
0});
this.nudCount.Location = new System.Drawing.Point(104, 3);
this.nudCount.Maximum = new decimal(new int[] {
999,
0,
0,
0});
this.nudCount.MaximumSize = new System.Drawing.Size(10000, 20);
this.nudCount.Minimum = new decimal(new int[] {
1,
0,
0,
-2147483648});
this.nudCount.Name = "nudCount";
this.tableLayoutPanel1.SetRowSpan(this.nudCount, 2);
this.nudCount.Size = new System.Drawing.Size(70, 20);
this.nudCount.TabIndex = 3;
this.nudCount.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// lblBreakOn
//
this.lblBreakOn.AutoSize = true;
this.lblBreakOn.Location = new System.Drawing.Point(3, 5);
this.lblBreakOn.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);
this.lblBreakOn.Name = "lblBreakOn";
this.tableLayoutPanel1.SetRowSpan(this.lblBreakOn, 2);
this.lblBreakOn.Size = new System.Drawing.Size(95, 13);
this.lblBreakOn.TabIndex = 0;
this.lblBreakOn.Text = "Break on scanline:";
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 4;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 76F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.lblBreakOn, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.nudCount, 1, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 4;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(186, 58);
this.tableLayoutPanel1.TabIndex = 0;
//
// frmBreakOn
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(186, 58);
this.Controls.Add(this.tableLayoutPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "frmBreakOn";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Break On...";
this.Controls.SetChildIndex(this.tableLayoutPanel1, 0);
this.Controls.SetChildIndex(this.baseConfigPanel, 0);
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private MesenNumericUpDown nudCount;
private System.Windows.Forms.Label lblBreakOn;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
}
}

View file

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Mesen.GUI.Config;
using Mesen.GUI.Forms;
namespace Mesen.GUI.Debugger
{
public partial class frmBreakOn : BaseConfigForm
{
public frmBreakOn()
{
InitializeComponent();
nudCount.Value = ConfigManager.Config.DebugInfo.BreakOnValue;
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
nudCount.Focus();
}
protected override void OnFormClosed(FormClosedEventArgs e)
{
base.OnFormClosed(e);
if(this.DialogResult == DialogResult.OK) {
int count = (int)nudCount.Value;
ConfigManager.Config.DebugInfo.BreakOnValue = count;
InteropEmu.DebugRun();
InteropEmu.DebugBreakOnScanline(count);
ConfigManager.ApplyChanges();
}
}
}
}

View file

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -64,7 +64,7 @@ namespace Mesen.GUI.Debugger
GetMember(nameof(DebuggerShortcutsConfig.ScriptWindow_StopScript))
};
ctrlDbgShortcutsDebugger.Shortcuts = new FieldInfo[42] {
ctrlDbgShortcutsDebugger.Shortcuts = new FieldInfo[43] {
GetMember(nameof(DebuggerShortcutsConfig.Continue)),
GetMember(nameof(DebuggerShortcutsConfig.Break)),
GetMember(nameof(DebuggerShortcutsConfig.ToggleBreakContinue)),
@ -76,6 +76,7 @@ namespace Mesen.GUI.Debugger
GetMember(nameof(DebuggerShortcutsConfig.RunPpuScanline)),
GetMember(nameof(DebuggerShortcutsConfig.RunPpuFrame)),
GetMember(nameof(DebuggerShortcutsConfig.BreakIn)),
GetMember(nameof(DebuggerShortcutsConfig.BreakOn)),
GetMember(nameof(DebuggerShortcutsConfig.FindOccurrences)),
GetMember(nameof(DebuggerShortcutsConfig.GoToProgramCounter)),
GetMember(nameof(DebuggerShortcutsConfig.CodeWindow_SetNextStatement)),

View file

@ -186,6 +186,7 @@ namespace Mesen.GUI.Debugger
this.ctrlPpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping();
this.ctrlCpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping();
this.tsToolbar = new Mesen.GUI.Controls.ctrlMesenToolStrip();
this.mnuBreakOn = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
this.splitContainer.Panel1.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout();
@ -655,7 +656,8 @@ namespace Mesen.GUI.Debugger
this.mnuRunScanline,
this.mnuRunOneFrame,
this.toolStripMenuItem8,
this.mnuBreakIn});
this.mnuBreakIn,
this.mnuBreakOn});
this.debugToolStripMenuItem.Name = "debugToolStripMenuItem";
this.debugToolStripMenuItem.Size = new System.Drawing.Size(54, 20);
this.debugToolStripMenuItem.Text = "Debug";
@ -1603,6 +1605,13 @@ namespace Mesen.GUI.Debugger
this.tsToolbar.Text = "toolStrip1";
this.tsToolbar.Visible = false;
//
// mnuBreakOn
//
this.mnuBreakOn.Name = "mnuBreakOn";
this.mnuBreakOn.Size = new System.Drawing.Size(212, 22);
this.mnuBreakOn.Text = "Break on...";
this.mnuBreakOn.Click += new System.EventHandler(this.mnuBreakOn_Click);
//
// frmDebugger
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -1802,5 +1811,6 @@ namespace Mesen.GUI.Debugger
private System.Windows.Forms.ToolStripMenuItem mnuCopyByteCode;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem6;
private System.Windows.Forms.ToolStripMenuItem mnuPreferences;
private System.Windows.Forms.ToolStripMenuItem mnuBreakOn;
}
}

View file

@ -174,6 +174,7 @@ namespace Mesen.GUI.Debugger
mnuContinue.InitShortcut(this, nameof(DebuggerShortcutsConfig.Continue));
mnuBreak.InitShortcut(this, nameof(DebuggerShortcutsConfig.Break));
mnuBreakIn.InitShortcut(this, nameof(DebuggerShortcutsConfig.BreakIn));
mnuBreakOn.InitShortcut(this, nameof(DebuggerShortcutsConfig.BreakOn));
mnuStepBack.InitShortcut(this, nameof(DebuggerShortcutsConfig.StepBack));
mnuStepOut.InitShortcut(this, nameof(DebuggerShortcutsConfig.StepOut));
@ -217,7 +218,7 @@ namespace Mesen.GUI.Debugger
);
AddItemToToolbar(mnuShowVerifiedData, "Show Verified Data");
AddItemToToolbar(mnuShowUnidentifiedData, "Show Unidentified Code/Data");
AddItemsToToolbar(null, mnuBreakIn);
AddItemsToToolbar(null, mnuBreakIn, null, mnuBreakOn);
}
private void AddItemToToolbar(ToolStripMenuItem item, string caption = null)
@ -1065,6 +1066,13 @@ namespace Mesen.GUI.Debugger
frm.ShowDialog();
}
}
private void mnuBreakOn_Click(object sender, EventArgs e)
{
using(frmBreakOn frm = new frmBreakOn()) {
frm.ShowDialog();
}
}
private void mnuFindAllOccurrences_Click(object sender, EventArgs e)
{

View file

@ -593,6 +593,12 @@
<Compile Include="Debugger\frmAssembler.Designer.cs">
<DependentUpon>frmAssembler.cs</DependentUpon>
</Compile>
<Compile Include="Debugger\frmBreakOn.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Debugger\frmBreakOn.Designer.cs">
<DependentUpon>frmBreakOn.cs</DependentUpon>
</Compile>
<Compile Include="Debugger\frmDbgPreferences.cs">
<SubType>Form</SubType>
</Compile>
@ -1293,6 +1299,9 @@
<EmbeddedResource Include="Debugger\frmAssembler.resx">
<DependentUpon>frmAssembler.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Debugger\frmBreakOn.resx">
<DependentUpon>frmBreakOn.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Debugger\frmDbgPreferences.resx">
<DependentUpon>frmDbgPreferences.cs</DependentUpon>
</EmbeddedResource>