Debugger: Fixed breakpoints not being set correctly from code window when in internal ram section (<= $1FFF)

This commit is contained in:
Sour 2019-01-03 14:51:25 -05:00
parent 86ff0cdf2b
commit a489716ad8
2 changed files with 10 additions and 11 deletions

View file

@ -82,10 +82,10 @@ namespace Mesen.GUI.Debugger
).FirstOrDefault(); ).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) { if(info.Address >= 0) {
Breakpoint breakpoint = BreakpointManager.GetMatchingBreakpoint(relativeAddress, info); Breakpoint breakpoint = BreakpointManager.GetMatchingBreakpoint(InteropEmu.DebugGetRelativeAddress((uint)info.Address, info.Type), info);
if(breakpoint != null) { if(breakpoint != null) {
if(toggleEnabled) { if(toggleEnabled) {
breakpoint.SetEnabled(!breakpoint.Enabled); breakpoint.SetEnabled(!breakpoint.Enabled);
@ -93,13 +93,13 @@ namespace Mesen.GUI.Debugger
BreakpointManager.RemoveBreakpoint(breakpoint); BreakpointManager.RemoveBreakpoint(breakpoint);
} }
} else { } else {
if(info.Address < 0 || info.Type == AddressType.InternalRam) { if(info.Type == AddressType.InternalRam) {
breakpoint = new Breakpoint() { breakpoint = new Breakpoint() {
MemoryType = DebugMemoryType.CpuMemory, MemoryType = DebugMemoryType.CpuMemory,
BreakOnExec = true, BreakOnExec = true,
BreakOnRead = true, BreakOnRead = true,
BreakOnWrite = true, BreakOnWrite = true,
Address = (UInt32)relativeAddress, Address = (UInt32)info.Address,
Enabled = true Enabled = true
}; };
} else { } else {

View file

@ -298,15 +298,14 @@ namespace Mesen.GUI.Debugger.Controls
public void ToggleBreakpoint(bool toggleEnabledFlag) public void ToggleBreakpoint(bool toggleEnabledFlag)
{ {
AddressTypeInfo info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine); AddressTypeInfo info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine);
if(info.Address >= 0) { if(info.Address < 0) {
BreakpointManager.ToggleBreakpoint(-1, info, toggleEnabledFlag);
} else {
//Current line has no address, try using the next line instead. //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) //(Used when trying to set a breakpoint on a row containing only a label)
info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine + 1); info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine + 1);
if(info.Address >= 0) {
BreakpointManager.ToggleBreakpoint(-1, info, toggleEnabledFlag);
} }
if(info.Address >= 0) {
BreakpointManager.ToggleBreakpoint(info, toggleEnabledFlag);
} }
} }