mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
PPCSymbolDB: Move loading map on boot logic from boot.cpp into PPCSymbolDB, as it will be needing a mutex.
Cleanup loading code and reduce amount of signals. On boot. allow previously loaded map to be kept, if its filename matches. Useful for restarting a game with a large symbol map.
This commit is contained in:
@ -44,15 +44,20 @@ void SymbolDB::List()
|
||||
|
||||
bool SymbolDB::IsEmpty() const
|
||||
{
|
||||
return m_functions.empty();
|
||||
return m_functions.empty() && m_notes.empty();
|
||||
}
|
||||
|
||||
void SymbolDB::Clear(const char* prefix)
|
||||
bool SymbolDB::Clear(const char* prefix)
|
||||
{
|
||||
// TODO: honor prefix
|
||||
m_map_name.clear();
|
||||
if (IsEmpty())
|
||||
return false;
|
||||
|
||||
m_functions.clear();
|
||||
m_notes.clear();
|
||||
m_checksum_to_function.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SymbolDB::Index()
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
const XNoteMap& Notes() const { return m_notes; }
|
||||
XFuncMap& AccessSymbols() { return m_functions; }
|
||||
bool IsEmpty() const;
|
||||
void Clear(const char* prefix = "");
|
||||
bool Clear(const char* prefix = "");
|
||||
void List();
|
||||
void Index();
|
||||
|
||||
@ -108,5 +108,6 @@ protected:
|
||||
XFuncMap m_functions;
|
||||
XNoteMap m_notes;
|
||||
XFuncPtrMap m_checksum_to_function;
|
||||
std::string m_map_name;
|
||||
};
|
||||
} // namespace Common
|
||||
|
@ -354,19 +354,6 @@ bool CBoot::DVDReadDiscID(Core::System& system, const DiscIO::VolumeDisc& disc,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBoot::LoadMapFromFilename(const Core::CPUThreadGuard& guard, PPCSymbolDB& ppc_symbol_db)
|
||||
{
|
||||
std::string strMapFilename;
|
||||
bool found = ppc_symbol_db.FindMapFile(&strMapFilename, nullptr);
|
||||
if (found && ppc_symbol_db.LoadMap(guard, strMapFilename))
|
||||
{
|
||||
Host_PPCSymbolsChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// If ipl.bin is not found, this function does *some* of what BS1 does:
|
||||
// loading IPL(BS2) and jumping to it.
|
||||
// It does not initialize the hardware or anything else like BS1 does.
|
||||
@ -504,12 +491,6 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard,
|
||||
{
|
||||
SConfig& config = SConfig::GetInstance();
|
||||
|
||||
if (auto& ppc_symbol_db = system.GetPPCSymbolDB(); !ppc_symbol_db.IsEmpty())
|
||||
{
|
||||
ppc_symbol_db.Clear();
|
||||
Host_PPCSymbolsChanged();
|
||||
}
|
||||
|
||||
// PAL Wii uses NTSC framerate and linecount in 60Hz modes
|
||||
system.GetVideoInterface().Preset(DiscIO::IsNTSC(config.m_region) ||
|
||||
(system.IsWii() && Config::Get(Config::SYSCONF_PAL60)));
|
||||
@ -591,11 +572,18 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard,
|
||||
|
||||
const std::string filename = PathToFileName(executable.path);
|
||||
|
||||
if (executable.reader->LoadSymbols(guard, system.GetPPCSymbolDB(), filename))
|
||||
auto& ppc_symbol_db = system.GetPPCSymbolDB();
|
||||
bool symbols_changed = ppc_symbol_db.Clear();
|
||||
|
||||
if (executable.reader->LoadSymbols(guard, ppc_symbol_db, filename))
|
||||
{
|
||||
Host_PPCSymbolsChanged();
|
||||
symbols_changed = true;
|
||||
HLE::PatchFunctions(system);
|
||||
}
|
||||
|
||||
if (symbols_changed)
|
||||
Host_PPCSymbolsChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -159,17 +159,6 @@ public:
|
||||
static bool BootUp(Core::System& system, const Core::CPUThreadGuard& guard,
|
||||
std::unique_ptr<BootParameters> boot);
|
||||
|
||||
// Tries to find a map file for the current game by looking first in the
|
||||
// local user directory, then in the shared user directory.
|
||||
//
|
||||
// If existing_map_file is not nullptr and a map file exists, it is set to the
|
||||
// path to the existing map file.
|
||||
//
|
||||
// If writable_map_file is not nullptr, it is set to the path to where a map
|
||||
// file should be saved.
|
||||
//
|
||||
// Returns true if a map file exists, false if none could be found.
|
||||
static bool LoadMapFromFilename(const Core::CPUThreadGuard& guard, PPCSymbolDB& ppc_symbol_db);
|
||||
|
||||
private:
|
||||
static bool DVDRead(Core::System& system, const DiscIO::VolumeDisc& disc, u64 dvd_offset,
|
||||
|
@ -271,12 +271,9 @@ void SConfig::OnTitleDirectlyBooted(const Core::CPUThreadGuard& guard)
|
||||
return;
|
||||
|
||||
auto& ppc_symbol_db = system.GetPPCSymbolDB();
|
||||
if (!ppc_symbol_db.IsEmpty())
|
||||
{
|
||||
ppc_symbol_db.Clear();
|
||||
|
||||
if (ppc_symbol_db.LoadMapOnBoot(guard))
|
||||
Host_PPCSymbolsChanged();
|
||||
}
|
||||
CBoot::LoadMapFromFilename(guard, ppc_symbol_db);
|
||||
HLE::Reload(system);
|
||||
|
||||
PatchEngine::Reload(system);
|
||||
|
@ -71,18 +71,18 @@ bool Load(Core::System& system)
|
||||
auto& ppc_symbol_db = power_pc.GetSymbolDB();
|
||||
|
||||
// Load symbols for the IPL if they exist.
|
||||
if (!ppc_symbol_db.IsEmpty())
|
||||
{
|
||||
ppc_symbol_db.Clear();
|
||||
Host_PPCSymbolsChanged();
|
||||
}
|
||||
bool symbols_changed = ppc_symbol_db.Clear();
|
||||
|
||||
if (ppc_symbol_db.LoadMap(guard, File::GetUserPath(D_MAPS_IDX) + "mios-ipl.map"))
|
||||
{
|
||||
::HLE::Clear();
|
||||
::HLE::PatchFunctions(system);
|
||||
Host_PPCSymbolsChanged();
|
||||
symbols_changed = true;
|
||||
}
|
||||
|
||||
if (symbols_changed)
|
||||
Host_PPCSymbolsChanged();
|
||||
|
||||
const PowerPC::CoreMode core_mode = power_pc.GetMode();
|
||||
power_pc.SetMode(PowerPC::CoreMode::Interpreter);
|
||||
|
||||
|
@ -301,6 +301,25 @@ bool PPCSymbolDB::FindMapFile(std::string* existing_map_file, std::string* writa
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PPCSymbolDB::LoadMapOnBoot(const Core::CPUThreadGuard& guard)
|
||||
{
|
||||
std::string existing_map_file;
|
||||
if (!PPCSymbolDB::FindMapFile(&existing_map_file, nullptr))
|
||||
return Clear();
|
||||
|
||||
// If the map is already loaded (such as restarting the same game), skip reloading.
|
||||
if (!IsEmpty() && existing_map_file == m_map_name)
|
||||
return false;
|
||||
|
||||
// Load map into cleared m_functions.
|
||||
bool changed = Clear();
|
||||
|
||||
if (!LoadMap(guard, existing_map_file))
|
||||
return changed;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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
|
||||
@ -554,6 +573,8 @@ bool PPCSymbolDB::LoadMap(const Core::CPUThreadGuard& guard, const std::string&
|
||||
}
|
||||
}
|
||||
|
||||
m_map_name = filename;
|
||||
|
||||
Index();
|
||||
DetermineNoteLayers();
|
||||
NOTICE_LOG_FMT(SYMBOLS, "{} symbols loaded, {} symbols ignored.", good_count, bad_count);
|
||||
|
@ -37,6 +37,8 @@ public:
|
||||
std::string_view GetDescription(u32 addr);
|
||||
|
||||
void FillInCallers();
|
||||
|
||||
bool LoadMapOnBoot(const Core::CPUThreadGuard& guard);
|
||||
bool LoadMap(const Core::CPUThreadGuard& guard, const std::string& filename, bool bad = false);
|
||||
bool SaveSymbolMap(const std::string& filename) const;
|
||||
bool SaveCodeMap(const Core::CPUThreadGuard& guard, const std::string& filename) const;
|
||||
|
Reference in New Issue
Block a user