Skip to content

Commit

Permalink
DebugTools: Fix iterator invalidation issue when creating IRX symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoticgd committed Mar 12, 2024
1 parent dd6d739 commit 62b8cd8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pcsx2/IopBios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1063,26 +1063,31 @@ namespace R3000A
if (!source.success())
return;

// Destroy the old entry for this module if it exists.
// Enumerate the module symbols that already exist for this IRX
// module. Really there should only be one.
std::vector<ccc::ModuleHandle> existing_modules;
for (const auto& pair : database.modules.handles_from_name(modname))
{
const ccc::Module* existing_module = database.modules.symbol_from_handle(pair.second);
if (!existing_module || !existing_module->is_irx)
continue;

// Different major versions, we treat this one as a different module
// Different major versions, we treat this one as a different module.
if (existing_module->version_major != version_major)
continue;

// RegisterLibraryEntries will fail if the new minor ver is <= the old minor ver
// and the major version is the same
// and the major version is the same.
if (existing_module->version_minor >= version_minor)
return;

// Remove the old module and its export table
database.destroy_symbols_from_modules(existing_module->handle());
existing_modules.emplace_back(existing_module->handle());
}

// Destroy the old symbols for this IRX module if any exist.
for (ccc::ModuleHandle existing_module : existing_modules)
database.destroy_symbols_from_modules(existing_module);

ccc::Result<ccc::Module*> module_symbol = database.modules.create_symbol(modname, *source, nullptr);
if (!module_symbol.success())
return;
Expand All @@ -1097,7 +1102,7 @@ namespace R3000A
while (funcptr != 0)
{
const char* unqualified_name = irxImportFuncname(modname, index);

std::string qualified_name;
if (unqualified_name && unqualified_name[0] != '\0')
qualified_name = fmt::format("{}[{:02}]::{}", modname, index, unqualified_name);
Expand Down

0 comments on commit 62b8cd8

Please sign in to comment.