Debugger: Allow double-clicking in profiler to move to function in debugger + better sort default

This commit is contained in:
Souryo 2016-12-09 00:12:38 -05:00
parent 75076d5db5
commit c023a87dd9
4 changed files with 33 additions and 4 deletions

View file

@ -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
//

View file

@ -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
{

View file

@ -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;

View file

@ -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) {