Skip to content

Commit

Permalink
PPUThread: String & hex previews for register pointers in register dump
Browse files Browse the repository at this point in the history
  • Loading branch information
VelocityRa committed Mar 31, 2020
1 parent 2e17f1e commit ad20eff
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions rpcs3/Emu/Cell/PPUThread.cpp
Expand Up @@ -384,7 +384,52 @@ std::string ppu_thread::dump_regs() const
{
std::string ret;

for (uint i = 0; i < 32; ++i) fmt::append(ret, "GPR[%d] = 0x%llx\n", i, gpr[i]);
for (uint i = 0; i < 32; ++i)
{
auto reg = gpr[i];

fmt::append(ret, "GPR[%-2d] = 0x%-8llx", i, reg);

const u32 max_str_len = 100;
const u32 hex_count = 10;

if (vm::check_addr(reg, max_str_len, vm::page_readable))
{
const u64 reg_ptr = vm::read64(reg);

if (vm::check_addr(reg_ptr, max_str_len, vm::page_readable))
{
reg = reg_ptr;
}

const auto gpr_buf = (char*)vm::base(reg);

bool is_long_string = true;
for(u32 buf_i = 0; buf_i < max_str_len; ++buf_i)
{
if (gpr_buf[buf_i] == 0)
{
is_long_string = false;
break;
}
}

if (!is_long_string && std::isprint(gpr_buf[0]) && std::isprint(gpr_buf[1]) && std::isprint(gpr_buf[2]))
{
fmt::append(ret, " -> \"%s\"", gpr_buf);
}
else
{
fmt::append(ret, " -> ");
for (u32 j = 0; j < hex_count; ++j)
{
fmt::append(ret, "%02x ", (u8)gpr_buf[j]);
}
}
}

fmt::append(ret, "\n");
}
for (uint i = 0; i < 32; ++i) fmt::append(ret, "FPR[%d] = %.6G\n", i, fpr[i]);
for (uint i = 0; i < 32; ++i) fmt::append(ret, "VR[%d] = %s [x: %g y: %g z: %g w: %g]\n", i, vr[i], vr[i]._f[3], vr[i]._f[2], vr[i]._f[1], vr[i]._f[0]);

Expand Down Expand Up @@ -616,7 +661,7 @@ void ppu_thread::exec_task()
{
const auto exec_op = [this](u64 op)
{
return reinterpret_cast<func_t>(op & 0xffffffff)(*this, {static_cast<u32>(op >> 32)});
return reinterpret_cast<func_t>(op & 0xffffffff)(*this, { static_cast<u32>(op >> 32) });
};

if (cia % 8 || state) [[unlikely]]
Expand Down

0 comments on commit ad20eff

Please sign in to comment.