diff --git a/GUI.NET/Config/DebugInfo.cs b/GUI.NET/Config/DebugInfo.cs index 644c9545..65d87725 100644 --- a/GUI.NET/Config/DebugInfo.cs +++ b/GUI.NET/Config/DebugInfo.cs @@ -151,6 +151,7 @@ namespace Mesen.GUI.Config public bool BreakOnReset = true; public bool BreakOnUnofficialOpcodes = true; public bool BreakOnBrk = false; + public bool BreakOnDebuggerFocus = false; public TraceLoggerOptions TraceLoggerOptions; public bool TraceAutoRefresh = true; diff --git a/GUI.NET/Debugger/frmDebugger.Designer.cs b/GUI.NET/Debugger/frmDebugger.Designer.cs index 2787f3ee..f6faa6c9 100644 --- a/GUI.NET/Debugger/frmDebugger.Designer.cs +++ b/GUI.NET/Debugger/frmDebugger.Designer.cs @@ -100,6 +100,12 @@ namespace Mesen.GUI.Debugger this.mnuHighlightUnexecutedCode = new System.Windows.Forms.ToolStripMenuItem(); this.mnuShowEffectiveAddresses = new System.Windows.Forms.ToolStripMenuItem(); this.mnuShowOnlyDisassembledCode = new System.Windows.Forms.ToolStripMenuItem(); + this.breakOptionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuBreakOnDebuggerFocus = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuBreakOnReset = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuBreakOnOpen = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuBreakOnUnofficialOpcodes = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuBreakOnBrk = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem12 = new System.Windows.Forms.ToolStripSeparator(); this.mnuSplitView = new System.Windows.Forms.ToolStripMenuItem(); this.fontSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -107,10 +113,6 @@ namespace Mesen.GUI.Debugger this.mnuDecreaseFontSize = new System.Windows.Forms.ToolStripMenuItem(); this.mnuResetFontSize = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripSeparator(); - this.mnuBreakOnReset = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuBreakOnOpen = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuBreakOnUnofficialOpcodes = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuBreakOnBrk = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem11 = new System.Windows.Forms.ToolStripSeparator(); this.mnuShowCpuMemoryMapping = new System.Windows.Forms.ToolStripMenuItem(); this.mnuShowPpuMemoryMapping = new System.Windows.Forms.ToolStripMenuItem(); @@ -118,6 +120,7 @@ namespace Mesen.GUI.Debugger this.mnuShowBottomPanel = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator(); this.mnuPpuPartialDraw = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuRefreshWatchWhileRunning = new System.Windows.Forms.ToolStripMenuItem(); this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mnuAssembler = new System.Windows.Forms.ToolStripMenuItem(); this.mnuMemoryViewer = new System.Windows.Forms.ToolStripMenuItem(); @@ -140,7 +143,7 @@ namespace Mesen.GUI.Debugger this.lblChrAnalysisResult = new System.Windows.Forms.ToolStripStatusLabel(); this.ctrlPpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping(); this.ctrlCpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping(); - this.mnuRefreshWatchWhileRunning = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem15 = new System.Windows.Forms.ToolStripSeparator(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); this.splitContainer.Panel1.SuspendLayout(); this.splitContainer.Panel2.SuspendLayout(); @@ -209,7 +212,7 @@ namespace Mesen.GUI.Debugger this.ctrlSplitContainerTop.Panel2.Controls.Add(this.tlpFunctionLabelLists); this.ctrlSplitContainerTop.Panel2MinSize = 150; this.ctrlSplitContainerTop.Size = new System.Drawing.Size(1260, 390); - this.ctrlSplitContainerTop.SplitterDistance = 876; + this.ctrlSplitContainerTop.SplitterDistance = 873; this.ctrlSplitContainerTop.SplitterWidth = 7; this.ctrlSplitContainerTop.TabIndex = 3; this.ctrlSplitContainerTop.PanelCollapsed += new System.EventHandler(this.ctrlSplitContainerTop_PanelCollapsed); @@ -230,7 +233,7 @@ namespace Mesen.GUI.Debugger this.tlpTop.Name = "tlpTop"; this.tlpTop.RowCount = 1; this.tlpTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tlpTop.Size = new System.Drawing.Size(876, 390); + this.tlpTop.Size = new System.Drawing.Size(873, 390); this.tlpTop.TabIndex = 2; // // ctrlDebuggerCode @@ -239,7 +242,7 @@ namespace Mesen.GUI.Debugger this.ctrlDebuggerCode.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlDebuggerCode.Location = new System.Drawing.Point(3, 3); this.ctrlDebuggerCode.Name = "ctrlDebuggerCode"; - this.ctrlDebuggerCode.Size = new System.Drawing.Size(438, 384); + this.ctrlDebuggerCode.Size = new System.Drawing.Size(435, 384); this.ctrlDebuggerCode.TabIndex = 2; this.ctrlDebuggerCode.OnEditCode += new Mesen.GUI.Debugger.ctrlDebuggerCode.AssemblerEventHandler(this.ctrlDebuggerCode_OnEditCode); this.ctrlDebuggerCode.OnSetNextStatement += new Mesen.GUI.Debugger.ctrlDebuggerCode.AddressEventHandler(this.ctrlDebuggerCode_OnSetNextStatement); @@ -248,7 +251,7 @@ namespace Mesen.GUI.Debugger // ctrlConsoleStatus // this.ctrlConsoleStatus.Dock = System.Windows.Forms.DockStyle.Fill; - this.ctrlConsoleStatus.Location = new System.Drawing.Point(444, 0); + this.ctrlConsoleStatus.Location = new System.Drawing.Point(441, 0); this.ctrlConsoleStatus.Margin = new System.Windows.Forms.Padding(0); this.ctrlConsoleStatus.Name = "ctrlConsoleStatus"; this.ctrlConsoleStatus.Size = new System.Drawing.Size(432, 390); @@ -259,7 +262,7 @@ namespace Mesen.GUI.Debugger // this.ctrlDebuggerCodeSplit.Code = null; this.ctrlDebuggerCodeSplit.Dock = System.Windows.Forms.DockStyle.Fill; - this.ctrlDebuggerCodeSplit.Location = new System.Drawing.Point(447, 3); + this.ctrlDebuggerCodeSplit.Location = new System.Drawing.Point(444, 3); this.ctrlDebuggerCodeSplit.Name = "ctrlDebuggerCodeSplit"; this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 384); this.ctrlDebuggerCodeSplit.TabIndex = 4; @@ -281,7 +284,7 @@ namespace Mesen.GUI.Debugger this.tlpFunctionLabelLists.RowCount = 2; this.tlpFunctionLabelLists.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tlpFunctionLabelLists.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tlpFunctionLabelLists.Size = new System.Drawing.Size(377, 390); + this.tlpFunctionLabelLists.Size = new System.Drawing.Size(380, 390); this.tlpFunctionLabelLists.TabIndex = 5; // // grpLabels @@ -290,7 +293,7 @@ namespace Mesen.GUI.Debugger this.grpLabels.Dock = System.Windows.Forms.DockStyle.Fill; this.grpLabels.Location = new System.Drawing.Point(3, 198); this.grpLabels.Name = "grpLabels"; - this.grpLabels.Size = new System.Drawing.Size(371, 189); + this.grpLabels.Size = new System.Drawing.Size(374, 189); this.grpLabels.TabIndex = 6; this.grpLabels.TabStop = false; this.grpLabels.Text = "Labels"; @@ -300,7 +303,7 @@ namespace Mesen.GUI.Debugger this.ctrlLabelList.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlLabelList.Location = new System.Drawing.Point(3, 16); this.ctrlLabelList.Name = "ctrlLabelList"; - this.ctrlLabelList.Size = new System.Drawing.Size(365, 170); + this.ctrlLabelList.Size = new System.Drawing.Size(368, 170); this.ctrlLabelList.TabIndex = 0; this.ctrlLabelList.OnFindOccurrence += new System.EventHandler(this.ctrlLabelList_OnFindOccurrence); this.ctrlLabelList.OnLabelSelected += new System.EventHandler(this.ctrlLabelList_OnLabelSelected); @@ -311,7 +314,7 @@ namespace Mesen.GUI.Debugger this.grpFunctions.Dock = System.Windows.Forms.DockStyle.Fill; this.grpFunctions.Location = new System.Drawing.Point(3, 3); this.grpFunctions.Name = "grpFunctions"; - this.grpFunctions.Size = new System.Drawing.Size(371, 189); + this.grpFunctions.Size = new System.Drawing.Size(374, 189); this.grpFunctions.TabIndex = 5; this.grpFunctions.TabStop = false; this.grpFunctions.Text = "Functions"; @@ -321,7 +324,7 @@ namespace Mesen.GUI.Debugger this.ctrlFunctionList.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlFunctionList.Location = new System.Drawing.Point(3, 16); this.ctrlFunctionList.Name = "ctrlFunctionList"; - this.ctrlFunctionList.Size = new System.Drawing.Size(365, 170); + this.ctrlFunctionList.Size = new System.Drawing.Size(368, 170); this.ctrlFunctionList.TabIndex = 0; this.ctrlFunctionList.OnFindOccurrence += new System.EventHandler(this.ctrlFunctionList_OnFindOccurrence); this.ctrlFunctionList.OnFunctionSelected += new System.EventHandler(this.ctrlFunctionList_OnFunctionSelected); @@ -756,14 +759,11 @@ namespace Mesen.GUI.Debugger // this.mnuOptions.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.mnuDisassemblyOptions, + this.breakOptionsToolStripMenuItem, this.toolStripMenuItem12, this.mnuSplitView, this.fontSizeToolStripMenuItem, this.toolStripMenuItem5, - this.mnuBreakOnReset, - this.mnuBreakOnOpen, - this.mnuBreakOnUnofficialOpcodes, - this.mnuBreakOnBrk, this.toolStripMenuItem11, this.mnuShowCpuMemoryMapping, this.mnuShowPpuMemoryMapping, @@ -857,6 +857,59 @@ namespace Mesen.GUI.Debugger this.mnuShowOnlyDisassembledCode.Text = "Show Only Disassembled Code"; this.mnuShowOnlyDisassembledCode.Click += new System.EventHandler(this.mnuShowOnlyDisassembledCode_Click); // + // breakOptionsToolStripMenuItem + // + this.breakOptionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuBreakOnReset, + this.mnuBreakOnUnofficialOpcodes, + this.mnuBreakOnBrk, + this.toolStripMenuItem15, + this.mnuBreakOnOpen, + this.mnuBreakOnDebuggerFocus}); + this.breakOptionsToolStripMenuItem.Name = "breakOptionsToolStripMenuItem"; + this.breakOptionsToolStripMenuItem.Size = new System.Drawing.Size(259, 22); + this.breakOptionsToolStripMenuItem.Text = "Break Options"; + // + // mnuBreakOnDebuggerFocus + // + this.mnuBreakOnDebuggerFocus.CheckOnClick = true; + this.mnuBreakOnDebuggerFocus.Name = "mnuBreakOnDebuggerFocus"; + this.mnuBreakOnDebuggerFocus.Size = new System.Drawing.Size(243, 22); + this.mnuBreakOnDebuggerFocus.Text = "Break on debugger focus"; + this.mnuBreakOnDebuggerFocus.Click += new System.EventHandler(this.mnuBreakOnDebuggerFocus_Click); + // + // mnuBreakOnReset + // + this.mnuBreakOnReset.CheckOnClick = true; + this.mnuBreakOnReset.Name = "mnuBreakOnReset"; + this.mnuBreakOnReset.Size = new System.Drawing.Size(243, 22); + this.mnuBreakOnReset.Text = "Break on power/reset"; + this.mnuBreakOnReset.Click += new System.EventHandler(this.mnuBreakOnReset_Click); + // + // mnuBreakOnOpen + // + this.mnuBreakOnOpen.CheckOnClick = true; + this.mnuBreakOnOpen.Name = "mnuBreakOnOpen"; + this.mnuBreakOnOpen.Size = new System.Drawing.Size(243, 22); + this.mnuBreakOnOpen.Text = "Break when debugger is opened"; + this.mnuBreakOnOpen.Click += new System.EventHandler(this.mnuBreakOnOpen_Click); + // + // mnuBreakOnUnofficialOpcodes + // + this.mnuBreakOnUnofficialOpcodes.CheckOnClick = true; + this.mnuBreakOnUnofficialOpcodes.Name = "mnuBreakOnUnofficialOpcodes"; + this.mnuBreakOnUnofficialOpcodes.Size = new System.Drawing.Size(243, 22); + this.mnuBreakOnUnofficialOpcodes.Text = "Break on unofficial opcodes"; + this.mnuBreakOnUnofficialOpcodes.Click += new System.EventHandler(this.mnuBreakOnUnofficialOpcodes_Click); + // + // mnuBreakOnBrk + // + this.mnuBreakOnBrk.CheckOnClick = true; + this.mnuBreakOnBrk.Name = "mnuBreakOnBrk"; + this.mnuBreakOnBrk.Size = new System.Drawing.Size(243, 22); + this.mnuBreakOnBrk.Text = "Break on BRK"; + this.mnuBreakOnBrk.Click += new System.EventHandler(this.mnuBreakOnBrk_Click); + // // toolStripMenuItem12 // this.toolStripMenuItem12.Name = "toolStripMenuItem12"; @@ -914,38 +967,6 @@ namespace Mesen.GUI.Debugger this.toolStripMenuItem5.Name = "toolStripMenuItem5"; this.toolStripMenuItem5.Size = new System.Drawing.Size(256, 6); // - // mnuBreakOnReset - // - this.mnuBreakOnReset.CheckOnClick = true; - this.mnuBreakOnReset.Name = "mnuBreakOnReset"; - this.mnuBreakOnReset.Size = new System.Drawing.Size(259, 22); - this.mnuBreakOnReset.Text = "Break on power/reset"; - this.mnuBreakOnReset.Click += new System.EventHandler(this.mnuBreakOnReset_Click); - // - // mnuBreakOnOpen - // - this.mnuBreakOnOpen.CheckOnClick = true; - this.mnuBreakOnOpen.Name = "mnuBreakOnOpen"; - this.mnuBreakOnOpen.Size = new System.Drawing.Size(259, 22); - this.mnuBreakOnOpen.Text = "Break when debugger is opened"; - this.mnuBreakOnOpen.Click += new System.EventHandler(this.mnuBreakOnOpen_Click); - // - // mnuBreakOnUnofficialOpcodes - // - this.mnuBreakOnUnofficialOpcodes.CheckOnClick = true; - this.mnuBreakOnUnofficialOpcodes.Name = "mnuBreakOnUnofficialOpcodes"; - this.mnuBreakOnUnofficialOpcodes.Size = new System.Drawing.Size(259, 22); - this.mnuBreakOnUnofficialOpcodes.Text = "Break on unofficial opcodes"; - this.mnuBreakOnUnofficialOpcodes.Click += new System.EventHandler(this.mnuBreakOnUnofficialOpcodes_Click); - // - // mnuBreakOnBrk - // - this.mnuBreakOnBrk.CheckOnClick = true; - this.mnuBreakOnBrk.Name = "mnuBreakOnBrk"; - this.mnuBreakOnBrk.Size = new System.Drawing.Size(259, 22); - this.mnuBreakOnBrk.Text = "Break on BRK"; - this.mnuBreakOnBrk.Click += new System.EventHandler(this.mnuBreakOnBrk_Click); - // // toolStripMenuItem11 // this.toolStripMenuItem11.Name = "toolStripMenuItem11"; @@ -996,6 +1017,14 @@ namespace Mesen.GUI.Debugger this.mnuPpuPartialDraw.Text = "Draw Partial Frame"; this.mnuPpuPartialDraw.Click += new System.EventHandler(this.mnuPpuPartialDraw_Click); // + // mnuRefreshWatchWhileRunning + // + this.mnuRefreshWatchWhileRunning.CheckOnClick = true; + this.mnuRefreshWatchWhileRunning.Name = "mnuRefreshWatchWhileRunning"; + this.mnuRefreshWatchWhileRunning.Size = new System.Drawing.Size(259, 22); + this.mnuRefreshWatchWhileRunning.Text = "Refresh watch while running"; + this.mnuRefreshWatchWhileRunning.Click += new System.EventHandler(this.mnuRefreshWatchWhileRunning_Click); + // // toolsToolStripMenuItem // this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -1180,13 +1209,10 @@ namespace Mesen.GUI.Debugger this.ctrlCpuMemoryMapping.Text = "ctrlMemoryMapping1"; this.ctrlCpuMemoryMapping.Visible = false; // - // mnuRefreshWatchWhileRunning + // toolStripMenuItem15 // - this.mnuRefreshWatchWhileRunning.CheckOnClick = true; - this.mnuRefreshWatchWhileRunning.Name = "mnuRefreshWatchWhileRunning"; - this.mnuRefreshWatchWhileRunning.Size = new System.Drawing.Size(259, 22); - this.mnuRefreshWatchWhileRunning.Text = "Refresh watch while running"; - this.mnuRefreshWatchWhileRunning.Click += new System.EventHandler(this.mnuRefreshWatchWhileRunning_Click); + this.toolStripMenuItem15.Name = "toolStripMenuItem15"; + this.toolStripMenuItem15.Size = new System.Drawing.Size(240, 6); // // frmDebugger // @@ -1341,5 +1367,8 @@ namespace Mesen.GUI.Debugger private System.Windows.Forms.ToolStripMenuItem mnuAssembler; private System.Windows.Forms.ToolStripMenuItem mnuCode; private System.Windows.Forms.ToolStripMenuItem mnuRefreshWatchWhileRunning; + private System.Windows.Forms.ToolStripMenuItem breakOptionsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mnuBreakOnDebuggerFocus; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItem15; } } \ No newline at end of file diff --git a/GUI.NET/Debugger/frmDebugger.cs b/GUI.NET/Debugger/frmDebugger.cs index 9f554557..e3e7db9c 100644 --- a/GUI.NET/Debugger/frmDebugger.cs +++ b/GUI.NET/Debugger/frmDebugger.cs @@ -138,6 +138,14 @@ namespace Mesen.GUI.Debugger mnuSaveRom.Enabled = InteropEmu.GetRomInfo().Format == RomFormat.iNes; } + protected override void OnActivated(EventArgs e) + { + base.OnActivated(e); + if(ConfigManager.Config.DebugInfo.BreakOnDebuggerFocus) { + InteropEmu.DebugStep(1); + } + } + private void ctrlProfiler_OnFunctionSelected(object sender, EventArgs e) { int relativeAddress = InteropEmu.DebugGetRelativeAddress((UInt32)sender, AddressType.PrgRom); @@ -699,6 +707,12 @@ namespace Mesen.GUI.Debugger ConfigManager.Config.DebugInfo.BreakOnBrk = mnuBreakOnBrk.Checked; ConfigManager.ApplyChanges(); } + + private void mnuBreakOnDebuggerFocus_Click(object sender, EventArgs e) + { + ConfigManager.Config.DebugInfo.BreakOnDebuggerFocus = mnuBreakOnDebuggerFocus.Checked; + ConfigManager.ApplyChanges(); + } private void mnuRefreshWatchWhileRunning_Click(object sender, EventArgs e) {