mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-09-24 18:29:02 +00:00
PPU debugger: Implement function names at the starting instruction
This commit is contained in:
parent
904ec44a8c
commit
b087d79a08
2 changed files with 64 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
|||
#include "Emu/IdManager.h"
|
||||
|
||||
const ppu_decoder<PPUDisAsm> s_ppu_disasm;
|
||||
extern const std::unordered_map<u32, std::string_view>& get_exported_function_names_as_addr_indexed_map();
|
||||
|
||||
u32 PPUDisAsm::disasm(u32 pc)
|
||||
{
|
||||
|
@ -12,6 +13,15 @@ u32 PPUDisAsm::disasm(u32 pc)
|
|||
std::memcpy(&op, m_offset + pc, 4);
|
||||
m_op = op;
|
||||
(this->*(s_ppu_disasm.decode(m_op)))({ m_op });
|
||||
|
||||
const auto& map = get_exported_function_names_as_addr_indexed_map();
|
||||
|
||||
if (auto it = map.find(pc); it != map.end())
|
||||
{
|
||||
last_opcode += " #";
|
||||
last_opcode += it->second;
|
||||
}
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
|
|
@ -307,7 +307,7 @@ static void ppu_initialize_modules(ppu_linkage_info* link)
|
|||
|
||||
if (is_first)
|
||||
{
|
||||
g_ppu_function_names[function.second.index] = fmt::format("%s.%s", _module->name, function.second.name);
|
||||
g_ppu_function_names[function.second.index] = fmt::format("%s:%s", function.second.name, _module->name);
|
||||
}
|
||||
|
||||
if ((function.second.flags & MFF_HIDDEN) == 0)
|
||||
|
@ -368,6 +368,59 @@ static void ppu_initialize_modules(ppu_linkage_info* link)
|
|||
}
|
||||
}
|
||||
|
||||
// For the debugger (g_ppu_function_names shouldn't change, string_view should suffice)
|
||||
extern const std::unordered_map<u32, std::string_view>& get_exported_function_names_as_addr_indexed_map()
|
||||
{
|
||||
static std::unordered_map<u32, std::string_view> res;
|
||||
static u64 update_time = 0;
|
||||
|
||||
const auto link = g_fxo->try_get<ppu_linkage_info>();
|
||||
const auto hle_funcs = g_fxo->try_get<ppu_function_manager>();
|
||||
|
||||
if (!link || !hle_funcs)
|
||||
{
|
||||
res.clear();
|
||||
return res;
|
||||
}
|
||||
|
||||
const u64 current_time = get_system_time();
|
||||
|
||||
// Update list every >=0.1 seconds
|
||||
if (current_time - update_time < 100'000)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
update_time = current_time;
|
||||
|
||||
res.clear();
|
||||
res.reserve(ppu_module_manager::get().size());
|
||||
|
||||
for (auto& pair : ppu_module_manager::get())
|
||||
{
|
||||
const auto _module = pair.second;
|
||||
auto& linkage = link->modules[_module->name];
|
||||
|
||||
for (auto& function : _module->functions)
|
||||
{
|
||||
auto& flink = linkage.functions[function.first];
|
||||
u32 addr = flink.export_addr;
|
||||
|
||||
if (vm::check_addr<4>(addr, vm::page_readable) && addr != hle_funcs->func_addr(function.second.index))
|
||||
{
|
||||
addr = vm::read32(addr);
|
||||
|
||||
if (!(addr % 4) && vm::check_addr<4>(addr, vm::page_executable))
|
||||
{
|
||||
res.try_emplace(addr, g_ppu_function_names[function.second.index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// Resolve relocations for variable/function linkage.
|
||||
static void ppu_patch_refs(std::vector<ppu_reloc>* out_relocs, u32 fref, u32 faddr)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue