1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Add origin PRX names for log messages

This commit is contained in:
Eladash 2022-10-02 12:59:41 +03:00 committed by Ivan
parent 50e1e6596e
commit af8c871411
2 changed files with 81 additions and 0 deletions

View File

@ -1071,6 +1071,77 @@ void try_spawn_ppu_if_exclusive_program(const ppu_module& m)
}
}
struct prx_names_table
{
shared_mutex mutex;
std::set<std::string, std::less<>> registered;
atomic_t<const char*> lut[0x1000'0000 / 0x1'0000]{};
SAVESTATE_INIT_POS(4.1); // Dependency on lv2_obj
prx_names_table() noexcept
{
idm::select<lv2_obj, lv2_prx>([this](u32, lv2_prx& prx)
{
install(prx.name, prx);
});
}
void install(std::string_view name, lv2_prx& prx)
{
if (name.empty())
{
return;
}
if (name.ends_with(".sprx"sv) && name.size() > (".sprx"sv).size())
{
name = name.substr(0, name.size() - (".sprx"sv).size());
}
std::lock_guard lock(mutex);
const auto ptr = registered.emplace(name).first->c_str();
for (auto& seg : prx.segs)
{
if (!seg.size)
{
continue;
}
// Doesn't support addresses above 256MB because it wastes memory and is very unlikely (if somehow does occur increase it)
const u32 max0 = (seg.addr + seg.size - 1) >> 16;
const u32 max = std::min<u32>(std::size(lut), max0);
if (max0 > max)
{
ppu_loader.error("Skipping PRX name registeration: %s, max=0x%x", name, max0 << 16);
}
for (u32 i = seg.addr >> 16; i <= max; i++)
{
lut[i].release(ptr);
}
}
}
};
const char* get_prx_name_by_cia(u32 addr)
{
if (auto t = g_fxo->try_get<prx_names_table>())
{
addr >>= 16;
if (addr < std::size(t->lut))
{
return t->lut[addr];
}
}
return nullptr;
}
std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf, const std::string& path, s64 file_offset, utils::serial* ar)
{
if (elf != elf_error::ok)
@ -1364,6 +1435,9 @@ std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf, const std::stri
prx->path = path;
prx->offset = file_offset;
g_fxo->need<prx_names_table>();
g_fxo->get<prx_names_table>().install(prx->name, *prx);
sha1_finish(&sha, prx->sha1);
// Format patch name

View File

@ -1953,6 +1953,13 @@ void ppu_thread::fast_call(u32 addr, u64 rtoc)
return fmt::format("PPU[0x%x] Thread (%s) [HLE:0x%08x, LR:0x%08x]", _this->id, *name_cache.get(), cia, _this->lr);
}
extern const char* get_prx_name_by_cia(u32 addr);
if (auto name = get_prx_name_by_cia(cia))
{
return fmt::format("PPU[0x%x] Thread (%s) [%s: 0x%08x]", _this->id, *name_cache.get(), name, cia);
}
return fmt::format("PPU[0x%x] Thread (%s) [0x%08x]", _this->id, *name_cache.get(), cia);
};