CPU: Add SetBreakpointEnabled()

This commit is contained in:
Stenzek 2024-09-15 17:15:38 +10:00
parent c640b664da
commit 3c093c72fd
No known key found for this signature in database
2 changed files with 24 additions and 2 deletions

View File

@ -2184,6 +2184,27 @@ bool CPU::AddBreakpointWithCallback(BreakpointType type, VirtualMemoryAddress ad
return true; 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) bool CPU::RemoveBreakpoint(BreakpointType type, VirtualMemoryAddress address)
{ {
BreakpointList& bplist = GetBreakpointList(type); BreakpointList& bplist = GetBreakpointList(type);
@ -2323,8 +2344,8 @@ ALWAYS_INLINE_RELEASE bool CPU::CheckBreakpointList(BreakpointType type, Virtual
} }
else else
{ {
Host::ReportDebuggerMessage( Host::ReportDebuggerMessage(fmt::format("Hit {} breakpoint {} at 0x{:08X}, Hit Count {}.",
fmt::format("Hit {} breakpoint {} at 0x{:08X}, Hit Count {}.", GetBreakpointTypeName(type), bp.number, address, bp.hit_count)); GetBreakpointTypeName(type), bp.number, address, bp.hit_count));
i++; i++;
} }

View File

@ -232,6 +232,7 @@ bool HasBreakpointAtAddress(BreakpointType type, VirtualMemoryAddress address);
BreakpointList CopyBreakpointList(bool include_auto_clear = false, bool include_callbacks = false); 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 AddBreakpoint(BreakpointType type, VirtualMemoryAddress address, bool auto_clear = false, bool enabled = true);
bool AddBreakpointWithCallback(BreakpointType type, VirtualMemoryAddress address, BreakpointCallback callback); bool AddBreakpointWithCallback(BreakpointType type, VirtualMemoryAddress address, BreakpointCallback callback);
bool SetBreakpointEnabled(BreakpointType type, VirtualMemoryAddress address, bool enabled);
bool RemoveBreakpoint(BreakpointType type, VirtualMemoryAddress address); bool RemoveBreakpoint(BreakpointType type, VirtualMemoryAddress address);
void ClearBreakpoints(); void ClearBreakpoints();
bool AddStepOverBreakpoint(); bool AddStepOverBreakpoint();