Reload companion ELF debug info after a savestate load too

Modules are torn down and re-registered from PSPModule::DoState when a state is
loaded, which takes their symbols and line info with them. That path read the
per-module .ppsym file and nothing else, so coming back from a savestate lost
everything the companion ELF had contributed - every function back to
z_un_<address>, and no line numbers at all - with no way to get it back short of
rebooting the game.

It reads the companion again now, on the same terms as the initial load:
unconditionally, since the file is still sitting next to the game and only the
.ppsym half was ever meant to depend on the setting.

Costs a re-read and re-parse of the companion on every state load for games that
have one (CrossCraft: 3734 symbols and 98383 line rows), which is the price of
not silently losing them.

Line info that came from the main ELF rather than a companion still doesn't
survive a state load - those bytes aren't around at that point. Nothing to do
about that here, and it doesn't apply to the EBOOT case, where the companion is
the only source anyway.

pspautotests 314/314, UnitTest 55/55.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
This commit is contained in:
Henrik Rydgård
2026-08-18 14:07:57 +02:00
co-authored by Claude Opus 5
parent a6dd949df4
commit 4ffbe80d76
+4
View File
@@ -309,6 +309,10 @@ void PSPModule::DoState(PointerWrap &p) {
truncate_cpy(moduleName, nm.name);
if (memoryBlockAddr != 0) {
g_symbolMap->AddModule(moduleName, memoryBlockAddr, memoryBlockSize, crc);
// Loading a state tears the old module down and re-registers it here, which takes its
// symbols and line info with it. The companion ELF is still sitting next to the game,
// so read it again rather than coming back from a savestate with none.
LoadCompanionElfDebugInfo(PSP_CoreParameter().fileToStart, memoryBlockAddr, memoryBlockSize);
if (g_Config.bAutoSaveLoadSymbols) {
int idx = g_symbolMap->GetModuleIndexByName(moduleName);
if (idx > 0) {