Debugger: Disable breakpoints when debugger window is closed

(and fixed issue with breakpoint list being empty if any other debugger window was opened first)
This commit is contained in:
Sour 2019-03-30 22:11:21 -04:00
parent 4402be3c52
commit ba4de9135c
5 changed files with 41 additions and 18 deletions

View file

@ -11,12 +11,23 @@ namespace Mesen.GUI.Debugger
public static event EventHandler BreakpointsChanged;
private static List<Breakpoint> _breakpoints = new List<Breakpoint>();
private static bool _breakpointsEnabled = false;
public static ReadOnlyCollection<Breakpoint> Breakpoints
{
get { return _breakpoints.ToList().AsReadOnly(); }
}
public static bool BreakpointsEnabled
{
get { return _breakpointsEnabled; }
set
{
_breakpointsEnabled = value;
SetBreakpoints();
}
}
public static void RefreshBreakpoints(Breakpoint bp = null)
{
if(BreakpointsChanged != null) {
@ -105,8 +116,10 @@ namespace Mesen.GUI.Debugger
public static void SetBreakpoints()
{
List<InteropBreakpoint> breakpoints = new List<InteropBreakpoint>();
for(int i = 0; i < Breakpoints.Count; i++) {
breakpoints.Add(Breakpoints[i].ToInteropBreakpoint(i));
if(BreakpointsEnabled) {
for(int i = 0; i < Breakpoints.Count; i++) {
breakpoints.Add(Breakpoints[i].ToInteropBreakpoint(i));
}
}
DebugApi.SetBreakpoints(breakpoints.ToArray(), (UInt32)breakpoints.Count);
}

View file

@ -40,6 +40,8 @@ namespace Mesen.GUI.Debugger.Controls
mnuGoToLocation.Enabled = false;
InitShortcuts();
RefreshList();
}
}

View file

@ -57,12 +57,16 @@ namespace Mesen.GUI.Debugger.Controls
public void SetActiveAddress(int? address)
{
UpdateCode();
if(_styleProvider.ActiveAddress == address) {
return;
}
_styleProvider.ActiveAddress = address;
if(address.HasValue && address.Value >= 0) {
ctrlCode.ScrollToAddress(address.Value);
}
ctrlCode.Invalidate();
}
public void ScrollToAddress(uint address)
@ -70,7 +74,7 @@ namespace Mesen.GUI.Debugger.Controls
ctrlCode.ScrollToAddress((int)address);
}
private void UpdateCode()
public void UpdateCode()
{
int centerLineIndex = ctrlCode.GetLineIndexAtPosition(0) + ctrlCode.GetNumberVisibleLines() / 2;
int centerLineAddress;

View file

@ -35,6 +35,7 @@ namespace Mesen.GUI.Debugger
this.pnlPicture = new System.Windows.Forms.Panel();
this.grpOptions = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.chkShowPreviousFrameEvents = new System.Windows.Forms.CheckBox();
this.picNmi = new Mesen.GUI.Debugger.ctrlColorPicker();
this.chkShowNmi = new System.Windows.Forms.CheckBox();
this.picIrq = new Mesen.GUI.Debugger.ctrlColorPicker();
@ -62,7 +63,6 @@ namespace Mesen.GUI.Debugger
this.picPpuReads = new Mesen.GUI.Debugger.ctrlColorPicker();
this.chkShowMarkedBreakpoints = new System.Windows.Forms.CheckBox();
this.picMarkedBreakpoints = new Mesen.GUI.Debugger.ctrlColorPicker();
this.chkShowPreviousFrameEvents = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.picViewer)).BeginInit();
this.pnlPicture.SuspendLayout();
this.grpOptions.SuspendLayout();
@ -173,6 +173,19 @@ namespace Mesen.GUI.Debugger
this.tableLayoutPanel1.Size = new System.Drawing.Size(255, 510);
this.tableLayoutPanel1.TabIndex = 0;
//
// chkShowPreviousFrameEvents
//
this.chkShowPreviousFrameEvents.AutoSize = true;
this.tableLayoutPanel1.SetColumnSpan(this.chkShowPreviousFrameEvents, 6);
this.chkShowPreviousFrameEvents.Location = new System.Drawing.Point(3, 148);
this.chkShowPreviousFrameEvents.Margin = new System.Windows.Forms.Padding(3, 10, 3, 3);
this.chkShowPreviousFrameEvents.Name = "chkShowPreviousFrameEvents";
this.chkShowPreviousFrameEvents.Size = new System.Drawing.Size(167, 17);
this.chkShowPreviousFrameEvents.TabIndex = 28;
this.chkShowPreviousFrameEvents.Text = "Show previous frame\'s events";
this.chkShowPreviousFrameEvents.UseVisualStyleBackColor = true;
this.chkShowPreviousFrameEvents.Click += new System.EventHandler(this.chkOption_Click);
//
// picNmi
//
this.picNmi.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
@ -427,6 +440,7 @@ namespace Mesen.GUI.Debugger
//
this.chkShowMarkedBreakpoints.AutoSize = true;
this.tableLayoutPanel1.SetColumnSpan(this.chkShowMarkedBreakpoints, 2);
this.chkShowMarkedBreakpoints.Enabled = false;
this.chkShowMarkedBreakpoints.Location = new System.Drawing.Point(3, 118);
this.chkShowMarkedBreakpoints.Name = "chkShowMarkedBreakpoints";
this.chkShowMarkedBreakpoints.Size = new System.Drawing.Size(121, 17);
@ -444,19 +458,6 @@ namespace Mesen.GUI.Debugger
this.picMarkedBreakpoints.TabIndex = 27;
this.picMarkedBreakpoints.TabStop = false;
//
// chkShowPreviousFrameEvents
//
this.chkShowPreviousFrameEvents.AutoSize = true;
this.tableLayoutPanel1.SetColumnSpan(this.chkShowPreviousFrameEvents, 6);
this.chkShowPreviousFrameEvents.Location = new System.Drawing.Point(3, 148);
this.chkShowPreviousFrameEvents.Margin = new System.Windows.Forms.Padding(3, 10, 3, 3);
this.chkShowPreviousFrameEvents.Name = "chkShowPreviousFrameEvents";
this.chkShowPreviousFrameEvents.Size = new System.Drawing.Size(167, 17);
this.chkShowPreviousFrameEvents.TabIndex = 28;
this.chkShowPreviousFrameEvents.Text = "Show previous frame\'s events";
this.chkShowPreviousFrameEvents.UseVisualStyleBackColor = true;
this.chkShowPreviousFrameEvents.Click += new System.EventHandler(this.chkOption_Click);
//
// ctrlEventViewerPpuView
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View file

@ -34,6 +34,7 @@ namespace Mesen.GUI.Debugger
InitShortcuts();
InitToolbar();
BreakpointManager.BreakpointsEnabled = true;
DebugApi.Step(10000);
}
@ -41,6 +42,7 @@ namespace Mesen.GUI.Debugger
{
base.OnClosing(e);
BreakpointManager.BreakpointsEnabled = false;
if(this._notifListener != null) {
this._notifListener.Dispose();
this._notifListener = null;
@ -184,6 +186,7 @@ namespace Mesen.GUI.Debugger
UpdateContinueAction();
ctrlStatus.UpdateStatus(state);
ctrlDisassemblyView.UpdateCode();
ctrlDisassemblyView.SetActiveAddress(activeAddress);
ctrlWatch.UpdateWatch(true);
ctrlCallstack.UpdateCallstack();