From 5836ca133c49573f308062c8e40af9216240f502 Mon Sep 17 00:00:00 2001 From: TryTwo Date: Tue, 17 Jun 2025 22:16:12 -0700 Subject: [PATCH] PPCSymbolDB: Move function for finding file path to PPCSymbolDB, so MenuBar doesn't have to randomly access boot.cpp to get the file path. --- Source/Core/Core/Boot/Boot.cpp | 22 +--------------------- Source/Core/Core/Boot/Boot.h | 1 - Source/Core/Core/PowerPC/PPCSymbolDB.cpp | 22 ++++++++++++++++++++++ Source/Core/Core/PowerPC/PPCSymbolDB.h | 2 ++ Source/Core/DolphinQt/MenuBar.cpp | 7 +++---- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index a3a984e35e..7521e5978c 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -354,30 +354,10 @@ bool CBoot::DVDReadDiscID(Core::System& system, const DiscIO::VolumeDisc& disc, return true; } -// Get map file paths for the active title. -bool CBoot::FindMapFile(std::string* existing_map_file, std::string* writable_map_file) -{ - const std::string& game_id = SConfig::GetInstance().m_debugger_game_id; - std::string path = File::GetUserPath(D_MAPS_IDX) + game_id + ".map"; - - if (writable_map_file) - *writable_map_file = path; - - if (File::Exists(path)) - { - if (existing_map_file) - *existing_map_file = std::move(path); - - return true; - } - - return false; -} - bool CBoot::LoadMapFromFilename(const Core::CPUThreadGuard& guard, PPCSymbolDB& ppc_symbol_db) { std::string strMapFilename; - bool found = FindMapFile(&strMapFilename, nullptr); + bool found = ppc_symbol_db.FindMapFile(&strMapFilename, nullptr); if (found && ppc_symbol_db.LoadMap(guard, strMapFilename)) { Host_PPCSymbolsChanged(); diff --git a/Source/Core/Core/Boot/Boot.h b/Source/Core/Core/Boot/Boot.h index 100f1cfdfd..8b157662cd 100644 --- a/Source/Core/Core/Boot/Boot.h +++ b/Source/Core/Core/Boot/Boot.h @@ -169,7 +169,6 @@ public: // file should be saved. // // Returns true if a map file exists, false if none could be found. - static bool FindMapFile(std::string* existing_map_file, std::string* writable_map_file); static bool LoadMapFromFilename(const Core::CPUThreadGuard& guard, PPCSymbolDB& ppc_symbol_db); private: diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index c837f1c041..09271fc688 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -15,10 +15,12 @@ #include #include "Common/CommonTypes.h" +#include "Common/FileUtil.h" #include "Common/IOFile.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" #include "Common/Unreachable.h" +#include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/Debugger/DebugInterface.h" #include "Core/PowerPC/MMU.h" @@ -279,6 +281,26 @@ void PPCSymbolDB::LogFunctionCall(u32 addr) f.num_calls++; } +// Get map file paths for the active title. +bool PPCSymbolDB::FindMapFile(std::string* existing_map_file, std::string* writable_map_file) +{ + const std::string& game_id = SConfig::GetInstance().m_debugger_game_id; + std::string path = File::GetUserPath(D_MAPS_IDX) + game_id + ".map"; + + if (writable_map_file) + *writable_map_file = path; + + if (File::Exists(path)) + { + if (existing_map_file) + *existing_map_file = std::move(path); + + return true; + } + + return false; +} + // The use case for handling bad map files is when you have a game with a map file on the disc, // but you can't tell whether that map file is for the particular release version used in that game, // or when you know that the map file is not for that build, but perhaps half the functions in the diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.h b/Source/Core/Core/PowerPC/PPCSymbolDB.h index b96ad2f42f..f3a84b0f18 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.h +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.h @@ -44,4 +44,6 @@ public: void PrintCalls(u32 funcAddr) const; void PrintCallers(u32 funcAddr) const; void LogFunctionCall(u32 addr); + + static bool FindMapFile(std::string* existing_map_file, std::string* writable_map_file); }; diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index 2f3245fe62..d6aa49d488 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -26,7 +26,6 @@ #include "Common/StringUtil.h" #include "Core/AchievementManager.h" -#include "Core/Boot/Boot.h" #include "Core/CommonTitles.h" #include "Core/Config/AchievementSettings.h" #include "Core/Config/MainSettings.h" @@ -1714,7 +1713,7 @@ void MenuBar::LoadSymbolMap() auto& ppc_symbol_db = system.GetPPCSymbolDB(); std::string existing_map_file, writable_map_file; - bool map_exists = CBoot::FindMapFile(&existing_map_file, &writable_map_file); + bool map_exists = PPCSymbolDB::FindMapFile(&existing_map_file, &writable_map_file); if (!map_exists) { @@ -1752,7 +1751,7 @@ void MenuBar::LoadSymbolMap() void MenuBar::SaveSymbolMap() { std::string existing_map_file, writable_map_file; - CBoot::FindMapFile(&existing_map_file, &writable_map_file); + PPCSymbolDB::FindMapFile(&existing_map_file, &writable_map_file); TrySaveSymbolMap(QString::fromStdString(writable_map_file)); } @@ -1808,7 +1807,7 @@ void MenuBar::SaveSymbolMapAs() void MenuBar::SaveCode() { std::string existing_map_file, writable_map_file; - CBoot::FindMapFile(&existing_map_file, &writable_map_file); + PPCSymbolDB::FindMapFile(&existing_map_file, &writable_map_file); const std::string path = writable_map_file.substr(0, writable_map_file.find_last_of('.')) + "_code.map";