diff options
| author | TryTwo <taolas@gmail.com> | 2022-03-17 12:53:38 -0700 |
|---|---|---|
| committer | TryTwo <taolas@gmail.com> | 2022-03-17 12:53:38 -0700 |
| commit | 53cf78d413cb4e4cc546f027423a6a011cd30a64 (patch) | |
| tree | c86cca8e02eaad96f468191a3128adb8f5f6c929 /Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp | |
| parent | 58c02e6b8585e0764643853f8e255b5013978469 (diff) | |
Gekko constistancy changes. Add context item to codeview to show or copy a load/store target memory address from instructions at or near PC when paused.
Diffstat (limited to 'Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp')
| -rw-r--r-- | Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp index fb300a370f..76e43d50ad 100644 --- a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp @@ -235,6 +235,15 @@ static bool IsBranchInstructionWithLink(std::string_view ins) StringEndsWith(ins, "la+") || StringEndsWith(ins, "l-") || StringEndsWith(ins, "la-"); } +static bool IsInstructionLoadStore(std::string_view ins) +{ + // Could add check for context address being near PC, because we need gprs to be correct for the + // load/store. + return (StringBeginsWith(ins, "l") && !StringBeginsWith(ins, "li")) || + StringBeginsWith(ins, "st") || StringBeginsWith(ins, "psq_l") || + StringBeginsWith(ins, "psq_s"); +} + void CodeViewWidget::Update() { if (!isVisible()) @@ -530,7 +539,10 @@ void CodeViewWidget::OnContextMenu() auto* copy_hex_action = menu->addAction(tr("Copy &hex"), this, &CodeViewWidget::OnCopyHex); menu->addAction(tr("Show in &memory"), this, &CodeViewWidget::OnShowInMemory); - + auto* show_target_memory = + menu->addAction(tr("Show target in memor&y"), this, &CodeViewWidget::OnShowTargetInMemory); + auto* copy_target_memory = + menu->addAction(tr("Copy tar&get address"), this, &CodeViewWidget::OnCopyTargetAddress); menu->addSeparator(); auto* symbol_rename_action = @@ -561,6 +573,14 @@ void CodeViewWidget::OnContextMenu() for (auto* action : {symbol_rename_action, symbol_size_action, symbol_end_action}) action->setEnabled(has_symbol); + const bool valid_load_store = Core::GetState() == Core::State::Paused && + IsInstructionLoadStore(PowerPC::debug_interface.Disassemble(addr)); + + for (auto* action : {copy_target_memory, show_target_memory}) + { + action->setEnabled(valid_load_store); + } + restore_action->setEnabled(running && PowerPC::debug_interface.HasEnabledPatch(addr)); menu->exec(QCursor::pos()); @@ -574,11 +594,45 @@ void CodeViewWidget::OnCopyAddress() QApplication::clipboard()->setText(QStringLiteral("%1").arg(addr, 8, 16, QLatin1Char('0'))); } +void CodeViewWidget::OnCopyTargetAddress() +{ + if (Core::GetState() != Core::State::Paused) + return; + + const std::string code_line = PowerPC::debug_interface.Disassemble(GetContextAddress()); + + if (!IsInstructionLoadStore(code_line)) + return; + + const std::optional<u32> addr = + PowerPC::debug_interface.GetMemoryAddressFromInstruction(code_line); + + if (addr) + QApplication::clipboard()->setText(QStringLiteral("%1").arg(*addr, 8, 16, QLatin1Char('0'))); +} + void CodeViewWidget::OnShowInMemory() { emit ShowMemory(GetContextAddress()); } +void CodeViewWidget::OnShowTargetInMemory() +{ + if (Core::GetState() != Core::State::Paused) + return; + + const std::string code_line = PowerPC::debug_interface.Disassemble(GetContextAddress()); + + if (!IsInstructionLoadStore(code_line)) + return; + + const std::optional<u32> addr = + PowerPC::debug_interface.GetMemoryAddressFromInstruction(code_line); + + if (addr) + emit ShowMemory(*addr); +} + void CodeViewWidget::OnCopyCode() { const u32 addr = GetContextAddress(); |
