Debugger: Breakpoints - Only enable CPU/SPC breakpoints if the matching debugger window is opened (and fix breakpoints not being enabled after power cycle)

This commit is contained in:
Sour 2019-04-21 20:37:05 -04:00
parent f0cb8052d7
commit 02cab97944
3 changed files with 22 additions and 16 deletions

View file

@ -156,12 +156,14 @@ namespace Mesen.GUI.Debugger
return -1;
}
public CpuType GetCpuType()
{
return _memoryType == SnesMemoryType.SpcMemory ? CpuType.Spc : CpuType.Cpu;
}
public bool Matches(CpuType type)
{
return (
(type == CpuType.Spc && _memoryType == SnesMemoryType.SpcMemory) ||
(type == CpuType.Cpu && _memoryType != SnesMemoryType.SpcMemory)
);
return GetCpuType() == type;
}
public bool Matches(UInt32 address, SnesMemoryType type)

View file

@ -11,21 +11,23 @@ namespace Mesen.GUI.Debugger
public static event EventHandler BreakpointsChanged;
private static List<Breakpoint> _breakpoints = new List<Breakpoint>();
private static bool _breakpointsEnabled = false;
private static HashSet<CpuType> _activeCpuTypes = new HashSet<CpuType>();
public static ReadOnlyCollection<Breakpoint> Breakpoints
{
get { return _breakpoints.ToList().AsReadOnly(); }
}
public static bool BreakpointsEnabled
public static void AddCpuType(CpuType cpuType)
{
get { return _breakpointsEnabled; }
set
{
_breakpointsEnabled = value;
SetBreakpoints();
}
_activeCpuTypes.Add(cpuType);
SetBreakpoints();
}
public static void RemoveCpuType(CpuType cpuType)
{
_activeCpuTypes.Remove(cpuType);
SetBreakpoints();
}
public static void RefreshBreakpoints(Breakpoint bp = null)
@ -116,8 +118,8 @@ namespace Mesen.GUI.Debugger
public static void SetBreakpoints()
{
List<InteropBreakpoint> breakpoints = new List<InteropBreakpoint>();
if(BreakpointsEnabled) {
for(int i = 0; i < Breakpoints.Count; i++) {
for(int i = 0; i < Breakpoints.Count; i++) {
if(_activeCpuTypes.Contains(Breakpoints[i].GetCpuType())) {
breakpoints.Add(Breakpoints[i].ToInteropBreakpoint(i));
}
}

View file

@ -54,7 +54,7 @@ namespace Mesen.GUI.Debugger
toolTip.SetToolTip(picWatchHelp, ctrlWatch.GetTooltipText());
BreakpointManager.BreakpointsEnabled = true;
BreakpointManager.AddCpuType(_cpuType);
DebugApi.Step(10000, StepType.CpuStep);
}
@ -68,7 +68,8 @@ namespace Mesen.GUI.Debugger
_entityBinder.UpdateObject();
ConfigManager.ApplyChanges();
BreakpointManager.BreakpointsEnabled = false;
BreakpointManager.RemoveCpuType(_cpuType);
if(this._notifListener != null) {
this._notifListener.Dispose();
this._notifListener = null;
@ -258,6 +259,7 @@ namespace Mesen.GUI.Debugger
DebugState state = DebugApi.GetState();
this.BeginInvoke((MethodInvoker)(() => {
UpdateDebugger(state, null);
BreakpointManager.SetBreakpoints();
}));
break;
}