Show errors if module mapping fails

This commit is contained in:
momo5502
2025-01-05 09:42:14 +01:00
parent ac16b4a727
commit 5bfb1b06ee
3 changed files with 69 additions and 74 deletions

View File

@@ -68,7 +68,7 @@ module_manager::module_manager(emulator& emu)
mapped_module* module_manager::map_module(const std::filesystem::path& file, logger& logger)
{
const auto canonical_file = canonicalize_module_path(file);
auto canonical_file = canonicalize_module_path(file);
for (auto& mod : this->modules_)
{
@@ -78,18 +78,26 @@ mapped_module* module_manager::map_module(const std::filesystem::path& file, log
}
}
auto mod = map_module_from_file(*this->emu_, std::move(canonical_file));
if (!mod)
try
{
logger.error("Failed to map %s\n", file.generic_string().c_str());
auto mod = map_module_from_file(*this->emu_, std::move(canonical_file));
logger.log("Mapped %s at 0x%llX\n", mod.path.generic_string().c_str(), mod.image_base);
const auto image_base = mod.image_base;
const auto entry = this->modules_.try_emplace(image_base, std::move(mod));
return &entry.first->second;
}
catch (const std::exception& e)
{
logger.error("Failed to map %s: %s\n", file.generic_string().c_str(), e.what());
return nullptr;
}
catch (...)
{
logger.error("Failed to map %s: Unknown error\n", file.generic_string().c_str());
return nullptr;
}
logger.log("Mapped %s at 0x%llX\n", mod->path.generic_string().c_str(), mod->image_base);
const auto image_base = mod->image_base;
const auto entry = this->modules_.try_emplace(image_base, std::move(*mod));
return &entry.first->second;
}
void module_manager::serialize(utils::buffer_serializer& buffer) const