Qt/Debugger: Add Show in Code / Show in Memory

This commit is contained in:
spycrab 2018-12-28 19:12:30 +01:00
parent 0a8e04e469
commit 3e3f9565ec
9 changed files with 40 additions and 0 deletions

View file

@ -224,6 +224,9 @@ void CodeViewWidget::OnContextMenu()
auto* copy_line_action = auto* copy_line_action =
menu->addAction(tr("Copy code &line"), this, &CodeViewWidget::OnCopyCode); menu->addAction(tr("Copy code &line"), this, &CodeViewWidget::OnCopyCode);
auto* copy_hex_action = menu->addAction(tr("Copy &hex"), this, &CodeViewWidget::OnCopyHex); auto* copy_hex_action = menu->addAction(tr("Copy &hex"), this, &CodeViewWidget::OnCopyHex);
menu->addAction(tr("Show in &memory"), this, &CodeViewWidget::OnShowInMemory);
menu->addSeparator(); menu->addSeparator();
auto* symbol_rename_action = auto* symbol_rename_action =
@ -267,6 +270,11 @@ void CodeViewWidget::OnCopyAddress()
QApplication::clipboard()->setText(QStringLiteral("%1").arg(addr, 8, 16, QLatin1Char('0'))); QApplication::clipboard()->setText(QStringLiteral("%1").arg(addr, 8, 16, QLatin1Char('0')));
} }
void CodeViewWidget::OnShowInMemory()
{
emit ShowMemory(GetContextAddress());
}
void CodeViewWidget::OnCopyCode() void CodeViewWidget::OnCopyCode()
{ {
const u32 addr = GetContextAddress(); const u32 addr = GetContextAddress();

View file

@ -34,8 +34,10 @@ public:
void ToggleBreakpoint(); void ToggleBreakpoint();
void AddBreakpoint(); void AddBreakpoint();
signals: signals:
void RequestPPCComparison(u32 addr); void RequestPPCComparison(u32 addr);
void ShowMemory(u32 address);
void SymbolsChanged(); void SymbolsChanged();
void BreakpointsChanged(); void BreakpointsChanged();
@ -57,6 +59,7 @@ private:
void OnFollowBranch(); void OnFollowBranch();
void OnCopyAddress(); void OnCopyAddress();
void OnShowInMemory();
void OnCopyFunction(); void OnCopyFunction();
void OnCopyCode(); void OnCopyCode();
void OnCopyHex(); void OnCopyHex();

View file

@ -164,6 +164,7 @@ void CodeWidget::ConnectWidgets()
connect(m_code_view, &CodeViewWidget::RequestPPCComparison, this, connect(m_code_view, &CodeViewWidget::RequestPPCComparison, this,
&CodeWidget::RequestPPCComparison); &CodeWidget::RequestPPCComparison);
connect(m_code_view, &CodeViewWidget::ShowMemory, this, &CodeWidget::ShowMemory);
} }
void CodeWidget::OnSearchAddress() void CodeWidget::OnSearchAddress()
@ -250,6 +251,12 @@ void CodeWidget::OnSelectFunctionCallers()
void CodeWidget::SetAddress(u32 address, CodeViewWidget::SetAddressUpdate update) void CodeWidget::SetAddress(u32 address, CodeViewWidget::SetAddressUpdate update)
{ {
m_code_view->SetAddress(address, update); m_code_view->SetAddress(address, update);
if (update == CodeViewWidget::SetAddressUpdate::WithUpdate)
{
raise();
m_code_view->setFocus();
}
} }
void CodeWidget::Update() void CodeWidget::Update()

View file

@ -44,6 +44,7 @@ public:
signals: signals:
void BreakpointsChanged(); void BreakpointsChanged();
void RequestPPCComparison(u32 addr); void RequestPPCComparison(u32 addr);
void ShowMemory(u32 address);
private: private:
void CreateWidgets(); void CreateWidgets();

View file

@ -359,6 +359,10 @@ void MemoryViewWidget::OnContextMenu()
menu->addSeparator(); menu->addSeparator();
menu->addAction(tr("Show in code"), this, [this] { emit ShowCode(GetContextAddress()); });
menu->addSeparator();
menu->addAction(tr("Toggle Breakpoint"), this, &MemoryViewWidget::ToggleBreakpoint); menu->addAction(tr("Toggle Breakpoint"), this, &MemoryViewWidget::ToggleBreakpoint);
menu->exec(QCursor::pos()); menu->exec(QCursor::pos());

View file

@ -49,6 +49,7 @@ public:
signals: signals:
void BreakpointsChanged(); void BreakpointsChanged();
void ShowCode(u32 address);
private: private:
void OnContextMenu(); void OnContextMenu();

View file

@ -212,6 +212,7 @@ void MemoryWidget::ConnectWidgets()
connect(m_bp_log_check, &QCheckBox::toggled, this, &MemoryWidget::OnBPLogChanged); connect(m_bp_log_check, &QCheckBox::toggled, this, &MemoryWidget::OnBPLogChanged);
connect(m_memory_view, &MemoryViewWidget::BreakpointsChanged, this, connect(m_memory_view, &MemoryViewWidget::BreakpointsChanged, this,
&MemoryWidget::BreakpointsChanged); &MemoryWidget::BreakpointsChanged);
connect(m_memory_view, &MemoryViewWidget::ShowCode, this, &MemoryWidget::ShowCode);
} }
void MemoryWidget::closeEvent(QCloseEvent*) void MemoryWidget::closeEvent(QCloseEvent*)
@ -323,6 +324,15 @@ void MemoryWidget::OnBPTypeChanged()
SaveSettings(); SaveSettings();
} }
void MemoryWidget::SetAddress(u32 address)
{
m_memory_view->SetAddress(address);
Settings::Instance().SetMemoryVisible(true);
raise();
m_memory_view->setFocus();
}
void MemoryWidget::OnSearchAddress() void MemoryWidget::OnSearchAddress()
{ {
bool good; bool good;

View file

@ -25,9 +25,11 @@ public:
explicit MemoryWidget(QWidget* parent = nullptr); explicit MemoryWidget(QWidget* parent = nullptr);
~MemoryWidget(); ~MemoryWidget();
void SetAddress(u32 address);
void Update(); void Update();
signals: signals:
void BreakpointsChanged(); void BreakpointsChanged();
void ShowCode(u32 address);
private: private:
void CreateWidgets(); void CreateWidgets();

View file

@ -288,8 +288,12 @@ void MainWindow::CreateComponents()
connect(m_code_widget, &CodeWidget::BreakpointsChanged, m_breakpoint_widget, connect(m_code_widget, &CodeWidget::BreakpointsChanged, m_breakpoint_widget,
&BreakpointWidget::Update); &BreakpointWidget::Update);
connect(m_code_widget, &CodeWidget::RequestPPCComparison, m_jit_widget, &JITWidget::Compare); 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, connect(m_memory_widget, &MemoryWidget::BreakpointsChanged, m_breakpoint_widget,
&BreakpointWidget::Update); &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, connect(m_breakpoint_widget, &BreakpointWidget::BreakpointsChanged, m_code_widget,
&CodeWidget::Update); &CodeWidget::Update);