diff --git a/GUI.NET/Debugger/Controls/ctrlProfiler.Designer.cs b/GUI.NET/Debugger/Controls/ctrlProfiler.Designer.cs index 6d70a370..80684fcc 100644 --- a/GUI.NET/Debugger/Controls/ctrlProfiler.Designer.cs +++ b/GUI.NET/Debugger/Controls/ctrlProfiler.Designer.cs @@ -92,6 +92,7 @@ this.lstFunctions.Dock = System.Windows.Forms.DockStyle.Fill; this.lstFunctions.FullRowSelect = true; this.lstFunctions.GridLines = true; + this.lstFunctions.HideSelection = false; this.lstFunctions.Location = new System.Drawing.Point(3, 3); this.lstFunctions.Name = "lstFunctions"; this.lstFunctions.Size = new System.Drawing.Size(508, 272); @@ -99,6 +100,7 @@ this.lstFunctions.UseCompatibleStateImageBehavior = false; this.lstFunctions.View = System.Windows.Forms.View.Details; this.lstFunctions.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lstFunctions_ColumnClick); + this.lstFunctions.DoubleClick += new System.EventHandler(this.lstFunctions_DoubleClick); // // columnHeader1 // diff --git a/GUI.NET/Debugger/Controls/ctrlProfiler.cs b/GUI.NET/Debugger/Controls/ctrlProfiler.cs index bbaf5568..5fbf6a52 100644 --- a/GUI.NET/Debugger/Controls/ctrlProfiler.cs +++ b/GUI.NET/Debugger/Controls/ctrlProfiler.cs @@ -13,12 +13,13 @@ namespace Mesen.GUI.Debugger.Controls { public partial class ctrlProfiler : UserControl { + public static event EventHandler OnFunctionSelected; private Int64[] _exclusiveTime; private Int64[] _inclusiveTime; private Int64[] _callCount; - private int _sortColumn = 1; - private bool _sortOrder = false; + private int _sortColumn = 5; + private bool _sortOrder = true; public ctrlProfiler() { @@ -63,7 +64,7 @@ namespace Mesen.GUI.Debugger.Controls lstFunctions.BeginUpdate(); lstFunctions.ListViewItemSorter = null; lstFunctions.Items.Clear(); - for(int i = 0; i < _exclusiveTime.Length; i++) { + for(UInt32 i = 0; i < _exclusiveTime.Length; i++) { if(_exclusiveTime[i] > 0) { string functionName; @@ -80,6 +81,8 @@ namespace Mesen.GUI.Debugger.Controls } ListViewItem item = lstFunctions.Items.Add(functionName); + item.Tag = i; + item.SubItems.Add(_callCount[i].ToString()); item.SubItems[1].Tag = _callCount[i]; @@ -124,6 +127,13 @@ namespace Mesen.GUI.Debugger.Controls RefreshList(); } + + private void lstFunctions_DoubleClick(object sender, EventArgs e) + { + if(lstFunctions.SelectedItems.Count > 0) { + OnFunctionSelected?.Invoke(lstFunctions.SelectedItems[0].Tag, EventArgs.Empty); + } + } private class ListComparer : IComparer { diff --git a/GUI.NET/Debugger/frmDebugger.Designer.cs b/GUI.NET/Debugger/frmDebugger.Designer.cs index ccda88d9..12a51c47 100644 --- a/GUI.NET/Debugger/frmDebugger.Designer.cs +++ b/GUI.NET/Debugger/frmDebugger.Designer.cs @@ -1,4 +1,6 @@ -namespace Mesen.GUI.Debugger +using Mesen.GUI.Debugger.Controls; + +namespace Mesen.GUI.Debugger { partial class frmDebugger { @@ -17,6 +19,10 @@ components.Dispose(); } LabelManager.OnLabelUpdated -= LabelManager_OnLabelUpdated; + BreakpointManager.BreakpointsChanged -= BreakpointManager_BreakpointsChanged; + ctrlConsoleStatus.OnStateChanged -= ctrlConsoleStatus_OnStateChanged; + ctrlProfiler.OnFunctionSelected -= ctrlProfiler_OnFunctionSelected; + if(_notifListener != null) { _notifListener.Dispose(); _notifListener = null; diff --git a/GUI.NET/Debugger/frmDebugger.cs b/GUI.NET/Debugger/frmDebugger.cs index 4d16d6ee..6f019c81 100644 --- a/GUI.NET/Debugger/frmDebugger.cs +++ b/GUI.NET/Debugger/frmDebugger.cs @@ -10,6 +10,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Mesen.GUI.Config; +using Mesen.GUI.Debugger.Controls; using Mesen.GUI.Forms; namespace Mesen.GUI.Debugger @@ -37,6 +38,7 @@ namespace Mesen.GUI.Debugger ctrlConsoleStatus.OnStateChanged += ctrlConsoleStatus_OnStateChanged; LabelManager.OnLabelUpdated += LabelManager_OnLabelUpdated; BreakpointManager.BreakpointsChanged += BreakpointManager_BreakpointsChanged; + ctrlProfiler.OnFunctionSelected += ctrlProfiler_OnFunctionSelected; this.UpdateWorkspace(); this.AutoLoadDbgFile(true); @@ -122,6 +124,15 @@ namespace Mesen.GUI.Debugger tmrCdlRatios.Start(); } + private void ctrlProfiler_OnFunctionSelected(object sender, EventArgs e) + { + int relativeAddress = InteropEmu.DebugGetRelativeAddress((UInt32)sender, AddressType.PrgRom); + if(relativeAddress >= 0) { + BringToFront(); + _lastCodeWindow.ScrollToLineNumber(relativeAddress); + } + } + private void AutoLoadDbgFile(bool silent) { if(ConfigManager.Config.DebugInfo.AutoLoadDbgFiles) {