Debugger: Find Occurrences feature for labels/addresses
This commit is contained in:
parent
c59f094301
commit
4350952ad3
12 changed files with 356 additions and 24 deletions
156
GUI.NET/Debugger/Controls/ctrlDebuggerCode.Designer.cs
generated
156
GUI.NET/Debugger/Controls/ctrlDebuggerCode.Designer.cs
generated
|
@ -37,14 +37,30 @@
|
|||
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuGoToLocation = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuAddToWatch = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuFindOccurrences = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.ctrlCodeViewer = new Mesen.GUI.Debugger.ctrlScrollableTextbox();
|
||||
this.contextMenuMargin = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.mnuDisableBreakpoint = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuRemoveBreakpoint = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuEditBreakpoint = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.splitContainer = new System.Windows.Forms.SplitContainer();
|
||||
this.tlpSearchResults = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.lstSearchResult = new System.Windows.Forms.ListView();
|
||||
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.picCloseOccurrenceList = new System.Windows.Forms.PictureBox();
|
||||
this.lblSearchResult = new System.Windows.Forms.Label();
|
||||
this.contextMenuCode.SuspendLayout();
|
||||
this.contextMenuMargin.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
|
||||
this.splitContainer.Panel1.SuspendLayout();
|
||||
this.splitContainer.Panel2.SuspendLayout();
|
||||
this.splitContainer.SuspendLayout();
|
||||
this.tlpSearchResults.SuspendLayout();
|
||||
this.tableLayoutPanel2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picCloseOccurrenceList)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// contextMenuCode
|
||||
|
@ -57,9 +73,10 @@
|
|||
this.mnuShowCodeNotes,
|
||||
this.toolStripMenuItem2,
|
||||
this.mnuGoToLocation,
|
||||
this.mnuAddToWatch});
|
||||
this.mnuAddToWatch,
|
||||
this.mnuFindOccurrences});
|
||||
this.contextMenuCode.Name = "contextMenuWatch";
|
||||
this.contextMenuCode.Size = new System.Drawing.Size(259, 148);
|
||||
this.contextMenuCode.Size = new System.Drawing.Size(259, 170);
|
||||
this.contextMenuCode.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuCode_Opening);
|
||||
//
|
||||
// mnuShowNextStatement
|
||||
|
@ -120,6 +137,13 @@
|
|||
this.mnuAddToWatch.Text = "Add to Watch";
|
||||
this.mnuAddToWatch.Click += new System.EventHandler(this.mnuAddToWatch_Click);
|
||||
//
|
||||
// mnuFindOccurrences
|
||||
//
|
||||
this.mnuFindOccurrences.Name = "mnuFindOccurrences";
|
||||
this.mnuFindOccurrences.Size = new System.Drawing.Size(258, 22);
|
||||
this.mnuFindOccurrences.Text = "Find Occurrences";
|
||||
this.mnuFindOccurrences.Click += new System.EventHandler(this.mnuFindOccurrences_Click);
|
||||
//
|
||||
// ctrlCodeViewer
|
||||
//
|
||||
this.ctrlCodeViewer.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
|
@ -129,7 +153,7 @@
|
|||
this.ctrlCodeViewer.Name = "ctrlCodeViewer";
|
||||
this.ctrlCodeViewer.ShowContentNotes = false;
|
||||
this.ctrlCodeViewer.ShowLineNumberNotes = false;
|
||||
this.ctrlCodeViewer.Size = new System.Drawing.Size(379, 218);
|
||||
this.ctrlCodeViewer.Size = new System.Drawing.Size(479, 150);
|
||||
this.ctrlCodeViewer.TabIndex = 1;
|
||||
this.ctrlCodeViewer.ScrollPositionChanged += new System.EventHandler(this.ctrlCodeViewer_ScrollPositionChanged);
|
||||
this.ctrlCodeViewer.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ctrlCodeViewer_MouseUp);
|
||||
|
@ -169,15 +193,128 @@
|
|||
this.mnuEditBreakpoint.Text = "Edit breakpoint";
|
||||
this.mnuEditBreakpoint.Click += new System.EventHandler(this.mnuEditBreakpoint_Click);
|
||||
//
|
||||
// splitContainer
|
||||
//
|
||||
this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
|
||||
this.splitContainer.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitContainer.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.splitContainer.Name = "splitContainer";
|
||||
this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
//
|
||||
// splitContainer.Panel1
|
||||
//
|
||||
this.splitContainer.Panel1.Controls.Add(this.ctrlCodeViewer);
|
||||
this.splitContainer.Panel1MinSize = 150;
|
||||
//
|
||||
// splitContainer.Panel2
|
||||
//
|
||||
this.splitContainer.Panel2.Controls.Add(this.tlpSearchResults);
|
||||
this.splitContainer.Size = new System.Drawing.Size(479, 318);
|
||||
this.splitContainer.SplitterDistance = 150;
|
||||
this.splitContainer.TabIndex = 12;
|
||||
//
|
||||
// tlpSearchResults
|
||||
//
|
||||
this.tlpSearchResults.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
|
||||
this.tlpSearchResults.ColumnCount = 1;
|
||||
this.tlpSearchResults.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tlpSearchResults.Controls.Add(this.lstSearchResult, 0, 1);
|
||||
this.tlpSearchResults.Controls.Add(this.tableLayoutPanel2, 0, 0);
|
||||
this.tlpSearchResults.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tlpSearchResults.Location = new System.Drawing.Point(0, 0);
|
||||
this.tlpSearchResults.Name = "tlpSearchResults";
|
||||
this.tlpSearchResults.RowCount = 2;
|
||||
this.tlpSearchResults.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tlpSearchResults.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tlpSearchResults.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tlpSearchResults.Size = new System.Drawing.Size(479, 164);
|
||||
this.tlpSearchResults.TabIndex = 12;
|
||||
//
|
||||
// lstSearchResult
|
||||
//
|
||||
this.lstSearchResult.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.lstSearchResult.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeader1,
|
||||
this.columnHeader2});
|
||||
this.lstSearchResult.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.lstSearchResult.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lstSearchResult.FullRowSelect = true;
|
||||
this.lstSearchResult.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
|
||||
this.lstSearchResult.Location = new System.Drawing.Point(1, 24);
|
||||
this.lstSearchResult.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.lstSearchResult.Name = "lstSearchResult";
|
||||
this.lstSearchResult.Size = new System.Drawing.Size(477, 139);
|
||||
this.lstSearchResult.TabIndex = 9;
|
||||
this.lstSearchResult.UseCompatibleStateImageBehavior = false;
|
||||
this.lstSearchResult.View = System.Windows.Forms.View.Details;
|
||||
this.lstSearchResult.DoubleClick += new System.EventHandler(this.lstSearchResult_DoubleClick);
|
||||
//
|
||||
// columnHeader1
|
||||
//
|
||||
this.columnHeader1.Text = "";
|
||||
//
|
||||
// columnHeader2
|
||||
//
|
||||
this.columnHeader2.Text = "";
|
||||
this.columnHeader2.Width = 160;
|
||||
//
|
||||
// tableLayoutPanel2
|
||||
//
|
||||
this.tableLayoutPanel2.ColumnCount = 2;
|
||||
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanel2.Controls.Add(this.picCloseOccurrenceList, 1, 0);
|
||||
this.tableLayoutPanel2.Controls.Add(this.lblSearchResult, 0, 0);
|
||||
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel2.Location = new System.Drawing.Point(1, 1);
|
||||
this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
|
||||
this.tableLayoutPanel2.RowCount = 1;
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel2.Size = new System.Drawing.Size(477, 22);
|
||||
this.tableLayoutPanel2.TabIndex = 11;
|
||||
//
|
||||
// picCloseOccurrenceList
|
||||
//
|
||||
this.picCloseOccurrenceList.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.picCloseOccurrenceList.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.picCloseOccurrenceList.Image = global::Mesen.GUI.Properties.Resources.Close;
|
||||
this.picCloseOccurrenceList.Location = new System.Drawing.Point(458, 3);
|
||||
this.picCloseOccurrenceList.Name = "picCloseOccurrenceList";
|
||||
this.picCloseOccurrenceList.Size = new System.Drawing.Size(16, 16);
|
||||
this.picCloseOccurrenceList.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.picCloseOccurrenceList.TabIndex = 10;
|
||||
this.picCloseOccurrenceList.TabStop = false;
|
||||
this.picCloseOccurrenceList.Click += new System.EventHandler(this.picCloseOccurrenceList_Click);
|
||||
//
|
||||
// lblSearchResult
|
||||
//
|
||||
this.lblSearchResult.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.lblSearchResult.AutoSize = true;
|
||||
this.lblSearchResult.Location = new System.Drawing.Point(3, 4);
|
||||
this.lblSearchResult.Name = "lblSearchResult";
|
||||
this.lblSearchResult.Size = new System.Drawing.Size(95, 13);
|
||||
this.lblSearchResult.TabIndex = 11;
|
||||
this.lblSearchResult.Text = "Search results for: ";
|
||||
//
|
||||
// ctrlDebuggerCode
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.ctrlCodeViewer);
|
||||
this.Controls.Add(this.splitContainer);
|
||||
this.Name = "ctrlDebuggerCode";
|
||||
this.Size = new System.Drawing.Size(379, 218);
|
||||
this.Size = new System.Drawing.Size(479, 318);
|
||||
this.contextMenuCode.ResumeLayout(false);
|
||||
this.contextMenuMargin.ResumeLayout(false);
|
||||
this.splitContainer.Panel1.ResumeLayout(false);
|
||||
this.splitContainer.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
|
||||
this.splitContainer.ResumeLayout(false);
|
||||
this.tlpSearchResults.ResumeLayout(false);
|
||||
this.tableLayoutPanel2.ResumeLayout(false);
|
||||
this.tableLayoutPanel2.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picCloseOccurrenceList)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
@ -199,5 +336,14 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem mnuRemoveBreakpoint;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuEditBreakpoint;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuDisableBreakpoint;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuFindOccurrences;
|
||||
private System.Windows.Forms.SplitContainer splitContainer;
|
||||
private System.Windows.Forms.TableLayoutPanel tlpSearchResults;
|
||||
private System.Windows.Forms.ListView lstSearchResult;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader1;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader2;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
|
||||
private System.Windows.Forms.PictureBox picCloseOccurrenceList;
|
||||
private System.Windows.Forms.Label lblSearchResult;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace Mesen.GUI.Debugger
|
|||
public ctrlDebuggerCode()
|
||||
{
|
||||
InitializeComponent();
|
||||
splitContainer.Panel2Collapsed = true;
|
||||
}
|
||||
|
||||
public void SetConfig(DebugViewInfo config)
|
||||
|
@ -244,10 +245,13 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
UInt32 _lastClickedAddress = UInt32.MaxValue;
|
||||
string _newWatchValue = string.Empty;
|
||||
string _lastWord = string.Empty;
|
||||
private void ctrlCodeViewer_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
string word = GetWordUnderLocation(e.Location);
|
||||
if(word.StartsWith("$") || LabelManager.GetLabel(word) != null) {
|
||||
_lastWord = word;
|
||||
|
||||
if(word.StartsWith("$")) {
|
||||
_lastClickedAddress = UInt32.Parse(word.Substring(1), System.Globalization.NumberStyles.AllowHexSpecifier);
|
||||
_newWatchValue = "[$" + _lastClickedAddress.ToString("X") + "]";
|
||||
|
@ -269,11 +273,16 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
mnuAddToWatch.Enabled = true;
|
||||
mnuAddToWatch.Text = "Add to Watch (" + word + ")";
|
||||
|
||||
mnuFindOccurrences.Enabled = true;
|
||||
mnuFindOccurrences.Text = "Find Occurrences (" + word + ")";
|
||||
} else {
|
||||
mnuGoToLocation.Enabled = false;
|
||||
mnuGoToLocation.Text = "Go to Location";
|
||||
mnuAddToWatch.Enabled = false;
|
||||
mnuAddToWatch.Text = "Add to Watch";
|
||||
mnuFindOccurrences.Enabled = false;
|
||||
mnuFindOccurrences.Text = "Find Occurrences";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,9 +396,36 @@ namespace Mesen.GUI.Debugger
|
|||
GoToLocation();
|
||||
}
|
||||
|
||||
private void GoToLocation()
|
||||
private void mnuFindOccurrences_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.ctrlCodeViewer.ScrollToLineNumber((int)_lastClickedAddress);
|
||||
this.FindAllOccurrences(_lastWord);
|
||||
}
|
||||
|
||||
public void FindAllOccurrences(string text)
|
||||
{
|
||||
this.lstSearchResult.Items.Clear();
|
||||
foreach(Tuple<int, int, string> searchResult in this.ctrlCodeViewer.FindAllOccurrences(text)) {
|
||||
var item = this.lstSearchResult.Items.Add(searchResult.Item1.ToString("X4"));
|
||||
item.Tag = searchResult.Item2;
|
||||
item.SubItems.Add(searchResult.Item3);
|
||||
}
|
||||
this.lblSearchResult.Text = $"Search results for: {text} ({this.lstSearchResult.Items.Count} results)";
|
||||
this.lstSearchResult.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
|
||||
this.lstSearchResult.Columns[0].Width += 20;
|
||||
this.splitContainer.Panel2Collapsed = false;
|
||||
}
|
||||
|
||||
private void picCloseOccurrenceList_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.splitContainer.Panel2Collapsed = true;
|
||||
}
|
||||
|
||||
private void lstSearchResult_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
if(lstSearchResult.SelectedItems.Count > 0) {
|
||||
int lineIndex = (int)lstSearchResult.SelectedItems[0].Tag;
|
||||
this.ctrlCodeViewer.ScrollToLineIndex(lineIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void mnuAddToWatch_Click(object sender, EventArgs e)
|
||||
|
@ -397,6 +433,11 @@ namespace Mesen.GUI.Debugger
|
|||
AddWatch();
|
||||
}
|
||||
|
||||
private void GoToLocation()
|
||||
{
|
||||
this.ctrlCodeViewer.ScrollToLineNumber((int)_lastClickedAddress);
|
||||
}
|
||||
|
||||
private void AddWatch()
|
||||
{
|
||||
if(this.OnWatchAdded != null) {
|
||||
|
|
|
@ -27,10 +27,15 @@
|
|||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.lstFunctions = new Mesen.GUI.Controls.DoubleBufferedListView();
|
||||
this.colFunctionLabel = ((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.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.mnuEditLabel = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuFindOccurrences = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.contextMenuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lstFunctions
|
||||
|
@ -39,6 +44,7 @@
|
|||
this.colFunctionLabel,
|
||||
this.colFunctionAddress,
|
||||
this.colMemoryAddress});
|
||||
this.lstFunctions.ContextMenuStrip = this.contextMenuStrip;
|
||||
this.lstFunctions.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.lstFunctions.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lstFunctions.FullRowSelect = true;
|
||||
|
@ -69,6 +75,29 @@
|
|||
this.colMemoryAddress.Text = "ROM Addr.";
|
||||
this.colMemoryAddress.Width = 71;
|
||||
//
|
||||
// contextMenuStrip
|
||||
//
|
||||
this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.mnuEditLabel,
|
||||
this.mnuFindOccurrences});
|
||||
this.contextMenuStrip.Name = "contextMenuStrip";
|
||||
this.contextMenuStrip.Size = new System.Drawing.Size(167, 70);
|
||||
this.contextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip_Opening);
|
||||
//
|
||||
// mnuEditLabel
|
||||
//
|
||||
this.mnuEditLabel.Name = "mnuEditLabel";
|
||||
this.mnuEditLabel.Size = new System.Drawing.Size(166, 22);
|
||||
this.mnuEditLabel.Text = "Edit Label";
|
||||
this.mnuEditLabel.Click += new System.EventHandler(this.mnuEditLabel_Click);
|
||||
//
|
||||
// mnuFindOccurrences
|
||||
//
|
||||
this.mnuFindOccurrences.Name = "mnuFindOccurrences";
|
||||
this.mnuFindOccurrences.Size = new System.Drawing.Size(166, 22);
|
||||
this.mnuFindOccurrences.Text = "Find Occurrences";
|
||||
this.mnuFindOccurrences.Click += new System.EventHandler(this.mnuFindOccurrences_Click);
|
||||
//
|
||||
// ctrlFunctionList
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -76,6 +105,7 @@
|
|||
this.Controls.Add(this.lstFunctions);
|
||||
this.Name = "ctrlFunctionList";
|
||||
this.Size = new System.Drawing.Size(275, 112);
|
||||
this.contextMenuStrip.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
@ -86,5 +116,8 @@
|
|||
private System.Windows.Forms.ColumnHeader colFunctionLabel;
|
||||
private System.Windows.Forms.ColumnHeader colFunctionAddress;
|
||||
private System.Windows.Forms.ColumnHeader colMemoryAddress;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuEditLabel;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuFindOccurrences;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,9 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
{
|
||||
public partial class ctrlFunctionList : UserControl
|
||||
{
|
||||
public event EventHandler OnFindOccurrence;
|
||||
public event EventHandler OnFunctionSelected;
|
||||
|
||||
public ctrlFunctionList()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -28,8 +30,8 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
|
||||
string aText = string.IsNullOrWhiteSpace(a.Text) ? "ZZZZZZZZZZZZZZZZZZZZZZZ" : a.Text;
|
||||
string bText = string.IsNullOrWhiteSpace(b.Text) ? "ZZZZZZZZZZZZZZZZZZZZZZZ" : b.Text;
|
||||
Int32 aRelative = (Int32)a.Tag == -1 ? Int32.MaxValue : (Int32)a.Tag;
|
||||
Int32 bRelative = (Int32)b.Tag == -1 ? Int32.MaxValue : (Int32)b.Tag;
|
||||
Int32 aRelative = (Int32)a.SubItems[1].Tag == -1 ? Int32.MaxValue : (Int32)a.SubItems[1].Tag;
|
||||
Int32 bRelative = (Int32)b.SubItems[1].Tag == -1 ? Int32.MaxValue : (Int32)b.SubItems[1].Tag;
|
||||
Int32 aAbsolute = (Int32)a.SubItems[2].Tag;
|
||||
Int32 bAbsolute = (Int32)b.SubItems[2].Tag;
|
||||
|
||||
|
@ -68,9 +70,10 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
|
||||
CodeLabel label = LabelManager.GetLabel((UInt32)entryPoint, AddressType.PrgRom);
|
||||
item = lstFunctions.Items.Add(label?.Label);
|
||||
item.Tag = -1;
|
||||
item.Tag = label;
|
||||
|
||||
item.SubItems.Add("[n/a]");
|
||||
item.SubItems[1].Tag = -1;
|
||||
item.ForeColor = Color.Gray;
|
||||
item.Font = new Font(item.Font, FontStyle.Italic);
|
||||
|
||||
|
@ -81,7 +84,7 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
}
|
||||
|
||||
Int32 relativeAddress = InteropEmu.DebugGetRelativeAddress((UInt32)entryPoint, AddressType.PrgRom);
|
||||
if(relativeAddress != (Int32)item.Tag) {
|
||||
if(relativeAddress != (Int32)item.SubItems[1].Tag) {
|
||||
if(!updating) {
|
||||
updating = true;
|
||||
lstFunctions.BeginUpdate();
|
||||
|
@ -97,7 +100,7 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
item.ForeColor = Color.Gray;
|
||||
item.Font = new Font(item.Font, FontStyle.Italic);
|
||||
}
|
||||
item.Tag = relativeAddress;
|
||||
item.SubItems[1].Tag = relativeAddress;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,5 +121,31 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void mnuEditLabel_Click(object sender, EventArgs e)
|
||||
{
|
||||
CodeLabel label = lstFunctions.SelectedItems[0].Tag as CodeLabel;
|
||||
if(label != null) {
|
||||
ctrlLabelList.EditLabel(label.Address, label.AddressType);
|
||||
} else {
|
||||
ctrlLabelList.EditLabel((UInt32)(Int32)lstFunctions.SelectedItems[0].SubItems[2].Tag, AddressType.PrgRom);
|
||||
}
|
||||
}
|
||||
|
||||
private void mnuFindOccurrences_Click(object sender, EventArgs e)
|
||||
{
|
||||
CodeLabel label = lstFunctions.SelectedItems[0].Tag as CodeLabel;
|
||||
if(label != null) {
|
||||
OnFindOccurrence?.Invoke(label.Label, null);
|
||||
} else {
|
||||
OnFindOccurrence?.Invoke("$" + ((int)lstFunctions.SelectedItems[0].SubItems[1].Tag).ToString("X4"), null);
|
||||
}
|
||||
}
|
||||
|
||||
private void contextMenuStrip_Opening(object sender, CancelEventArgs e)
|
||||
{
|
||||
mnuEditLabel.Enabled = lstFunctions.SelectedItems.Count == 1;
|
||||
mnuFindOccurrences.Enabled = lstFunctions.SelectedItems.Count == 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,4 +117,7 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="contextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
28
GUI.NET/Debugger/Controls/ctrlLabelList.Designer.cs
generated
28
GUI.NET/Debugger/Controls/ctrlLabelList.Designer.cs
generated
|
@ -36,6 +36,8 @@
|
|||
this.mnuAdd = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuEdit = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuDelete = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuFindOccurrences = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.contextMenu.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
@ -80,23 +82,25 @@
|
|||
this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.mnuAdd,
|
||||
this.mnuEdit,
|
||||
this.mnuDelete});
|
||||
this.mnuDelete,
|
||||
this.toolStripMenuItem1,
|
||||
this.mnuFindOccurrences});
|
||||
this.contextMenu.Name = "contextMenu";
|
||||
this.contextMenu.Size = new System.Drawing.Size(132, 70);
|
||||
this.contextMenu.Size = new System.Drawing.Size(167, 120);
|
||||
this.contextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.mnuActions_Opening);
|
||||
//
|
||||
// mnuAdd
|
||||
//
|
||||
this.mnuAdd.Name = "mnuAdd";
|
||||
this.mnuAdd.ShortcutKeys = System.Windows.Forms.Keys.Insert;
|
||||
this.mnuAdd.Size = new System.Drawing.Size(131, 22);
|
||||
this.mnuAdd.Size = new System.Drawing.Size(166, 22);
|
||||
this.mnuAdd.Text = "Add";
|
||||
this.mnuAdd.Click += new System.EventHandler(this.mnuAdd_Click);
|
||||
//
|
||||
// mnuEdit
|
||||
//
|
||||
this.mnuEdit.Name = "mnuEdit";
|
||||
this.mnuEdit.Size = new System.Drawing.Size(131, 22);
|
||||
this.mnuEdit.Size = new System.Drawing.Size(166, 22);
|
||||
this.mnuEdit.Text = "Edit";
|
||||
this.mnuEdit.Click += new System.EventHandler(this.mnuEdit_Click);
|
||||
//
|
||||
|
@ -104,10 +108,22 @@
|
|||
//
|
||||
this.mnuDelete.Name = "mnuDelete";
|
||||
this.mnuDelete.ShortcutKeys = System.Windows.Forms.Keys.Delete;
|
||||
this.mnuDelete.Size = new System.Drawing.Size(131, 22);
|
||||
this.mnuDelete.Size = new System.Drawing.Size(166, 22);
|
||||
this.mnuDelete.Text = "Delete";
|
||||
this.mnuDelete.Click += new System.EventHandler(this.mnuDelete_Click);
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(163, 6);
|
||||
//
|
||||
// mnuFindOccurrences
|
||||
//
|
||||
this.mnuFindOccurrences.Name = "mnuFindOccurrences";
|
||||
this.mnuFindOccurrences.Size = new System.Drawing.Size(166, 22);
|
||||
this.mnuFindOccurrences.Text = "Find Occurrences";
|
||||
this.mnuFindOccurrences.Click += new System.EventHandler(this.mnuFindOccurrences_Click);
|
||||
//
|
||||
// ctrlLabelList
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -130,5 +146,7 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem mnuDelete;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuAdd;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuEdit;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuFindOccurrences;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
{
|
||||
public partial class ctrlLabelList : UserControl
|
||||
{
|
||||
public event EventHandler OnFindOccurrence;
|
||||
public event EventHandler OnLabelSelected;
|
||||
private List<ListViewItem> _listItems = new List<ListViewItem>();
|
||||
|
||||
|
@ -114,6 +115,7 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
{
|
||||
mnuDelete.Enabled = lstLabels.SelectedItems.Count > 0;
|
||||
mnuEdit.Enabled = lstLabels.SelectedItems.Count == 1;
|
||||
mnuFindOccurrences.Enabled = lstLabels.SelectedItems.Count == 1;
|
||||
}
|
||||
|
||||
private void mnuDelete_Click(object sender, EventArgs e)
|
||||
|
@ -139,5 +141,10 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
CodeLabel label = (CodeLabel)lstLabels.SelectedItems[0].SubItems[1].Tag;
|
||||
EditLabel(label.Address, label.AddressType);
|
||||
}
|
||||
|
||||
private void mnuFindOccurrences_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnFindOccurrence?.Invoke(lstLabels.SelectedItems[0].SubItems[1].Tag, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -370,5 +370,10 @@ namespace Mesen.GUI.Debugger
|
|||
this.ctrlTextbox.ScrollToLineNumber((int)address.Address);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Tuple<int, int, string>> FindAllOccurrences(string text)
|
||||
{
|
||||
return this.ctrlTextbox.FindAllOccurrences(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,9 +47,9 @@
|
|||
//
|
||||
this.vScrollBar.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.vScrollBar.LargeChange = 20;
|
||||
this.vScrollBar.Location = new System.Drawing.Point(305, 0);
|
||||
this.vScrollBar.Location = new System.Drawing.Point(490, 0);
|
||||
this.vScrollBar.Name = "vScrollBar";
|
||||
this.vScrollBar.Size = new System.Drawing.Size(18, 156);
|
||||
this.vScrollBar.Size = new System.Drawing.Size(18, 141);
|
||||
this.vScrollBar.TabIndex = 0;
|
||||
//
|
||||
// panelSearch
|
||||
|
@ -57,7 +57,7 @@
|
|||
this.panelSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.panelSearch.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.panelSearch.Controls.Add(this.tableLayoutPanel1);
|
||||
this.panelSearch.Location = new System.Drawing.Point(81, -1);
|
||||
this.panelSearch.Location = new System.Drawing.Point(266, -1);
|
||||
this.panelSearch.Name = "panelSearch";
|
||||
this.panelSearch.Size = new System.Drawing.Size(222, 28);
|
||||
this.panelSearch.TabIndex = 2;
|
||||
|
@ -136,22 +136,23 @@
|
|||
// hScrollBar
|
||||
//
|
||||
this.hScrollBar.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.hScrollBar.Location = new System.Drawing.Point(0, 156);
|
||||
this.hScrollBar.Location = new System.Drawing.Point(0, 141);
|
||||
this.hScrollBar.Name = "hScrollBar";
|
||||
this.hScrollBar.Size = new System.Drawing.Size(323, 18);
|
||||
this.hScrollBar.Size = new System.Drawing.Size(508, 18);
|
||||
this.hScrollBar.TabIndex = 3;
|
||||
//
|
||||
// ctrlTextbox
|
||||
//
|
||||
this.ctrlTextbox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.ctrlTextbox.Font = new System.Drawing.Font("Consolas", 13F);
|
||||
this.ctrlTextbox.HorizontalScrollWidth = 0;
|
||||
this.ctrlTextbox.Location = new System.Drawing.Point(0, 0);
|
||||
this.ctrlTextbox.Name = "ctrlTextbox";
|
||||
this.ctrlTextbox.ShowContentNotes = false;
|
||||
this.ctrlTextbox.ShowLineInHex = false;
|
||||
this.ctrlTextbox.ShowLineNumberNotes = false;
|
||||
this.ctrlTextbox.ShowLineNumbers = true;
|
||||
this.ctrlTextbox.Size = new System.Drawing.Size(305, 156);
|
||||
this.ctrlTextbox.Size = new System.Drawing.Size(490, 141);
|
||||
this.ctrlTextbox.TabIndex = 1;
|
||||
//
|
||||
// ctrlScrollableTextbox
|
||||
|
@ -164,7 +165,7 @@
|
|||
this.Controls.Add(this.vScrollBar);
|
||||
this.Controls.Add(this.hScrollBar);
|
||||
this.Name = "ctrlScrollableTextbox";
|
||||
this.Size = new System.Drawing.Size(323, 174);
|
||||
this.Size = new System.Drawing.Size(508, 159);
|
||||
this.panelSearch.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.PerformLayout();
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.Drawing;
|
|||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
@ -192,6 +193,40 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
}
|
||||
|
||||
public List<Tuple<int, int, string>> FindAllOccurrences(string text)
|
||||
{
|
||||
List<Tuple<int, int, string>> result = new List<Tuple<int, int, string>>();
|
||||
string regex;
|
||||
if(text.StartsWith("$")) {
|
||||
regex = $"[^#]+\\$\\b{text.Substring(1, text.Length - 1)}\\b";
|
||||
} else {
|
||||
regex = $"\\b{text}\\b";
|
||||
}
|
||||
|
||||
for(int i = 0, len = _contents.Length; i < len; i++) {
|
||||
if(Regex.IsMatch(_contents[i], regex, RegexOptions.IgnoreCase)) {
|
||||
string line = _contents[i].Replace("\x2", "\t").Trim();
|
||||
|
||||
if(line.StartsWith("__") && line.EndsWith("__") || line.StartsWith("[[") && line.EndsWith("]]")) {
|
||||
line = "Block: " + line.Substring(2, line.Length - 4);
|
||||
}
|
||||
|
||||
if(line.StartsWith("--") && line.EndsWith("--")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int j = i;
|
||||
while(j < _lineNumbers.Length && _lineNumbers[j] < 0) {
|
||||
j++;
|
||||
}
|
||||
|
||||
var searchResult = new Tuple<int, int, string>(_lineNumbers[j], i, line);
|
||||
result.Add(searchResult);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool Search(string searchString, bool searchBackwards, bool isNewSearch)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(searchString)) {
|
||||
|
|
2
GUI.NET/Debugger/frmDebugger.Designer.cs
generated
2
GUI.NET/Debugger/frmDebugger.Designer.cs
generated
|
@ -276,6 +276,7 @@
|
|||
this.ctrlLabelList.Name = "ctrlLabelList";
|
||||
this.ctrlLabelList.Size = new System.Drawing.Size(298, 174);
|
||||
this.ctrlLabelList.TabIndex = 0;
|
||||
this.ctrlLabelList.OnFindOccurrence += new System.EventHandler(this.ctrlLabelList_OnFindOccurrence);
|
||||
this.ctrlLabelList.OnLabelSelected += new System.EventHandler(this.ctrlLabelList_OnLabelSelected);
|
||||
//
|
||||
// grpFunctions
|
||||
|
@ -296,6 +297,7 @@
|
|||
this.ctrlFunctionList.Name = "ctrlFunctionList";
|
||||
this.ctrlFunctionList.Size = new System.Drawing.Size(298, 174);
|
||||
this.ctrlFunctionList.TabIndex = 0;
|
||||
this.ctrlFunctionList.OnFindOccurrence += new System.EventHandler(this.ctrlFunctionList_OnFindOccurrence);
|
||||
this.ctrlFunctionList.OnFunctionSelected += new System.EventHandler(this.ctrlFunctionList_OnFunctionSelected);
|
||||
//
|
||||
// tableLayoutPanel10
|
||||
|
|
|
@ -560,6 +560,7 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
private void LabelManager_OnLabelUpdated(object sender, EventArgs e)
|
||||
{
|
||||
SaveWorkspace();
|
||||
ctrlLabelList.UpdateLabelList();
|
||||
ctrlFunctionList.UpdateFunctionList(true);
|
||||
UpdateDebugger(false);
|
||||
|
@ -598,5 +599,16 @@ namespace Mesen.GUI.Debugger
|
|||
dbgImporter.Import(ofd.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void ctrlLabelList_OnFindOccurrence(object sender, EventArgs e)
|
||||
{
|
||||
CodeLabel label = sender as CodeLabel;
|
||||
_lastCodeWindow.FindAllOccurrences(label.Label);
|
||||
}
|
||||
|
||||
private void ctrlFunctionList_OnFindOccurrence(object sender, EventArgs e)
|
||||
{
|
||||
_lastCodeWindow.FindAllOccurrences(sender as string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue