Debugger: Implement stubbing (noping) functions

This commit is contained in:
Ty Lamontagne 2023-10-09 20:31:49 -04:00 committed by Connor McLaughlin
parent 55c9cb45ac
commit 4269f16bcd
2 changed files with 22 additions and 1 deletions

View File

@ -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;

View File

@ -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;