Qt: Mutate breakpoints on CPU thread

This commit is contained in:
Stenzek 2024-02-10 23:18:49 +09:00
parent 9888d8c8be
commit 679046ceae
No known key found for this signature in database
2 changed files with 25 additions and 15 deletions

View File

@ -553,26 +553,30 @@ void DebuggerWindow::setMemoryViewRegion(Bus::MemoryRegion region)
void DebuggerWindow::toggleBreakpoint(VirtualMemoryAddress address)
{
const bool new_bp_state = !CPU::HasBreakpointAtAddress(address);
if (new_bp_state)
{
if (!CPU::AddBreakpoint(address, false))
return;
}
else
{
if (!CPU::RemoveBreakpoint(address))
return;
}
Host::RunOnCPUThread([this, address]() {
const bool new_bp_state = !CPU::HasBreakpointAtAddress(address);
if (new_bp_state)
{
if (!CPU::AddBreakpoint(address, false))
return;
}
else
{
if (!CPU::RemoveBreakpoint(address))
return;
}
m_code_model->setBreakpointState(address, new_bp_state);
refreshBreakpointList();
QtHost::RunOnUIThread([this, address, new_bp_state, bps = CPU::GetBreakpointList()]() {
m_code_model->setBreakpointState(address, new_bp_state);
refreshBreakpointList(bps);
});
});
}
void DebuggerWindow::clearBreakpoints()
{
m_code_model->clearBreakpoints();
CPU::ClearBreakpoints();
Host::RunOnCPUThread(&CPU::ClearBreakpoints);
}
std::optional<VirtualMemoryAddress> DebuggerWindow::getSelectedCodeAddress()
@ -614,11 +618,15 @@ bool DebuggerWindow::scrollToMemoryAddress(VirtualMemoryAddress address)
}
void DebuggerWindow::refreshBreakpointList()
{
refreshBreakpointList(CPU::GetBreakpointList());
}
void DebuggerWindow::refreshBreakpointList(const CPU::BreakpointList& bps)
{
while (m_ui.breakpointsWidget->topLevelItemCount() > 0)
delete m_ui.breakpointsWidget->takeTopLevelItem(0);
const CPU::BreakpointList bps(CPU::GetBreakpointList());
for (const CPU::Breakpoint& bp : bps)
{
QTreeWidgetItem* item = new QTreeWidgetItem();

View File

@ -5,6 +5,7 @@
#include "ui_debuggerwindow.h"
#include "core/cpu_core.h"
#include "core/types.h"
#include <QtWidgets/QMainWindow>
@ -76,6 +77,7 @@ private:
void scrollToCodeAddress(VirtualMemoryAddress address);
bool scrollToMemoryAddress(VirtualMemoryAddress address);
void refreshBreakpointList();
void refreshBreakpointList(const CPU::BreakpointList& bps);
Ui::DebuggerWindow m_ui;