From 3e3f9565ec784f99d8f143bb21f2f5206d41ab14 Mon Sep 17 00:00:00 2001 From: spycrab Date: Fri, 28 Dec 2018 19:12:30 +0100 Subject: [PATCH] Qt/Debugger: Add Show in Code / Show in Memory --- Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp | 8 ++++++++ Source/Core/DolphinQt/Debugger/CodeViewWidget.h | 3 +++ Source/Core/DolphinQt/Debugger/CodeWidget.cpp | 7 +++++++ Source/Core/DolphinQt/Debugger/CodeWidget.h | 1 + Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp | 4 ++++ Source/Core/DolphinQt/Debugger/MemoryViewWidget.h | 1 + Source/Core/DolphinQt/Debugger/MemoryWidget.cpp | 10 ++++++++++ Source/Core/DolphinQt/Debugger/MemoryWidget.h | 2 ++ Source/Core/DolphinQt/MainWindow.cpp | 4 ++++ 9 files changed, 40 insertions(+) diff --git a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp index af39c061e1..ab4e4d347e 100644 --- a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp @@ -224,6 +224,9 @@ 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); + + menu->addAction(tr("Show in &memory"), this, &CodeViewWidget::OnShowInMemory); + menu->addSeparator(); auto* symbol_rename_action = @@ -267,6 +270,11 @@ void CodeViewWidget::OnCopyAddress() QApplication::clipboard()->setText(QStringLiteral("%1").arg(addr, 8, 16, QLatin1Char('0'))); } +void CodeViewWidget::OnShowInMemory() +{ + emit ShowMemory(GetContextAddress()); +} + void CodeViewWidget::OnCopyCode() { const u32 addr = GetContextAddress(); diff --git a/Source/Core/DolphinQt/Debugger/CodeViewWidget.h b/Source/Core/DolphinQt/Debugger/CodeViewWidget.h index e93280a500..758fdceebd 100644 --- a/Source/Core/DolphinQt/Debugger/CodeViewWidget.h +++ b/Source/Core/DolphinQt/Debugger/CodeViewWidget.h @@ -34,8 +34,10 @@ public: void ToggleBreakpoint(); void AddBreakpoint(); + signals: void RequestPPCComparison(u32 addr); + void ShowMemory(u32 address); void SymbolsChanged(); void BreakpointsChanged(); @@ -57,6 +59,7 @@ private: void OnFollowBranch(); void OnCopyAddress(); + void OnShowInMemory(); void OnCopyFunction(); void OnCopyCode(); void OnCopyHex(); diff --git a/Source/Core/DolphinQt/Debugger/CodeWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeWidget.cpp index 4f782e0152..ab08d49ba5 100644 --- a/Source/Core/DolphinQt/Debugger/CodeWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeWidget.cpp @@ -164,6 +164,7 @@ void CodeWidget::ConnectWidgets() connect(m_code_view, &CodeViewWidget::RequestPPCComparison, this, &CodeWidget::RequestPPCComparison); + connect(m_code_view, &CodeViewWidget::ShowMemory, this, &CodeWidget::ShowMemory); } void CodeWidget::OnSearchAddress() @@ -250,6 +251,12 @@ void CodeWidget::OnSelectFunctionCallers() void CodeWidget::SetAddress(u32 address, CodeViewWidget::SetAddressUpdate update) { m_code_view->SetAddress(address, update); + + if (update == CodeViewWidget::SetAddressUpdate::WithUpdate) + { + raise(); + m_code_view->setFocus(); + } } void CodeWidget::Update() diff --git a/Source/Core/DolphinQt/Debugger/CodeWidget.h b/Source/Core/DolphinQt/Debugger/CodeWidget.h index ef755ab10c..df7e41348d 100644 --- a/Source/Core/DolphinQt/Debugger/CodeWidget.h +++ b/Source/Core/DolphinQt/Debugger/CodeWidget.h @@ -44,6 +44,7 @@ public: signals: void BreakpointsChanged(); void RequestPPCComparison(u32 addr); + void ShowMemory(u32 address); private: void CreateWidgets(); diff --git a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp index 30f262dbcf..09f1facac4 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp @@ -359,6 +359,10 @@ void MemoryViewWidget::OnContextMenu() menu->addSeparator(); + menu->addAction(tr("Show in code"), this, [this] { emit ShowCode(GetContextAddress()); }); + + menu->addSeparator(); + menu->addAction(tr("Toggle Breakpoint"), this, &MemoryViewWidget::ToggleBreakpoint); menu->exec(QCursor::pos()); diff --git a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.h b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.h index 3ff39c60f0..4b2b6958ea 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.h +++ b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.h @@ -49,6 +49,7 @@ public: signals: void BreakpointsChanged(); + void ShowCode(u32 address); private: void OnContextMenu(); diff --git a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp index 142037ccd9..fb396eb1f4 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp @@ -212,6 +212,7 @@ void MemoryWidget::ConnectWidgets() connect(m_bp_log_check, &QCheckBox::toggled, this, &MemoryWidget::OnBPLogChanged); connect(m_memory_view, &MemoryViewWidget::BreakpointsChanged, this, &MemoryWidget::BreakpointsChanged); + connect(m_memory_view, &MemoryViewWidget::ShowCode, this, &MemoryWidget::ShowCode); } void MemoryWidget::closeEvent(QCloseEvent*) @@ -323,6 +324,15 @@ void MemoryWidget::OnBPTypeChanged() SaveSettings(); } +void MemoryWidget::SetAddress(u32 address) +{ + m_memory_view->SetAddress(address); + Settings::Instance().SetMemoryVisible(true); + raise(); + + m_memory_view->setFocus(); +} + void MemoryWidget::OnSearchAddress() { bool good; diff --git a/Source/Core/DolphinQt/Debugger/MemoryWidget.h b/Source/Core/DolphinQt/Debugger/MemoryWidget.h index 6b38b23ea2..5d4cb0b603 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryWidget.h +++ b/Source/Core/DolphinQt/Debugger/MemoryWidget.h @@ -25,9 +25,11 @@ public: explicit MemoryWidget(QWidget* parent = nullptr); ~MemoryWidget(); + void SetAddress(u32 address); void Update(); signals: void BreakpointsChanged(); + void ShowCode(u32 address); private: void CreateWidgets(); diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 31917b6c86..b6a41cf7bf 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -288,8 +288,12 @@ void MainWindow::CreateComponents() connect(m_code_widget, &CodeWidget::BreakpointsChanged, m_breakpoint_widget, &BreakpointWidget::Update); connect(m_code_widget, &CodeWidget::RequestPPCComparison, m_jit_widget, &JITWidget::Compare); + connect(m_code_widget, &CodeWidget::ShowMemory, m_memory_widget, &MemoryWidget::SetAddress); connect(m_memory_widget, &MemoryWidget::BreakpointsChanged, m_breakpoint_widget, &BreakpointWidget::Update); + connect(m_memory_widget, &MemoryWidget::ShowCode, m_code_widget, [this](u32 address) { + m_code_widget->SetAddress(address, CodeViewWidget::SetAddressUpdate::WithUpdate); + }); connect(m_breakpoint_widget, &BreakpointWidget::BreakpointsChanged, m_code_widget, &CodeWidget::Update);