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
commit a2074a8583
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 46 additions and 78 deletions

View File

@ -96,7 +96,7 @@ std::vector<std::string> Host_GetPreferredLocales()
return {}; return {};
} }
void Host_NotifyMapLoaded() void Host_PPCSymbolsChanged()
{ {
} }

View File

@ -351,11 +351,6 @@ bool CBoot::DVDReadDiscID(Core::System& system, const DiscIO::VolumeDisc& disc,
return true; return true;
} }
void CBoot::UpdateDebugger_MapLoaded()
{
Host_NotifyMapLoaded();
}
// Get map file paths for the active title. // Get map file paths for the active title.
bool CBoot::FindMapFile(std::string* existing_map_file, std::string* writable_map_file) bool CBoot::FindMapFile(std::string* existing_map_file, std::string* writable_map_file)
{ {
@ -382,7 +377,7 @@ bool CBoot::LoadMapFromFilename(const Core::CPUThreadGuard& guard, PPCSymbolDB&
bool found = FindMapFile(&strMapFilename, nullptr); bool found = FindMapFile(&strMapFilename, nullptr);
if (found && ppc_symbol_db.LoadMap(guard, strMapFilename)) if (found && ppc_symbol_db.LoadMap(guard, strMapFilename))
{ {
UpdateDebugger_MapLoaded(); Host_PPCSymbolsChanged();
return true; return true;
} }
@ -517,7 +512,7 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard,
if (auto& ppc_symbol_db = system.GetPPCSymbolDB(); !ppc_symbol_db.IsEmpty()) if (auto& ppc_symbol_db = system.GetPPCSymbolDB(); !ppc_symbol_db.IsEmpty())
{ {
ppc_symbol_db.Clear(); ppc_symbol_db.Clear();
UpdateDebugger_MapLoaded(); Host_PPCSymbolsChanged();
} }
// PAL Wii uses NTSC framerate and linecount in 60Hz modes // PAL Wii uses NTSC framerate and linecount in 60Hz modes
@ -597,7 +592,7 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard,
if (executable.reader->LoadSymbols(guard, system.GetPPCSymbolDB())) if (executable.reader->LoadSymbols(guard, system.GetPPCSymbolDB()))
{ {
UpdateDebugger_MapLoaded(); Host_PPCSymbolsChanged();
HLE::PatchFunctions(system); HLE::PatchFunctions(system);
} }
return true; return true;

View File

@ -179,8 +179,6 @@ private:
u32 output_address); u32 output_address);
static void RunFunction(Core::System& system, u32 address); static void RunFunction(Core::System& system, u32 address);
static void UpdateDebugger_MapLoaded();
static bool Boot_WiiWAD(Core::System& system, const DiscIO::VolumeWAD& wad); static bool Boot_WiiWAD(Core::System& system, const DiscIO::VolumeWAD& wad);
static bool BootNANDTitle(Core::System& system, u64 title_id); static bool BootNANDTitle(Core::System& system, u64 title_id);

View File

@ -210,7 +210,7 @@ void SConfig::OnNewTitleLoad(const Core::CPUThreadGuard& guard)
if (!ppc_symbol_db.IsEmpty()) if (!ppc_symbol_db.IsEmpty())
{ {
ppc_symbol_db.Clear(); ppc_symbol_db.Clear();
Host_NotifyMapLoaded(); Host_PPCSymbolsChanged();
} }
CBoot::LoadMapFromFilename(guard, ppc_symbol_db); CBoot::LoadMapFromFilename(guard, ppc_symbol_db);
HLE::Reload(system); HLE::Reload(system);

View File

@ -55,7 +55,7 @@ bool Host_RendererHasFullFocus();
bool Host_RendererIsFullscreen(); bool Host_RendererIsFullscreen();
void Host_Message(HostMessageID id); void Host_Message(HostMessageID id);
void Host_NotifyMapLoaded(); void Host_PPCSymbolsChanged();
void Host_RefreshDSPDebuggerWindow(); void Host_RefreshDSPDebuggerWindow();
void Host_RequestRenderWindowSize(int width, int height); void Host_RequestRenderWindowSize(int width, int height);
void Host_UpdateDisasmDialog(); void Host_UpdateDisasmDialog();

View File

@ -74,13 +74,13 @@ bool Load(Core::System& system)
if (!ppc_symbol_db.IsEmpty()) if (!ppc_symbol_db.IsEmpty())
{ {
ppc_symbol_db.Clear(); ppc_symbol_db.Clear();
Host_NotifyMapLoaded(); Host_PPCSymbolsChanged();
} }
if (ppc_symbol_db.LoadMap(guard, File::GetUserPath(D_MAPS_IDX) + "mios-ipl.map")) if (ppc_symbol_db.LoadMap(guard, File::GetUserPath(D_MAPS_IDX) + "mios-ipl.map"))
{ {
::HLE::Clear(); ::HLE::Clear();
::HLE::PatchFunctions(system); ::HLE::PatchFunctions(system);
Host_NotifyMapLoaded(); Host_PPCSymbolsChanged();
} }
const PowerPC::CoreMode core_mode = power_pc.GetMode(); const PowerPC::CoreMode core_mode = power_pc.GetMode();

View File

@ -57,7 +57,7 @@ std::vector<std::string> Host_GetPreferredLocales()
return {}; return {};
} }
void Host_NotifyMapLoaded() void Host_PPCSymbolsChanged()
{ {
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -65,8 +65,6 @@ CodeWidget::CodeWidget(QWidget* parent)
Update(); Update();
}); });
connect(Host::GetInstance(), &Host::NotifyMapLoaded, this, &CodeWidget::UpdateSymbols);
connect(&Settings::Instance(), &Settings::DebugModeToggled, this, connect(&Settings::Instance(), &Settings::DebugModeToggled, this,
[this](bool enabled) { setHidden(!enabled || !Settings::Instance().IsCodeVisible()); }); [this](bool enabled) { setHidden(!enabled || !Settings::Instance().IsCodeVisible()); });
@ -191,15 +189,7 @@ void CodeWidget::ConnectWidgets()
connect(m_function_callers_list, &QListWidget::itemPressed, this, connect(m_function_callers_list, &QListWidget::itemPressed, this,
&CodeWidget::OnSelectFunctionCallers); &CodeWidget::OnSelectFunctionCallers);
connect(m_code_view, &CodeViewWidget::SymbolsChanged, this, [this]() { connect(Host::GetInstance(), &Host::PPCSymbolsChanged, this, &CodeWidget::OnPPCSymbolsChanged);
UpdateCallstack();
UpdateSymbols();
if (const Common::Symbol* symbol = m_ppc_symbol_db.GetSymbolFromAddr(m_code_view->GetAddress()))
{
UpdateFunctionCalls(symbol);
UpdateFunctionCallers(symbol);
}
});
connect(m_code_view, &CodeViewWidget::BreakpointsChanged, this, connect(m_code_view, &CodeViewWidget::BreakpointsChanged, this,
[this] { emit BreakpointsChanged(); }); [this] { emit BreakpointsChanged(); });
connect(m_code_view, &CodeViewWidget::UpdateCodeWidget, this, &CodeWidget::Update); connect(m_code_view, &CodeViewWidget::UpdateCodeWidget, this, &CodeWidget::Update);
@ -221,6 +211,17 @@ void CodeWidget::OnBranchWatchDialog()
m_branch_watch_dialog->activateWindow(); 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() void CodeWidget::OnSearchAddress()
{ {
bool good = true; bool good = true;
@ -389,11 +390,6 @@ void CodeWidget::UpdateSymbols()
} }
m_symbols_list->sortItems(); 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) void CodeWidget::UpdateFunctionCalls(const Common::Symbol* symbol)

