diff --git a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp index 696ff60d47..566b58e241 100644 --- a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp @@ -579,7 +579,8 @@ void CodeViewWidget::OnContextMenu() auto* copy_line_action = menu->addAction(tr("Copy Code &Line"), this, &CodeViewWidget::OnCopyCode); auto* copy_hex_action = menu->addAction(tr("Copy &Hex"), this, &CodeViewWidget::OnCopyHex); - + auto* copy_whole_line_action = + menu->addAction(tr("Copy &Whole Line"), this, &CodeViewWidget::OnCopyWholeLine); menu->addAction(tr("Show in &Memory"), this, &CodeViewWidget::OnShowInMemory); auto* show_target_memory = menu->addAction(tr("Show Target in Memor&y"), this, &CodeViewWidget::OnShowTargetInMemory); @@ -646,7 +647,7 @@ void CodeViewWidget::OnContextMenu() follow_branch_action->setEnabled(follow_branch_enabled); for (auto* action : - {copy_address_action, copy_line_action, copy_hex_action, function_action, run_to_action, + {copy_address_action, copy_line_action, copy_whole_line_action, copy_hex_action, function_action, run_to_action, ppc_action, insert_blr_action, insert_nop_action, replace_action, assemble_action}) { action->setEnabled(running); @@ -826,6 +827,35 @@ void CodeViewWidget::OnCopyCode() QApplication::clipboard()->setText(QString::fromStdString(text)); } +void CodeViewWidget::OnCopyWholeLine() +{ + const u32 addr = GetContextAddress(); + + const QString textAddress = QStringLiteral("%1").arg(addr, 8, 16, QLatin1Char('0')); + + const std::string textCode = [this, addr] { + Core::CPUThreadGuard guard(m_system); + return m_system.GetPowerPC().GetDebugInterface().Disassemble(&guard, addr); + }(); + + QString textTarget = QStringLiteral(""); + + if (IsInstructionLoadStore(textCode)) + { + const std::optional target_addr = + m_system.GetPowerPC().GetDebugInterface().GetMemoryAddressFromInstruction(textCode); + + if (target_addr) + { + textTarget = QStringLiteral(" targetting ") + + QStringLiteral("%1").arg(*target_addr, 8, 16, QLatin1Char('0')); + } + } + + QApplication::clipboard()->setText(textAddress + QString::fromStdString(std::string(" ")) + + QString::fromStdString(textCode) + textTarget); +} + void CodeViewWidget::OnCopyFunction() { const u32 address = GetContextAddress(); diff --git a/Source/Core/DolphinQt/Debugger/CodeViewWidget.h b/Source/Core/DolphinQt/Debugger/CodeViewWidget.h index 3fc78489ba..78eeb3bba4 100644 --- a/Source/Core/DolphinQt/Debugger/CodeViewWidget.h +++ b/Source/Core/DolphinQt/Debugger/CodeViewWidget.h @@ -85,6 +85,7 @@ private: void OnShowTargetInMemory(); void OnCopyFunction(); void OnCopyCode(); + void OnCopyWholeLine(); void OnCopyHex(); void OnRenameSymbol(); void OnSelectionChanged();