diff --git a/src/core/cpu_core.cpp b/src/core/cpu_core.cpp index 4c0152bc6..21eff6293 100644 --- a/src/core/cpu_core.cpp +++ b/src/core/cpu_core.cpp @@ -2184,6 +2184,27 @@ bool CPU::AddBreakpointWithCallback(BreakpointType type, VirtualMemoryAddress ad return true; } +bool CPU::SetBreakpointEnabled(BreakpointType type, VirtualMemoryAddress address, bool enabled) +{ + BreakpointList& bplist = GetBreakpointList(type); + auto it = + std::find_if(bplist.begin(), bplist.end(), [address](const Breakpoint& bp) { return bp.address == address; }); + if (it == bplist.end()) + return false; + + Host::ReportDebuggerMessage(fmt::format("{} {} breakpoint at 0x{:08X}.", enabled ? "Enabled" : "Disabled", + GetBreakpointTypeName(type), address)); + it->enabled = enabled; + + if (UpdateDebugDispatcherFlag()) + System::InterruptExecution(); + + if (address == s_last_breakpoint_check_pc && !enabled) + s_last_breakpoint_check_pc = INVALID_BREAKPOINT_PC; + + return true; +} + bool CPU::RemoveBreakpoint(BreakpointType type, VirtualMemoryAddress address) { BreakpointList& bplist = GetBreakpointList(type); @@ -2323,8 +2344,8 @@ ALWAYS_INLINE_RELEASE bool CPU::CheckBreakpointList(BreakpointType type, Virtual } else { - Host::ReportDebuggerMessage( - fmt::format("Hit {} breakpoint {} at 0x{:08X}, Hit Count {}.", GetBreakpointTypeName(type), bp.number, address, bp.hit_count)); + Host::ReportDebuggerMessage(fmt::format("Hit {} breakpoint {} at 0x{:08X}, Hit Count {}.", + GetBreakpointTypeName(type), bp.number, address, bp.hit_count)); i++; } diff --git a/src/core/cpu_core.h b/src/core/cpu_core.h index ae36497da..566a30944 100644 --- a/src/core/cpu_core.h +++ b/src/core/cpu_core.h @@ -232,6 +232,7 @@ bool HasBreakpointAtAddress(BreakpointType type, VirtualMemoryAddress address); BreakpointList CopyBreakpointList(bool include_auto_clear = false, bool include_callbacks = false); bool AddBreakpoint(BreakpointType type, VirtualMemoryAddress address, bool auto_clear = false, bool enabled = true); bool AddBreakpointWithCallback(BreakpointType type, VirtualMemoryAddress address, BreakpointCallback callback); +bool SetBreakpointEnabled(BreakpointType type, VirtualMemoryAddress address, bool enabled); bool RemoveBreakpoint(BreakpointType type, VirtualMemoryAddress address); void ClearBreakpoints(); bool AddStepOverBreakpoint();