diff --git a/pcsx2-qt/Debugger/DisassemblyWidget.cpp b/pcsx2-qt/Debugger/DisassemblyWidget.cpp index 1fda733c9a..cc95e32391 100644 --- a/pcsx2-qt/Debugger/DisassemblyWidget.cpp +++ b/pcsx2-qt/Debugger/DisassemblyWidget.cpp @@ -83,6 +83,8 @@ void DisassemblyWidget::CreateCustomContextMenu() connect(action, &QAction::triggered, this, &DisassemblyWidget::contextRenameFunction); m_contextMenu->addAction(action = new QAction(tr("Remove Function"), this)); connect(action, &QAction::triggered, this, &DisassemblyWidget::contextRemoveFunction); + m_contextMenu->addAction(action = new QAction(tr("Stub (NOP) Function"), this)); + connect(action, &QAction::triggered, this, &DisassemblyWidget::contextStubFunction); } void DisassemblyWidget::contextCopyAddress() @@ -309,6 +311,23 @@ void DisassemblyWidget::contextRenameFunction() } } +void DisassemblyWidget::contextStubFunction() +{ + const u32 curFuncAddress = m_cpu->GetSymbolMap().GetFunctionStart(m_selectedAddressStart); + if (curFuncAddress != SymbolMap::INVALID_ADDRESS) + { + Host::RunOnCPUThread([this, curFuncAddress, cpu = m_cpu] { + cpu->write32(curFuncAddress, 0x03E00008); // jr $ra + cpu->write32(curFuncAddress + 4, 0x00000000); // nop + QtHost::RunOnUIThread([this] { VMUpdate(); }); + }); + } + else + { + QMessageBox::warning(this, tr("Stub Function Error"), tr("No function / symbol is currently selected.")); + } +} + void DisassemblyWidget::SetCpu(DebugInterface* cpu) { m_cpu = cpu; diff --git a/pcsx2-qt/Debugger/DisassemblyWidget.h b/pcsx2-qt/Debugger/DisassemblyWidget.h index 6ab73715be..89714847fa 100644 --- a/pcsx2-qt/Debugger/DisassemblyWidget.h +++ b/pcsx2-qt/Debugger/DisassemblyWidget.h @@ -64,6 +64,8 @@ public slots: void contextAddFunction(); void contextRenameFunction(); void contextRemoveFunction(); + void contextStubFunction(); + void gotoAddress(u32 address); signals: @@ -74,7 +76,7 @@ signals: private: Ui::DisassemblyWidget ui; - QMenu* m_contextMenu = 0x0; + QMenu* m_contextMenu = nullptr; void CreateCustomContextMenu(); DebugInterface* m_cpu;