View File

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

View File

@ -238,14 +238,9 @@ void Host_UpdateDisasmDialog()
QueueOnObject(QApplication::instance(), [] { emit Host::GetInstance()->UpdateDisasmDialog(); }); QueueOnObject(QApplication::instance(), [] { emit Host::GetInstance()->UpdateDisasmDialog(); });
} }
void Host::RequestNotifyMapLoaded() void Host_PPCSymbolsChanged()
{ {
QueueOnObject(QApplication::instance(), [this] { emit NotifyMapLoaded(); }); QueueOnObject(QApplication::instance(), [] { emit Host::GetInstance()->PPCSymbolsChanged(); });
}
void Host_NotifyMapLoaded()
{
Host::GetInstance()->RequestNotifyMapLoaded();
} }
// We ignore these, and their purpose should be questioned individually. // We ignore these, and their purpose should be questioned individually.

View File

@ -32,14 +32,13 @@ public:
void SetRenderFullFocus(bool focus); void SetRenderFullFocus(bool focus);
void SetRenderFullscreen(bool fullscreen); void SetRenderFullscreen(bool fullscreen);
void ResizeSurface(int new_width, int new_height); void ResizeSurface(int new_width, int new_height);
void RequestNotifyMapLoaded();
signals: signals:
void RequestTitle(const QString& title); void RequestTitle(const QString& title);
void RequestStop(); void RequestStop();
void RequestRenderSize(int w, int h); void RequestRenderSize(int w, int h);
void UpdateDisasmDialog(); void UpdateDisasmDialog();
void NotifyMapLoaded(); void PPCSymbolsChanged();
private: private:
Host(); Host();

