From a489716ad8166927643a0cfa642883707510f753 Mon Sep 17 00:00:00 2001 From: Sour Date: Thu, 3 Jan 2019 14:51:25 -0500 Subject: [PATCH] Debugger: Fixed breakpoints not being set correctly from code window when in internal ram section (<= $1FFF) --- GUI.NET/Debugger/BreakpointManager.cs | 10 +++++----- GUI.NET/Debugger/Controls/CodeViewerActions.cs | 11 +++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/GUI.NET/Debugger/BreakpointManager.cs b/GUI.NET/Debugger/BreakpointManager.cs index 6e96ee42..ca9b8d12 100644 --- a/GUI.NET/Debugger/BreakpointManager.cs +++ b/GUI.NET/Debugger/BreakpointManager.cs @@ -82,10 +82,10 @@ namespace Mesen.GUI.Debugger ).FirstOrDefault(); } - public static void ToggleBreakpoint(int relativeAddress, AddressTypeInfo info, bool toggleEnabled) + public static void ToggleBreakpoint(AddressTypeInfo info, bool toggleEnabled) { - if(relativeAddress >= 0 || info.Address >= 0) { - Breakpoint breakpoint = BreakpointManager.GetMatchingBreakpoint(relativeAddress, info); + if(info.Address >= 0) { + Breakpoint breakpoint = BreakpointManager.GetMatchingBreakpoint(InteropEmu.DebugGetRelativeAddress((uint)info.Address, info.Type), info); if(breakpoint != null) { if(toggleEnabled) { breakpoint.SetEnabled(!breakpoint.Enabled); @@ -93,13 +93,13 @@ namespace Mesen.GUI.Debugger BreakpointManager.RemoveBreakpoint(breakpoint); } } else { - if(info.Address < 0 || info.Type == AddressType.InternalRam) { + if(info.Type == AddressType.InternalRam) { breakpoint = new Breakpoint() { MemoryType = DebugMemoryType.CpuMemory, BreakOnExec = true, BreakOnRead = true, BreakOnWrite = true, - Address = (UInt32)relativeAddress, + Address = (UInt32)info.Address, Enabled = true }; } else { diff --git a/GUI.NET/Debugger/Controls/CodeViewerActions.cs b/GUI.NET/Debugger/Controls/CodeViewerActions.cs index 35fb965c..759f52bc 100644 --- a/GUI.NET/Debugger/Controls/CodeViewerActions.cs +++ b/GUI.NET/Debugger/Controls/CodeViewerActions.cs @@ -298,15 +298,14 @@ namespace Mesen.GUI.Debugger.Controls public void ToggleBreakpoint(bool toggleEnabledFlag) { AddressTypeInfo info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine); - if(info.Address >= 0) { - BreakpointManager.ToggleBreakpoint(-1, info, toggleEnabledFlag); - } else { + if(info.Address < 0) { //Current line has no address, try using the next line instead. //(Used when trying to set a breakpoint on a row containing only a label) info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine + 1); - if(info.Address >= 0) { - BreakpointManager.ToggleBreakpoint(-1, info, toggleEnabledFlag); - } + } + + if(info.Address >= 0) { + BreakpointManager.ToggleBreakpoint(info, toggleEnabledFlag); } }