Debug fixes

This commit is contained in:
Eladash 2023-07-09 08:45:15 +03:00 committed by Elad Ashkenazi
parent 050b8fa7df
commit 17d8f2884e
3 changed files with 31 additions and 9 deletions

View File

@ -110,11 +110,7 @@ std::string dump_useful_thread_info()
if (auto cpu = get_current_cpu_thread())
{
// Wrap it to disable some internal exceptions when printing (not thrown on main thread)
Emu.BlockingCallFromMainThread([&]()
{
cpu->dump_all(result);
});
cpu->dump_all(result);
}
return result;

View File

@ -133,14 +133,26 @@ void fmt_class_string<typename ppu_thread::call_history_t>::format(std::string&
PPUDisAsm dis_asm(cpu_disasm_mode::normal, vm::g_sudo_addr);
for (u64 count = 0, idx = history.index - 1; idx != umax && count < ppu_thread::call_history_max_size; count++, idx--)
for (u64 count = 0, idx = history.index - 1; idx != umax && count < history.data.size(); count++, idx--)
{
const u32 pc = history.data[idx % ppu_thread::call_history_max_size];
const u32 pc = history.data[idx % history.data.size()];
dis_asm.disasm(pc);
fmt::append(out, "\n(%u) 0x%08x: %s", count, pc, dis_asm.last_opcode);
}
}
template <>
void fmt_class_string<typename ppu_thread::syscall_history_t>::format(std::string& out, u64 arg)
{
const auto& history = get_object(arg);
for (u64 count = 0, idx = history.index - 1; idx != umax && count < history.data.size(); count++, idx--)
{
const auto& entry = history.data[idx % history.data.size()];
fmt::append(out, "\n(%u) 0x%08x: %s, 0x%x, r3=0x%x, r4=0x%x, r5=0x%x, r6=0x%x", count, entry.cia, entry.func_name, entry.error, entry.args[0], entry.args[1], entry.args[2], entry.args[3]);
}
}
extern const ppu_decoder<ppu_itype> g_ppu_itype{};
extern const ppu_decoder<ppu_iname> g_ppu_iname{};
@ -1601,6 +1613,15 @@ void ppu_thread::dump_all(std::string& ret) const
fmt::append(ret, "%s", call_history);
}
if (syscall_history.data.size() > 1)
{
ret +=
"\nHLE/LV2 History:"
"\n================";
fmt::append(ret, "%s", syscall_history);
}
}
extern thread_local std::string(*g_tls_log_prefix)();

View File

@ -63,9 +63,14 @@ void ppu_thread_exit(ppu_thread& ppu, ppu_opcode_t, be_t<u32>*, struct ppu_intrp
if (ppu.call_history.index)
{
std::string str = fmt::format("%s", ppu.call_history);
ppu_log.notice("Calling history: %s", ppu.call_history);
ppu.call_history.index = 0;
ppu_log.notice("Calling history: %s", str);
}
if (ppu.syscall_history.index)
{
ppu_log.notice("HLE/LV2 history: %s", ppu.syscall_history);
ppu.syscall_history.index = 0;
}
}