Debugger: Seperate watch entries for CPU vs SPC
This commit is contained in:
parent
35476426c0
commit
f0d4e6deeb
5 changed files with 69 additions and 36 deletions
4
UI/Debugger/Controls/ctrlWatch.Designer.cs
generated
4
UI/Debugger/Controls/ctrlWatch.Designer.cs
generated
|
@ -16,7 +16,9 @@
|
|||
if(disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
WatchManager.WatchChanged -= WatchManager_WatchChanged;
|
||||
if(_watchManager != null) {
|
||||
_watchManager.WatchChanged -= WatchManager_WatchChanged;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
private bool _isEditing = false;
|
||||
ListViewItem _keyDownItem = null;
|
||||
private CpuType _cpuType;
|
||||
private WatchManager _watchManager;
|
||||
|
||||
public ctrlWatch()
|
||||
{
|
||||
|
@ -37,13 +39,24 @@ namespace Mesen.GUI.Debugger
|
|||
this.DoubleBuffered = true;
|
||||
}
|
||||
|
||||
public CpuType CpuType { get; set; }
|
||||
public CpuType CpuType
|
||||
{
|
||||
get { return _cpuType; }
|
||||
set
|
||||
{
|
||||
_cpuType = value;
|
||||
if(_watchManager != null) {
|
||||
_watchManager.WatchChanged -= WatchManager_WatchChanged;
|
||||
}
|
||||
_watchManager = WatchManager.GetWatchManager(value);
|
||||
_watchManager.WatchChanged += WatchManager_WatchChanged;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
if(!IsDesignMode) {
|
||||
WatchManager.WatchChanged += WatchManager_WatchChanged;
|
||||
mnuRemoveWatch.InitShortcut(this, nameof(DebuggerShortcutsConfig.WatchList_Delete));
|
||||
mnuEditInMemoryViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_EditInMemoryViewer));
|
||||
mnuViewInDisassembly.InitShortcut(this, nameof(DebuggerShortcutsConfig.MemoryViewer_ViewInDisassembly));
|
||||
|
@ -104,7 +117,7 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
public void UpdateWatch(bool autoResizeColumns = true)
|
||||
{
|
||||
List<WatchValueInfo> watchContent = WatchManager.GetWatchContent(this.CpuType, _previousValues);
|
||||
List<WatchValueInfo> watchContent = _watchManager.GetWatchContent(this.CpuType, _previousValues);
|
||||
_previousValues = watchContent;
|
||||
|
||||
bool updating = false;
|
||||
|
@ -161,7 +174,7 @@ namespace Mesen.GUI.Debugger
|
|||
lstWatch.EndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void lstWatch_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
mnuRemoveWatch.Enabled = lstWatch.SelectedItems.Count >= 1;
|
||||
|
@ -216,7 +229,7 @@ namespace Mesen.GUI.Debugger
|
|||
foreach(ListViewItem item in lstWatch.SelectedItems) {
|
||||
itemsToRemove.Add(item.Index);
|
||||
}
|
||||
WatchManager.RemoveWatch(itemsToRemove.ToArray());
|
||||
_watchManager.RemoveWatch(itemsToRemove.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,7 +300,7 @@ namespace Mesen.GUI.Debugger
|
|||
{
|
||||
if(lstWatch.SelectedItems.Count > 0) {
|
||||
lstWatch.SelectedItems[0].Text = txtEdit.Text;
|
||||
WatchManager.UpdateWatch(lstWatch.SelectedIndices[0], txtEdit.Text);
|
||||
_watchManager.UpdateWatch(lstWatch.SelectedIndices[0], txtEdit.Text);
|
||||
}
|
||||
lstWatch.Focus();
|
||||
}
|
||||
|
@ -355,8 +368,8 @@ namespace Mesen.GUI.Debugger
|
|||
string currentEntry = lstWatch.Items[index].SubItems[0].Text;
|
||||
string entryAbove = lstWatch.Items[index - 1].SubItems[0].Text;
|
||||
SetSelectedItem(index - 1);
|
||||
WatchManager.UpdateWatch(index - 1, currentEntry);
|
||||
WatchManager.UpdateWatch(index, entryAbove);
|
||||
_watchManager.UpdateWatch(index - 1, currentEntry);
|
||||
_watchManager.UpdateWatch(index, entryAbove);
|
||||
} else {
|
||||
SetSelectedItem(index);
|
||||
}
|
||||
|
@ -373,8 +386,8 @@ namespace Mesen.GUI.Debugger
|
|||
string currentEntry = lstWatch.Items[index].SubItems[0].Text;
|
||||
string entryBelow = lstWatch.Items[index + 1].SubItems[0].Text;
|
||||
SetSelectedItem(index + 1);
|
||||
WatchManager.UpdateWatch(index + 1, currentEntry);
|
||||
WatchManager.UpdateWatch(index, entryBelow);
|
||||
_watchManager.UpdateWatch(index + 1, currentEntry);
|
||||
_watchManager.UpdateWatch(index, entryBelow);
|
||||
} else {
|
||||
SetSelectedItem(index);
|
||||
}
|
||||
|
@ -396,7 +409,7 @@ namespace Mesen.GUI.Debugger
|
|||
using(OpenFileDialog ofd = new OpenFileDialog()) {
|
||||
ofd.SetFilter("Watch files (*.mwf)|*.mwf");
|
||||
if(ofd.ShowDialog() == DialogResult.OK) {
|
||||
WatchManager.Import(ofd.FileName);
|
||||
_watchManager.Import(ofd.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -406,7 +419,7 @@ namespace Mesen.GUI.Debugger
|
|||
using(SaveFileDialog sfd = new SaveFileDialog()) {
|
||||
sfd.SetFilter("Watch files (*.mwf)|*.mwf");
|
||||
if(sfd.ShowDialog() == DialogResult.OK) {
|
||||
WatchManager.Export(sfd.FileName);
|
||||
_watchManager.Export(sfd.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -455,15 +468,15 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
private void SetSelectionFormat(string formatString)
|
||||
{
|
||||
List<string> entries = WatchManager.WatchEntries;
|
||||
List<string> entries = _watchManager.WatchEntries;
|
||||
foreach(int i in lstWatch.SelectedIndices) {
|
||||
if(i < entries.Count) {
|
||||
Match match = WatchManager.FormatSuffixRegex.Match(entries[i]);
|
||||
if(match.Success) {
|
||||
WatchManager.UpdateWatch(i, match.Groups[1].Value + formatString);
|
||||
_watchManager.UpdateWatch(i, match.Groups[1].Value + formatString);
|
||||
} else {
|
||||
WatchManager.UpdateWatch(i, entries[i] + formatString);
|
||||
}
|
||||
_watchManager.UpdateWatch(i, entries[i] + formatString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,25 @@ namespace Mesen.GUI.Debugger
|
|||
{
|
||||
class WatchManager
|
||||
{
|
||||
public static event EventHandler WatchChanged;
|
||||
private static List<string> _watchEntries = new List<string>();
|
||||
private static Regex _arrayWatchRegex = new Regex(@"\[((\$[0-9A-Fa-f]+)|(\d+)|([@_a-zA-Z0-9]+))\s*,\s*(\d+)\]", RegexOptions.Compiled);
|
||||
public static Regex FormatSuffixRegex = new Regex(@"^(.*),\s*([B|H|S|U])([\d]){0,1}$", RegexOptions.Compiled);
|
||||
private static Regex _arrayWatchRegex = new Regex(@"\[((\$[0-9A-Fa-f]+)|(\d+)|([@_a-zA-Z0-9]+))\s*,\s*(\d+)\]", RegexOptions.Compiled);
|
||||
|
||||
public static List<string> WatchEntries
|
||||
public event EventHandler WatchChanged;
|
||||
private List<string> _watchEntries = new List<string>();
|
||||
|
||||
private static Dictionary<CpuType, WatchManager> _watchManagers = new Dictionary<CpuType, WatchManager>();
|
||||
|
||||
public static WatchManager GetWatchManager(CpuType cpuType)
|
||||
{
|
||||
WatchManager manager;
|
||||
if(!_watchManagers.TryGetValue(cpuType, out manager)) {
|
||||
manager = new WatchManager();
|
||||
_watchManagers[cpuType] = manager;
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
|
||||
public List<string> WatchEntries
|
||||
{
|
||||
get { return _watchEntries; }
|
||||
set
|
||||
|
@ -26,7 +39,7 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
}
|
||||
|
||||
public static List<WatchValueInfo> GetWatchContent(CpuType cpuType, List<WatchValueInfo> previousValues)
|
||||
public List<WatchValueInfo> GetWatchContent(CpuType cpuType, List<WatchValueInfo> previousValues)
|
||||
{
|
||||
WatchFormatStyle defaultStyle = ConfigManager.Config.Debug.Debugger.WatchFormat;
|
||||
int defaultByteLength = 1;
|
||||
|
@ -72,7 +85,7 @@ namespace Mesen.GUI.Debugger
|
|||
return list;
|
||||
}
|
||||
|
||||
private static string FormatValue(int value, WatchFormatStyle style, int byteLength)
|
||||
private string FormatValue(int value, WatchFormatStyle style, int byteLength)
|
||||
{
|
||||
switch(style) {
|
||||
case WatchFormatStyle.Unsigned: return ((UInt32)value).ToString();
|
||||
|
@ -101,12 +114,12 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
}
|
||||
|
||||
public static bool IsArraySyntax(string expression)
|
||||
public bool IsArraySyntax(string expression)
|
||||
{
|
||||
return _arrayWatchRegex.IsMatch(expression);
|
||||
}
|
||||
|
||||
private static bool ProcessFormatSpecifier(ref string expression, ref WatchFormatStyle style, ref int byteLength)
|
||||
private bool ProcessFormatSpecifier(ref string expression, ref WatchFormatStyle style, ref int byteLength)
|
||||
{
|
||||
Match match = WatchManager.FormatSuffixRegex.Match(expression);
|
||||
if(!match.Success) {
|
||||
|
@ -132,7 +145,7 @@ namespace Mesen.GUI.Debugger
|
|||
return true;
|
||||
}
|
||||
|
||||
private static string ProcessArrayDisplaySyntax(WatchFormatStyle style, ref bool forceHasChanged, Match match)
|
||||
private string ProcessArrayDisplaySyntax(WatchFormatStyle style, ref bool forceHasChanged, Match match)
|
||||
{
|
||||
string newValue;
|
||||
int address;
|
||||
|
@ -166,7 +179,7 @@ namespace Mesen.GUI.Debugger
|
|||
return newValue;
|
||||
}
|
||||
|
||||
public static void AddWatch(params string[] expressions)
|
||||
public void AddWatch(params string[] expressions)
|
||||
{
|
||||
foreach(string expression in expressions) {
|
||||
_watchEntries.Add(expression);
|
||||
|
@ -174,7 +187,7 @@ namespace Mesen.GUI.Debugger
|
|||
WatchChanged?.Invoke(null, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public static void UpdateWatch(int index, string expression)
|
||||
public void UpdateWatch(int index, string expression)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(expression)) {
|
||||
RemoveWatch(index);
|
||||
|
@ -188,7 +201,7 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
}
|
||||
|
||||
public static void RemoveWatch(params int[] indexes)
|
||||
public void RemoveWatch(params int[] indexes)
|
||||
{
|
||||
HashSet<int> set = new HashSet<int>(indexes);
|
||||
_watchEntries = _watchEntries.Where((el, index) => !set.Contains(index)).ToList();
|
||||
|
@ -196,16 +209,16 @@ namespace Mesen.GUI.Debugger
|
|||
WatchChanged?.Invoke(null, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public static void Import(string filename)
|
||||
public void Import(string filename)
|
||||
{
|
||||
if(File.Exists(filename)) {
|
||||
WatchManager.WatchEntries = new List<string>(File.ReadAllLines(filename));
|
||||
WatchEntries = new List<string>(File.ReadAllLines(filename));
|
||||
}
|
||||
}
|
||||
|
||||
public static void Export(string filename)
|
||||
public void Export(string filename)
|
||||
{
|
||||
File.WriteAllLines(filename, WatchManager.WatchEntries);
|
||||
File.WriteAllLines(filename, WatchEntries);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Mesen.GUI.Debugger.Workspace
|
|||
{
|
||||
public List<Breakpoint> Breakpoints = new List<Breakpoint>();
|
||||
public List<string> WatchValues = new List<string>();
|
||||
public List<string> SpcWatchValues = new List<string>();
|
||||
//public List<CodeLabel> Labels = new List<CodeLabel>();
|
||||
public List<string> TblMappings = null;
|
||||
private string _filePath;
|
||||
|
|
|
@ -15,7 +15,8 @@ namespace Mesen.GUI.Debugger.Workspace
|
|||
public static void SaveWorkspace()
|
||||
{
|
||||
if(_workspace != null) {
|
||||
_workspace.WatchValues = new List<string>(WatchManager.WatchEntries);
|
||||
_workspace.WatchValues = new List<string>(WatchManager.GetWatchManager(CpuType.Cpu).WatchEntries);
|
||||
_workspace.SpcWatchValues = new List<string>(WatchManager.GetWatchManager(CpuType.Spc).WatchEntries);
|
||||
_workspace.Breakpoints = new List<Breakpoint>(BreakpointManager.Breakpoints);
|
||||
_workspace.Save();
|
||||
}
|
||||
|
@ -32,7 +33,9 @@ namespace Mesen.GUI.Debugger.Workspace
|
|||
if(_workspace != null) {
|
||||
_workspace.Breakpoints = new List<Breakpoint>();
|
||||
_workspace.WatchValues = new List<string>();
|
||||
WatchManager.WatchEntries = _workspace.WatchValues;
|
||||
_workspace.SpcWatchValues = new List<string>();
|
||||
WatchManager.GetWatchManager(CpuType.Cpu).WatchEntries = _workspace.WatchValues;
|
||||
WatchManager.GetWatchManager(CpuType.Spc).WatchEntries = _workspace.SpcWatchValues;
|
||||
BreakpointManager.SetBreakpoints(_workspace.Breakpoints);
|
||||
_workspace.Save();
|
||||
Clear();
|
||||
|
@ -50,7 +53,8 @@ namespace Mesen.GUI.Debugger.Workspace
|
|||
_workspace = DebugWorkspace.GetWorkspace();
|
||||
|
||||
//Load watch entries
|
||||
WatchManager.WatchEntries = _workspace.WatchValues;
|
||||
WatchManager.GetWatchManager(CpuType.Cpu).WatchEntries = _workspace.WatchValues;
|
||||
WatchManager.GetWatchManager(CpuType.Spc).WatchEntries = _workspace.SpcWatchValues;
|
||||
|
||||
//Load breakpoints
|
||||
BreakpointManager.SetBreakpoints(_workspace.Breakpoints);
|
||||
|
|
Loading…
Add table
Reference in a new issue