Merge pull request #12645 from mitaclaw/ppc-symbols-signal

DolphinQt: A Ubiquitous Signal For When Symbols Change
This commit is contained in:
Admiral H. Curtiss
2024-03-31 06:36:09 +02:00
committed by GitHub
21 changed files with 46 additions and 78 deletions

View File

@ -42,6 +42,7 @@
#include "Core/System.h"
#include "DolphinQt/Debugger/BranchWatchTableModel.h"
#include "DolphinQt/Debugger/CodeWidget.h"
#include "DolphinQt/Host.h"
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
@ -219,6 +220,8 @@ BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& br
m_table_model->setFont(ui_settings.GetDebugFont());
connect(&ui_settings, &Settings::DebugFontChanged, m_table_model,
&BranchWatchTableModel::setFont);
connect(Host::GetInstance(), &Host::PPCSymbolsChanged, m_table_model,
&BranchWatchTableModel::UpdateSymbols);
auto* const table_view = new QTableView;
table_view->setModel(m_table_proxy);
@ -938,11 +941,6 @@ void BranchWatchDialog::Update()
m_table_model->UpdateHits();
}
void BranchWatchDialog::UpdateSymbols()
{
m_table_model->UpdateSymbols();
}
void BranchWatchDialog::UpdateStatus()
{
switch (m_branch_watch.GetRecordingPhase())

View File

@ -92,8 +92,6 @@ private:
public:
// TODO: Step doesn't cause EmulationStateChanged to be emitted, so it has to call this manually.
void Update();
// TODO: There seems to be a lack of a ubiquitous signal for when symbols change.
void UpdateSymbols();
private:
void UpdateStatus();

View File

@ -183,6 +183,8 @@ CodeViewWidget::CodeViewWidget()
m_address = m_system.GetPPCState().pc;
Update();
});
connect(Host::GetInstance(), &Host::PPCSymbolsChanged, this,
qOverload<>(&CodeViewWidget::Update));
connect(&Settings::Instance(), &Settings::ThemeChanged, this,
qOverload<>(&CodeViewWidget::Update));
@ -884,8 +886,7 @@ void CodeViewWidget::OnAddFunction()
Core::CPUThreadGuard guard(m_system);
m_ppc_symbol_db.AddFunction(guard, addr);
emit SymbolsChanged();
Update(&guard);
emit Host::GetInstance()->PPCSymbolsChanged();
}
void CodeViewWidget::OnInsertBLR()
@ -934,8 +935,7 @@ void CodeViewWidget::OnRenameSymbol()
if (good && !name.isEmpty())
{
symbol->Rename(name.toStdString());
emit SymbolsChanged();
Update();
emit Host::GetInstance()->PPCSymbolsChanged();
}
}
@ -973,8 +973,7 @@ void CodeViewWidget::OnSetSymbolSize()
Core::CPUThreadGuard guard(m_system);
PPCAnalyst::ReanalyzeFunction(guard, symbol->address, *symbol, size);
emit SymbolsChanged();
Update(&guard);
emit Host::GetInstance()->PPCSymbolsChanged();
}
void CodeViewWidget::OnSetSymbolEndAddress()
@ -1001,8 +1000,7 @@ void CodeViewWidget::OnSetSymbolEndAddress()
Core::CPUThreadGuard guard(m_system);
PPCAnalyst::ReanalyzeFunction(guard, symbol->address, *symbol, address - symbol->address);
emit SymbolsChanged();
Update(&guard);
emit Host::GetInstance()->PPCSymbolsChanged();
}
void CodeViewWidget::OnReplaceInstruction()

View File

@ -57,7 +57,6 @@ public:
signals:
void RequestPPCComparison(u32 addr);
void ShowMemory(u32 address);
void SymbolsChanged();
void BreakpointsChanged();
void UpdateCodeWidget();

View File

@ -65,8 +65,6 @@ CodeWidget::CodeWidget(QWidget* parent)
Update();
});
connect(Host::GetInstance(), &Host::NotifyMapLoaded, this, &CodeWidget::UpdateSymbols);
connect(&Settings::Instance(), &Settings::DebugModeToggled, this,
[this](bool enabled) { setHidden(!enabled || !Settings::Instance().IsCodeVisible()); });
@ -191,15 +189,7 @@ void CodeWidget::ConnectWidgets()
connect(m_function_callers_list, &QListWidget::itemPressed, this,
&CodeWidget::OnSelectFunctionCallers);
connect(m_code_view, &CodeViewWidget::SymbolsChanged, this, [this]() {
UpdateCallstack();
UpdateSymbols();
if (const Common::Symbol* symbol = m_ppc_symbol_db.GetSymbolFromAddr(m_code_view->GetAddress()))
{
UpdateFunctionCalls(symbol);
UpdateFunctionCallers(symbol);
}
});
connect(Host::GetInstance(), &Host::PPCSymbolsChanged, this, &CodeWidget::OnPPCSymbolsChanged);
connect(m_code_view, &CodeViewWidget::BreakpointsChanged, this,
[this] { emit BreakpointsChanged(); });
connect(m_code_view, &CodeViewWidget::UpdateCodeWidget, this, &CodeWidget::Update);
@ -221,6 +211,17 @@ void CodeWidget::OnBranchWatchDialog()
m_branch_watch_dialog->activateWindow();
}
void CodeWidget::OnPPCSymbolsChanged()
{
UpdateSymbols();
UpdateCallstack();
if (const Common::Symbol* symbol = m_ppc_symbol_db.GetSymbolFromAddr(m_code_view->GetAddress()))
{
UpdateFunctionCalls(symbol);
UpdateFunctionCallers(symbol);
}
}
void CodeWidget::OnSearchAddress()
{
bool good = true;
@ -389,11 +390,6 @@ void CodeWidget::UpdateSymbols()
}
m_symbols_list->sortItems();
// TODO: There seems to be a lack of a ubiquitous signal for when symbols change.
// This is the best location to catch the signals from MenuBar and CodeViewWidget.
if (m_branch_watch_dialog != nullptr)
m_branch_watch_dialog->UpdateSymbols();
}
void CodeWidget::UpdateFunctionCalls(const Common::Symbol* symbol)

View File

@ -61,6 +61,7 @@ private:
void UpdateFunctionCalls(const Common::Symbol* symbol);
void UpdateFunctionCallers(const Common::Symbol* symbol);
void OnPPCSymbolsChanged();
void OnSearchAddress();
void OnSearchSymbols();
void OnSelectSymbol();