From 23843583bf2fcc349bef18b37e1a8539be3db17d Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Tue, 28 Mar 2023 20:26:52 +0200 Subject: PowerPC: Refactor to class, move to System. --- .../Core/DolphinQt/Debugger/BreakpointWidget.cpp | 54 +++++++++++++--------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp') diff --git a/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp b/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp index 019494491b..c21ae91e6f 100644 --- a/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp @@ -18,6 +18,7 @@ #include "Core/PowerPC/Expression.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" +#include "Core/System.h" #include "DolphinQt/Debugger/BreakpointDialog.h" #include "DolphinQt/Debugger/MemoryWidget.h" @@ -34,7 +35,8 @@ enum CustomRole }; } -BreakpointWidget::BreakpointWidget(QWidget* parent) : QDockWidget(parent) +BreakpointWidget::BreakpointWidget(QWidget* parent) + : QDockWidget(parent), m_system(Core::System::GetInstance()) { setWindowTitle(tr("Breakpoints")); setObjectName(QStringLiteral("breakpoints")); @@ -172,8 +174,12 @@ void BreakpointWidget::Update() return item; }; + auto& power_pc = m_system.GetPowerPC(); + auto& breakpoints = power_pc.GetBreakPoints(); + auto& memchecks = power_pc.GetMemChecks(); + // Breakpoints - for (const auto& bp : PowerPC::breakpoints.GetBreakPoints()) + for (const auto& bp : breakpoints.GetBreakPoints()) { m_table->setRowCount(i + 1); @@ -215,7 +221,7 @@ void BreakpointWidget::Update() } // Memory Breakpoints - for (const auto& mbp : PowerPC::memchecks.GetMemChecks()) + for (const auto& mbp : memchecks.GetMemChecks()) { m_table->setRowCount(i + 1); auto* active = @@ -279,11 +285,11 @@ void BreakpointWidget::OnDelete() if (is_memcheck) { const QSignalBlocker blocker(Settings::Instance()); - PowerPC::memchecks.Remove(address); + m_system.GetPowerPC().GetMemChecks().Remove(address); } else { - PowerPC::breakpoints.Remove(address); + m_system.GetPowerPC().GetBreakPoints().Remove(address); } emit BreakpointsChanged(); @@ -292,10 +298,10 @@ void BreakpointWidget::OnDelete() void BreakpointWidget::OnClear() { - PowerPC::debug_interface.ClearAllBreakpoints(); + m_system.GetPowerPC().GetDebugInterface().ClearAllBreakpoints(); { const QSignalBlocker blocker(Settings::Instance()); - PowerPC::debug_interface.ClearAllMemChecks(); + m_system.GetPowerPC().GetDebugInterface().ClearAllMemChecks(); } m_table->setRowCount(0); @@ -314,12 +320,14 @@ void BreakpointWidget::OnEditBreakpoint(u32 address, bool is_instruction_bp) { if (is_instruction_bp) { - auto* dialog = new BreakpointDialog(this, PowerPC::breakpoints.GetBreakpoint(address)); + auto* dialog = + new BreakpointDialog(this, m_system.GetPowerPC().GetBreakPoints().GetBreakpoint(address)); dialog->exec(); } else { - auto* dialog = new BreakpointDialog(this, PowerPC::memchecks.GetMemCheck(address)); + auto* dialog = + new BreakpointDialog(this, m_system.GetPowerPC().GetMemChecks().GetMemCheck(address)); dialog->exec(); } @@ -339,16 +347,18 @@ void BreakpointWidget::OnLoad() BreakPoints::TBreakPointsStr new_bps; if (ini.GetLines("BreakPoints", &new_bps, false)) { - PowerPC::breakpoints.Clear(); - PowerPC::breakpoints.AddFromStrings(new_bps); + auto& breakpoints = m_system.GetPowerPC().GetBreakPoints(); + breakpoints.Clear(); + breakpoints.AddFromStrings(new_bps); } MemChecks::TMemChecksStr new_mcs; if (ini.GetLines("MemoryBreakPoints", &new_mcs, false)) { - PowerPC::memchecks.Clear(); + auto& memchecks = m_system.GetPowerPC().GetMemChecks(); + memchecks.Clear(); const QSignalBlocker blocker(Settings::Instance()); - PowerPC::memchecks.AddFromStrings(new_mcs); + memchecks.AddFromStrings(new_mcs); } emit BreakpointsChanged(); @@ -360,8 +370,8 @@ void BreakpointWidget::OnSave() IniFile ini; ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetGameID() + ".ini", false); - ini.SetLines("BreakPoints", PowerPC::breakpoints.GetStrings()); - ini.SetLines("MemoryBreakPoints", PowerPC::memchecks.GetStrings()); + ini.SetLines("BreakPoints", m_system.GetPowerPC().GetBreakPoints().GetStrings()); + ini.SetLines("MemoryBreakPoints", m_system.GetPowerPC().GetMemChecks().GetStrings()); ini.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetGameID() + ".ini"); } @@ -381,7 +391,7 @@ void BreakpointWidget::OnContextMenu() if (!is_memory_breakpoint) { - const auto& inst_breakpoints = PowerPC::breakpoints.GetBreakPoints(); + const auto& inst_breakpoints = m_system.GetPowerPC().GetBreakPoints().GetBreakPoints(); const auto bp_iter = std::find_if(inst_breakpoints.begin(), inst_breakpoints.end(), [bp_address](const auto& bp) { return bp.address == bp_address; }); @@ -390,7 +400,7 @@ void BreakpointWidget::OnContextMenu() menu->addAction(tr("Show in Code"), [this, bp_address] { emit ShowCode(bp_address); }); menu->addAction(bp_iter->is_enabled ? tr("Disable") : tr("Enable"), [this, &bp_address]() { - PowerPC::breakpoints.ToggleBreakPoint(bp_address); + m_system.GetPowerPC().GetBreakPoints().ToggleBreakPoint(bp_address); emit BreakpointsChanged(); Update(); @@ -398,7 +408,7 @@ void BreakpointWidget::OnContextMenu() } else { - const auto& memory_breakpoints = PowerPC::memchecks.GetMemChecks(); + const auto& memory_breakpoints = m_system.GetPowerPC().GetMemChecks().GetMemChecks(); const auto mb_iter = std::find_if(memory_breakpoints.begin(), memory_breakpoints.end(), [bp_address](const auto& bp) { return bp.start_address == bp_address; }); @@ -407,7 +417,7 @@ void BreakpointWidget::OnContextMenu() menu->addAction(tr("Show in Memory"), [this, bp_address] { emit ShowMemory(bp_address); }); menu->addAction(mb_iter->is_enabled ? tr("Disable") : tr("Enable"), [this, &bp_address]() { - PowerPC::memchecks.ToggleBreakPoint(bp_address); + m_system.GetPowerPC().GetMemChecks().ToggleBreakPoint(bp_address); emit BreakpointsChanged(); Update(); @@ -428,7 +438,7 @@ void BreakpointWidget::AddBP(u32 addr) void BreakpointWidget::AddBP(u32 addr, bool temp, bool break_on_hit, bool log_on_hit, const QString& condition) { - PowerPC::breakpoints.Add( + m_system.GetPowerPC().GetBreakPoints().Add( addr, temp, break_on_hit, log_on_hit, !condition.isEmpty() ? Expression::TryParse(condition.toUtf8().constData()) : std::nullopt); @@ -452,7 +462,7 @@ void BreakpointWidget::AddAddressMBP(u32 addr, bool on_read, bool on_write, bool !condition.isEmpty() ? Expression::TryParse(condition.toUtf8().constData()) : std::nullopt; { const QSignalBlocker blocker(Settings::Instance()); - PowerPC::memchecks.Add(std::move(check)); + m_system.GetPowerPC().GetMemChecks().Add(std::move(check)); } emit BreakpointsChanged(); @@ -475,7 +485,7 @@ void BreakpointWidget::AddRangedMBP(u32 from, u32 to, bool on_read, bool on_writ !condition.isEmpty() ? Expression::TryParse(condition.toUtf8().constData()) : std::nullopt; { const QSignalBlocker blocker(Settings::Instance()); - PowerPC::memchecks.Add(std::move(check)); + m_system.GetPowerPC().GetMemChecks().Add(std::move(check)); } emit BreakpointsChanged(); -- cgit v1.2.3