View File

@ -591,12 +591,6 @@ void MainWindow::ConnectMenuBar()
connect(m_game_list, &GameList::SelectionChanged, m_menu_bar, &MenuBar::SelectionChanged); connect(m_game_list, &GameList::SelectionChanged, m_menu_bar, &MenuBar::SelectionChanged);
connect(this, &MainWindow::ReadOnlyModeChanged, m_menu_bar, &MenuBar::ReadOnlyModeChanged); connect(this, &MainWindow::ReadOnlyModeChanged, m_menu_bar, &MenuBar::ReadOnlyModeChanged);
connect(this, &MainWindow::RecordingStatusChanged, m_menu_bar, &MenuBar::RecordingStatusChanged); connect(this, &MainWindow::RecordingStatusChanged, m_menu_bar, &MenuBar::RecordingStatusChanged);
// Symbols
connect(m_menu_bar, &MenuBar::NotifySymbolsUpdated, [this] {
m_code_widget->UpdateSymbols();
m_code_widget->Update();
});
} }
void MainWindow::ConnectHotkeys() void MainWindow::ConnectHotkeys()

View File

@ -1262,7 +1262,7 @@ void MenuBar::ClearSymbols()
return; return;
Core::System::GetInstance().GetPPCSymbolDB().Clear(); Core::System::GetInstance().GetPPCSymbolDB().Clear();
emit NotifySymbolsUpdated(); emit Host::GetInstance()->PPCSymbolsChanged();
} }
void MenuBar::GenerateSymbolsFromAddress() void MenuBar::GenerateSymbolsFromAddress()
@ -1275,7 +1275,7 @@ void MenuBar::GenerateSymbolsFromAddress()
PPCAnalyst::FindFunctions(guard, Memory::MEM1_BASE_ADDR, PPCAnalyst::FindFunctions(guard, Memory::MEM1_BASE_ADDR,
Memory::MEM1_BASE_ADDR + memory.GetRamSizeReal(), &ppc_symbol_db); Memory::MEM1_BASE_ADDR + memory.GetRamSizeReal(), &ppc_symbol_db);
emit NotifySymbolsUpdated(); emit Host::GetInstance()->PPCSymbolsChanged();
} }
void MenuBar::GenerateSymbolsFromSignatureDB() void MenuBar::GenerateSymbolsFromSignatureDB()
@ -1304,7 +1304,7 @@ void MenuBar::GenerateSymbolsFromSignatureDB()
tr("'%1' not found, no symbol names generated").arg(QString::fromStdString(TOTALDB))); tr("'%1' not found, no symbol names generated").arg(QString::fromStdString(TOTALDB)));
} }
emit NotifySymbolsUpdated(); emit Host::GetInstance()->PPCSymbolsChanged();
} }
void MenuBar::GenerateSymbolsFromRSO() void MenuBar::GenerateSymbolsFromRSO()
@ -1334,7 +1334,7 @@ void MenuBar::GenerateSymbolsFromRSO()
if (rso_chain.Load(guard, static_cast<u32>(address))) if (rso_chain.Load(guard, static_cast<u32>(address)))
{ {
rso_chain.Apply(guard, &system.GetPPCSymbolDB()); rso_chain.Apply(guard, &system.GetPPCSymbolDB());
emit NotifySymbolsUpdated(); emit Host::GetInstance()->PPCSymbolsChanged();
} }
else else
{ {
@ -1391,7 +1391,7 @@ void MenuBar::GenerateSymbolsFromRSOAuto()
if (rso_chain.Load(guard, address)) if (rso_chain.Load(guard, address))
{ {
rso_chain.Apply(guard, &system.GetPPCSymbolDB()); rso_chain.Apply(guard, &system.GetPPCSymbolDB());
emit NotifySymbolsUpdated(); emit Host::GetInstance()->PPCSymbolsChanged();
} }
else else
{ {
@ -1541,7 +1541,7 @@ void MenuBar::LoadSymbolMap()
} }
HLE::PatchFunctions(system); HLE::PatchFunctions(system);
emit NotifySymbolsUpdated(); emit Host::GetInstance()->PPCSymbolsChanged();
} }
void MenuBar::SaveSymbolMap() void MenuBar::SaveSymbolMap()
@ -1566,7 +1566,7 @@ void MenuBar::LoadOtherSymbolMap()
auto& system = Core::System::GetInstance(); auto& system = Core::System::GetInstance();
HLE::PatchFunctions(system); HLE::PatchFunctions(system);
emit NotifySymbolsUpdated(); emit Host::GetInstance()->PPCSymbolsChanged();
} }
void MenuBar::LoadBadSymbolMap() void MenuBar::LoadBadSymbolMap()
@ -1583,7 +1583,7 @@ void MenuBar::LoadBadSymbolMap()
auto& system = Core::System::GetInstance(); auto& system = Core::System::GetInstance();
HLE::PatchFunctions(system); HLE::PatchFunctions(system);
emit NotifySymbolsUpdated(); emit Host::GetInstance()->PPCSymbolsChanged();
} }
void MenuBar::SaveSymbolMapAs() void MenuBar::SaveSymbolMapAs()
@ -1708,7 +1708,7 @@ void MenuBar::ApplySignatureFile()
db.Apply(Core::CPUThreadGuard{system}, &system.GetPPCSymbolDB()); db.Apply(Core::CPUThreadGuard{system}, &system.GetPPCSymbolDB());
db.List(); db.List();
HLE::PatchFunctions(system); HLE::PatchFunctions(system);
emit NotifySymbolsUpdated(); emit Host::GetInstance()->PPCSymbolsChanged();
} }
void MenuBar::CombineSignatureFiles() void MenuBar::CombineSignatureFiles()

