Skip to content

Commit

Permalink
Debugger: Allow copying function names
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Daniel-McCarthy authored and refractionpcsx2 committed Nov 21, 2023
1 parent 21b3464 commit ae2860d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pcsx2-qt/Debugger/DisassemblyWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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))
{
Expand Down
1 change: 1 addition & 0 deletions pcsx2-qt/Debugger/DisassemblyWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public slots:
void contextCopyAddress();
void contextCopyInstructionHex();
void contextCopyInstructionText();
void contextCopyFunctionName();
void contextAssembleInstruction();
void contextNoopInstruction();
void contextRestoreInstruction();
Expand Down

0 comments on commit ae2860d

Please sign in to comment.