From 8427a9db7e455ef4202f89231f5f2f2dad363a9d Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 6 Feb 2015 00:41:50 +0000 Subject: [PATCH] Debugger - add context menu item on Disassembler "Add Breakpoint" that will add an execute breakpoint on the selected address --- .../tools/Debugger/BreakpointControl.cs | 9 ++++ .../Debugger/GenericDebugger.Designer.cs | 44 ++++++++++++++----- .../Debugger/GenericDebugger.Disassembler.cs | 16 +++++++ .../tools/Debugger/GenericDebugger.resx | 3 ++ 4 files changed, 61 insertions(+), 11 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs b/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs index 08f052fb6c..aa75bef3f2 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs @@ -142,6 +142,15 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger UpdateStatsLabel(); } + public void AddBreakpoint(uint address, MemoryCallbackType type) + { + Breakpoints.Add(Core, address, type); + + BreakpointView.ItemCount = Breakpoints.Count; + UpdateBreakpointRemoveButton(); + UpdateStatsLabel(); + } + private void AddBreakpointButton_Click(object sender, EventArgs e) { var b = new AddBreakpointDialog diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Designer.cs b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Designer.cs index 5b988d203a..8ab99a6486 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Designer.cs @@ -37,6 +37,8 @@ this.StepIntoMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.StepOverMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.StepOutMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.RefreshMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.RegistersGroupBox = new System.Windows.Forms.GroupBox(); this.RegisterPanel = new BizHawk.Client.EmuHawk.RegisterBoxControl(); this.BreakpointsGroupBox = new System.Windows.Forms.GroupBox(); @@ -54,12 +56,13 @@ this.SeekToBtn = new System.Windows.Forms.Button(); this.SeekToBox = new BizHawk.Client.EmuHawk.HexTextBox(); this.CancelSeekBtn = new System.Windows.Forms.Button(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.RefreshMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.DisassemblerContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); + this.AddBreakpointContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.RegistersGroupBox.SuspendLayout(); this.BreakpointsGroupBox.SuspendLayout(); this.DisassemblerBox.SuspendLayout(); + this.DisassemblerContextMenu.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 @@ -130,6 +133,19 @@ this.StepOutMenuItem.Text = "Step Ou&t"; this.StepOutMenuItem.Click += new System.EventHandler(this.StepOutMenuItem_Click); // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(174, 6); + // + // RefreshMenuItem + // + this.RefreshMenuItem.Name = "RefreshMenuItem"; + this.RefreshMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F5; + this.RefreshMenuItem.Size = new System.Drawing.Size(177, 22); + this.RefreshMenuItem.Text = "Refresh"; + this.RefreshMenuItem.Click += new System.EventHandler(this.RefreshMenuItem_Click); + // // RegistersGroupBox // this.RegistersGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -225,6 +241,7 @@ this.DisassemblerView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.Address, this.Instruction}); + this.DisassemblerView.ContextMenuStrip = this.DisassemblerContextMenu; this.DisassemblerView.FullRowSelect = true; this.DisassemblerView.GridLines = true; this.DisassemblerView.ItemCount = 0; @@ -319,18 +336,20 @@ this.CancelSeekBtn.UseVisualStyleBackColor = true; this.CancelSeekBtn.Click += new System.EventHandler(this.CancelSeekBtn_Click); // - // toolStripSeparator1 + // DisassemblerContextMenu // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(174, 6); + this.DisassemblerContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.AddBreakpointContextMenuItem}); + this.DisassemblerContextMenu.Name = "DisassemblerContextMenu"; + this.DisassemblerContextMenu.Size = new System.Drawing.Size(157, 26); + this.DisassemblerContextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.DisassemblerContextMenu_Opening); // - // RefreshMenuItem + // AddBreakpointContextMenuItem // - this.RefreshMenuItem.Name = "RefreshMenuItem"; - this.RefreshMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F5; - this.RefreshMenuItem.Size = new System.Drawing.Size(177, 22); - this.RefreshMenuItem.Text = "Refresh"; - this.RefreshMenuItem.Click += new System.EventHandler(this.RefreshMenuItem_Click); + this.AddBreakpointContextMenuItem.Name = "AddBreakpointContextMenuItem"; + this.AddBreakpointContextMenuItem.Size = new System.Drawing.Size(156, 22); + this.AddBreakpointContextMenuItem.Text = "Add Breakpoint"; + this.AddBreakpointContextMenuItem.Click += new System.EventHandler(this.AddBreakpointContextMenuItem_Click); // // GenericDebugger // @@ -360,6 +379,7 @@ this.BreakpointsGroupBox.ResumeLayout(false); this.DisassemblerBox.ResumeLayout(false); this.DisassemblerBox.PerformLayout(); + this.DisassemblerContextMenu.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -393,5 +413,7 @@ private System.Windows.Forms.Button ToPCBtn; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripMenuItem RefreshMenuItem; + private System.Windows.Forms.ContextMenuStrip DisassemblerContextMenu; + private System.Windows.Forms.ToolStripMenuItem AddBreakpointContextMenuItem; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs index c3f5b35eea..83b0450938 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs @@ -194,5 +194,21 @@ namespace BizHawk.Client.EmuHawk { FullUpdate(); } + + private void DisassemblerContextMenu_Opening(object sender, EventArgs e) + { + AddBreakpointContextMenuItem.Enabled = DisassemblerView.SelectedIndices.Count > 0; + } + + private void AddBreakpointContextMenuItem_Click(object sender, EventArgs e) + { + var indices = DisassemblerView.SelectedIndices; + + if (indices.Count > 0) + { + var line = DisassemblyLines[indices[0]]; + BreakPointControl1.AddBreakpoint(line.Address, Emulation.Common.MemoryCallbackType.Execute); + } + } } } diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.resx b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.resx index 8bc76d63e4..ba660d4792 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.resx +++ b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.resx @@ -120,6 +120,9 @@ 17, 17 + + 229, 17 + 132, 17