View File

@ -125,9 +125,6 @@ signals:
void RecordingStatusChanged(bool recording); void RecordingStatusChanged(bool recording);
void ReadOnlyModeChanged(bool read_only); void ReadOnlyModeChanged(bool read_only);
// Synbols
void NotifySymbolsUpdated();
private: private:
void OnEmulationStateChanged(Core::State state); void OnEmulationStateChanged(Core::State state);

View File

@ -21,7 +21,7 @@ std::vector<std::string> Host_GetPreferredLocales()
return {}; return {};
} }
void Host_NotifyMapLoaded() void Host_PPCSymbolsChanged()
{ {
} }

View File

@ -13,7 +13,7 @@ std::vector<std::string> Host_GetPreferredLocales()
{ {
return {}; return {};
} }
void Host_NotifyMapLoaded() void Host_PPCSymbolsChanged()
{ {
} }
void Host_RefreshDSPDebuggerWindow() void Host_RefreshDSPDebuggerWindow()

View File

@ -13,7 +13,7 @@ std::vector<std::string> Host_GetPreferredLocales()
{ {
return {}; return {};
} }
void Host_NotifyMapLoaded() void Host_PPCSymbolsChanged()
{ {
} }
void Host_RefreshDSPDebuggerWindow() void Host_RefreshDSPDebuggerWindow()