From 037de1ce929b9c785f11e9f595ededd1497bfe41 Mon Sep 17 00:00:00 2001 From: Martino Fontana Date: Sat, 15 Jun 2024 11:23:50 +0200 Subject: [PATCH] Debugger: fix Run to Here Now it actually does what it says on the name, instead of creating a breapoint and doing nothing else (not even updating the widget). Also, it now can't be selected if emulation isn't running. Closes https://bugs.dolphin-emu.org/issues/13532 --- Source/Core/Core/Debugger/DebugInterface.h | 2 +- Source/Core/Core/Debugger/PPCDebugInterface.cpp | 6 +++++- Source/Core/Core/Debugger/PPCDebugInterface.h | 2 +- Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp | 10 ++++------ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Source/Core/Core/Debugger/DebugInterface.h b/Source/Core/Core/Debugger/DebugInterface.h index 67ff54fcdb..cc07d06d3b 100644 --- a/Source/Core/Core/Debugger/DebugInterface.h +++ b/Source/Core/Core/Debugger/DebugInterface.h @@ -99,7 +99,7 @@ public: virtual u32 GetPC() const { return 0; } virtual void SetPC(u32 /*address*/) {} virtual void Step() {} - virtual void RunToBreakpoint() {} + virtual void RunTo(u32 /*address*/) {} virtual u32 GetColor(const CPUThreadGuard* /*guard*/, u32 /*address*/) const { return 0xFFFFFFFF; diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Debugger/PPCDebugInterface.cpp index 3819f62493..72cfd05b2c 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.cpp +++ b/Source/Core/Core/Debugger/PPCDebugInterface.cpp @@ -20,6 +20,7 @@ #include "Core/Config/MainSettings.h" #include "Core/Core.h" #include "Core/Debugger/OSThread.h" +#include "Core/HW/CPU.h" #include "Core/HW/DSP.h" #include "Core/PatchEngine.h" #include "Core/PowerPC/MMU.h" @@ -502,8 +503,11 @@ void PPCDebugInterface::SetPC(u32 address) m_system.GetPPCState().pc = address; } -void PPCDebugInterface::RunToBreakpoint() +void PPCDebugInterface::RunTo(u32 address) { + auto& breakpoints = m_system.GetPowerPC().GetBreakPoints(); + breakpoints.Add(address, true); + m_system.GetCPU().SetStepping(false); } std::shared_ptr PPCDebugInterface::NetworkLogger() diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.h b/Source/Core/Core/Debugger/PPCDebugInterface.h index 5f8f8b04de..797f2d5254 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.h +++ b/Source/Core/Core/Debugger/PPCDebugInterface.h @@ -100,7 +100,7 @@ public: u32 GetPC() const override; void SetPC(u32 address) override; void Step() override {} - void RunToBreakpoint() override; + void RunTo(u32 address) override; u32 GetColor(const Core::CPUThreadGuard* guard, u32 address) const override; std::string_view GetDescription(u32 address) const override; diff --git a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp index e2df3420a6..36e7ade321 100644 --- a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp @@ -594,7 +594,7 @@ void CodeViewWidget::OnContextMenu() menu->addAction(tr("Set symbol &end address"), this, &CodeViewWidget::OnSetSymbolEndAddress); menu->addSeparator(); - menu->addAction(tr("Run &To Here"), this, &CodeViewWidget::OnRunToHere); + auto* run_to_action = menu->addAction(tr("Run &To Here"), this, &CodeViewWidget::OnRunToHere); auto* function_action = menu->addAction(tr("&Add function"), this, &CodeViewWidget::OnAddFunction); auto* ppc_action = menu->addAction(tr("PPC vs Host"), this, &CodeViewWidget::OnPPCComparison); @@ -645,8 +645,8 @@ void CodeViewWidget::OnContextMenu() follow_branch_action->setEnabled(follow_branch_enabled); for (auto* action : - {copy_address_action, copy_line_action, copy_hex_action, function_action, ppc_action, - insert_blr_action, insert_nop_action, replace_action, assemble_action}) + {copy_address_action, copy_line_action, copy_hex_action, function_action, run_to_action, + ppc_action, insert_blr_action, insert_nop_action, replace_action, assemble_action}) { action->setEnabled(running); } @@ -869,9 +869,7 @@ void CodeViewWidget::OnRunToHere() { const u32 addr = GetContextAddress(); - m_system.GetPowerPC().GetDebugInterface().AddBreakpoint(addr); - m_system.GetPowerPC().GetDebugInterface().RunToBreakpoint(); - Update(); + m_system.GetPowerPC().GetDebugInterface().RunTo(addr); } void CodeViewWidget::OnPPCComparison()