From d34f2ec142b9576d8b4390a8dedd3dea64d46c61 Mon Sep 17 00:00:00 2001 From: chaoticgd <43898262+chaoticgd@users.noreply.github.com> Date: Thu, 9 Jan 2025 00:47:49 +0000 Subject: [PATCH] Debugger: Add disassembler toggle to go to the PC address on pause --- pcsx2-qt/Debugger/CpuWidget.cpp | 2 +- pcsx2-qt/Debugger/DisassemblyWidget.cpp | 12 ++++++++++++ pcsx2-qt/Debugger/DisassemblyWidget.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pcsx2-qt/Debugger/CpuWidget.cpp b/pcsx2-qt/Debugger/CpuWidget.cpp index 0dab3711c9..7666e594f2 100644 --- a/pcsx2-qt/Debugger/CpuWidget.cpp +++ b/pcsx2-qt/Debugger/CpuWidget.cpp @@ -336,7 +336,7 @@ void CpuWidget::onVMPaused() } else { - m_ui.disassemblyWidget->gotoAddress(m_cpu.getPC(), false); + m_ui.disassemblyWidget->gotoProgramCounterOnPause(); } reloadCPUWidgets(); diff --git a/pcsx2-qt/Debugger/DisassemblyWidget.cpp b/pcsx2-qt/Debugger/DisassemblyWidget.cpp index 9e70214bb0..f915a11753 100644 --- a/pcsx2-qt/Debugger/DisassemblyWidget.cpp +++ b/pcsx2-qt/Debugger/DisassemblyWidget.cpp @@ -656,6 +656,12 @@ void DisassemblyWidget::customMenuRequested(QPoint pos) connect(action, &QAction::triggered, this, &DisassemblyWidget::contextGoToAddress); contextMenu->addAction(action = new QAction(tr("Go to in Memory View"), this)); connect(action, &QAction::triggered, this, [this]() { gotoInMemory(m_selectedAddressStart); }); + + contextMenu->addAction(action = new QAction(tr("Go to PC on Pause"), this)); + action->setCheckable(true); + action->setChecked(m_goToProgramCounterOnPause); + connect(action, &QAction::triggered, this, [this](bool value) { m_goToProgramCounterOnPause = value; }); + contextMenu->addSeparator(); contextMenu->addAction(action = new QAction(tr("Add Function"), this)); connect(action, &QAction::triggered, this, &DisassemblyWidget::contextAddFunction); @@ -822,6 +828,12 @@ void DisassemblyWidget::gotoAddressAndSetFocus(u32 address) gotoAddress(address, true); } +void DisassemblyWidget::gotoProgramCounterOnPause() +{ + if (m_goToProgramCounterOnPause) + gotoAddress(m_cpu->getPC(), false); +} + void DisassemblyWidget::gotoAddress(u32 address, bool should_set_focus) { const u32 destAddress = address & ~3; diff --git a/pcsx2-qt/Debugger/DisassemblyWidget.h b/pcsx2-qt/Debugger/DisassemblyWidget.h index d6ba1318c5..d42423af9a 100644 --- a/pcsx2-qt/Debugger/DisassemblyWidget.h +++ b/pcsx2-qt/Debugger/DisassemblyWidget.h @@ -59,6 +59,7 @@ public slots: void contextShowOpcode(); void gotoAddressAndSetFocus(u32 address); + void gotoProgramCounterOnPause(); void gotoAddress(u32 address, bool should_set_focus); void setDemangle(bool demangle) { m_demangleFunctions = demangle; }; @@ -82,6 +83,7 @@ private: bool m_demangleFunctions = true; bool m_showInstructionOpcode = true; + bool m_goToProgramCounterOnPause = true; DisassemblyManager m_disassemblyManager; inline QString DisassemblyStringFromAddress(u32 address, QFont font, u32 pc, bool selected);