[DEBUGGER] Disassembler copy whole line option

This commit is contained in:
Nitch2024 2025-03-29 11:54:38 -07:00
parent 1981f22228
commit fdda9fdcc5
2 changed files with 33 additions and 2 deletions

View file

@ -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<u32> 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();

View file

@ -85,6 +85,7 @@ private:
void OnShowTargetInMemory();
void OnCopyFunction();
void OnCopyCode();
void OnCopyWholeLine();
void OnCopyHex();
void OnRenameSymbol();
void OnSelectionChanged();