Debugger: Allow copying function names

Add the ability to copy a function name when you right click the first instruction of a function (the line where the function name displays).

Instructions inside the function that are not the first instruction will not show the copy option, partly because it's less clear what will be copied but also to not needlessly overpopulate the context menu.
This commit is contained in:
Dan McCarthy 2023-11-20 22:29:01 -06:00 committed by refractionpcsx2
parent 21b3464212
commit ae2860d03d
2 changed files with 11 additions and 0 deletions

View File

@ -234,6 +234,11 @@ void DisassemblyWidget::contextAddFunction()
}
}
void DisassemblyWidget::contextCopyFunctionName()
{
QGuiApplication::clipboard()->setText(QString::fromStdString(m_cpu->GetSymbolMap().GetLabelName(m_selectedAddressStart)));
}
void DisassemblyWidget::contextRemoveFunction()
{
u32 curFuncAddr = m_cpu->GetSymbolMap().GetFunctionStart(m_selectedAddressStart);
@ -665,6 +670,11 @@ void DisassemblyWidget::customMenuRequested(QPoint pos)
connect(action, &QAction::triggered, this, &DisassemblyWidget::contextCopyInstructionHex);
contextMenu->addAction(action = new QAction(tr("Copy Instruction Text"), this));
connect(action, &QAction::triggered, this, &DisassemblyWidget::contextCopyInstructionText);
if (m_selectedAddressStart == m_cpu->GetSymbolMap().GetFunctionStart(m_selectedAddressStart))
{
contextMenu->addAction(action = new QAction(tr("Copy Function Name"), this));
connect(action, &QAction::triggered, this, &DisassemblyWidget::contextCopyFunctionName);
}
contextMenu->addSeparator();
if (AddressCanRestore(m_selectedAddressStart, m_selectedAddressEnd))
{

View File

@ -54,6 +54,7 @@ public slots:
void contextCopyAddress();
void contextCopyInstructionHex();
void contextCopyInstructionText();
void contextCopyFunctionName();
void contextAssembleInstruction();
void contextNoopInstruction();
void contextRestoreInstruction();