Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor debugger fixups #7932

Merged
merged 2 commits into from Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 25 additions & 14 deletions rpcs3/Emu/Cell/PPUThread.cpp
Expand Up @@ -372,10 +372,10 @@ extern bool ppu_patch(u32 addr, u32 value)

std::string ppu_thread::dump_all() const
{
std::string ret = cpu_thread::dump_misc() + '\n';

ret += dump_misc() + '\n';
ret += dump_regs() + '\n';
std::string ret = cpu_thread::dump_misc();
ret += '\n';
ret += dump_regs();
ret += '\n';
ret += dump_callstack();

return ret;
Expand All @@ -389,16 +389,16 @@ std::string ppu_thread::dump_regs() const
{
auto reg = gpr[i];

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

const u32 max_str_len = 32;
const u32 hex_count = 10;
const u32 hex_count = 8;

if (vm::check_addr(reg, max_str_len, vm::page_readable))
if (reg <= UINT32_MAX && vm::check_addr(static_cast<u32>(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))
if (reg_ptr <= UINT32_MAX && vm::check_addr(static_cast<u32>(reg_ptr), max_str_len, vm::page_readable))
{
reg = reg_ptr;
}
Expand All @@ -409,11 +409,11 @@ std::string ppu_thread::dump_regs() const

if (std::isprint(static_cast<u8>(buf_tmp[0])) && std::isprint(static_cast<u8>(buf_tmp[1])) && std::isprint(static_cast<u8>(buf_tmp[2])))
{
fmt::append(ret, " -> \"%s\"", buf_tmp.c_str());
fmt::append(ret, " -> \"%s\"", buf_tmp.c_str());
}
else
{
fmt::append(ret, " -> ");
fmt::append(ret, " -> ");

for (u32 j = 0; j < hex_count; ++j)
{
Expand All @@ -424,8 +424,16 @@ std::string ppu_thread::dump_regs() const

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]);

for (uint i = 0; i < 32; ++i)
{
fmt::append(ret, "f%d%s = %.6G\n", i, i <= 9 ? " " : "", fpr[i]);
}

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

fmt::append(ret, "CR = 0x%08x\n", cr.pack());
fmt::append(ret, "LR = 0x%llx\n", lr);
Expand Down Expand Up @@ -501,7 +509,9 @@ std::string ppu_thread::dump_misc() const
fmt::append(ret, "Priority: %d\n", +prio);
fmt::append(ret, "Stack: 0x%x..0x%x\n", stack_addr, stack_addr + stack_size - 1);
fmt::append(ret, "Joiner: %s\n", joiner.load());
fmt::append(ret, "Commands: %u\n", cmd_queue.size());

if (const auto size = cmd_queue.size())
fmt::append(ret, "Commands: %u\n", size);

const char* _func = current_function;

Expand All @@ -512,7 +522,8 @@ std::string ppu_thread::dump_misc() const
ret += '\n';

for (u32 i = 3; i <= 6; i++)
fmt::append(ret, " ** GPR[%d] = 0x%llx\n", i, syscall_args[i - 3]);
if (gpr[i] != syscall_args[i - 3])
fmt::append(ret, " ** r%d = 0x%llx\n", i, syscall_args[i - 3]);
}
else if (is_paused())
{
Expand Down
47 changes: 41 additions & 6 deletions rpcs3/Emu/Cell/SPUThread.cpp
Expand Up @@ -1011,9 +1011,8 @@ spu_imm_table_t::spu_imm_table_t()

std::string spu_thread::dump_all() const
{
std::string ret = cpu_thread::dump_misc() + '\n';

ret += dump_misc() + '\n';
std::string ret = cpu_thread::dump_misc();
ret += '\n';
ret += dump_regs();

return ret;
Expand All @@ -1025,9 +1024,19 @@ std::string spu_thread::dump_regs() const

for (u32 i = 0; i < 128; i++)
{
fmt::append(ret, "\nGPR[%d] = %s", i, gpr[i]);
fmt::append(ret, "r%d = %s\n", i, gpr[i]);
}

fmt::append(ret, "\nEvent Stat: 0x%x\n", +ch_event_stat);
fmt::append(ret, "Event Mask: 0x%x\n", +ch_event_mask);
fmt::append(ret, "Interrupts Enabled: %s\n", interrupts_enabled.load());
fmt::append(ret, "Inbound Mailbox: %s\n", ch_in_mbox);
fmt::append(ret, "Out Mailbox: %s\n", ch_out_mbox);
fmt::append(ret, "Out Interrupts Mailbox: %s\n", ch_out_intr_mbox);
fmt::append(ret, "SNR config: 0x%llx\n", snr_config);
fmt::append(ret, "SNR1: %s\n", ch_snr1);
fmt::append(ret, "SNR2: %s\n", ch_snr2);

return ret;
}

Expand All @@ -1045,7 +1054,7 @@ std::string spu_thread::dump_misc() const
{
std::string ret;

fmt::append(ret, "\nBlock Weight: %u (Retreats: %u)", block_counter, block_failure);
fmt::append(ret, "Block Weight: %u (Retreats: %u)", block_counter, block_failure);

if (g_cfg.core.spu_prof)
{
Expand Down Expand Up @@ -1074,7 +1083,7 @@ std::string spu_thread::dump_misc() const
}
else
{
fmt::append(ret, "\n[-]");
break;
}
}

Expand Down Expand Up @@ -3280,5 +3289,31 @@ void spu_thread::fast_call(u32 ls_addr)
gpr[1]._u32[3] = old_stack;
}

template <>
void fmt_class_string<spu_channel>::format(std::string& out, u64 arg)
{
const auto& ch = get_object(arg);

const u64 raw = ch.data.load();

if (raw & spu_channel::bit_count)
{
fmt::append(out, "0x%08x", static_cast<u32>(raw));
}
else
{
out += "empty";
}
}

template <>
void fmt_class_string<spu_channel_4_t>::format(std::string& out, u64 arg)
{
const auto& ch = get_object(arg);

// TODO
fmt::append(out, "count = %d", ch.get_count());
}

DECLARE(spu_thread::g_raw_spu_ctr){};
DECLARE(spu_thread::g_raw_spu_id){};
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/SPUThread.h
Expand Up @@ -337,9 +337,9 @@ struct spu_channel_4_t
});
}

u32 get_count()
u32 get_count() const
{
return values.raw().count;
return std::as_const(values).raw().count;
}

void set_values(u32 count, u32 value0, u32 value1 = 0, u32 value2 = 0, u32 value3 = 0)
Expand Down
8 changes: 4 additions & 4 deletions rpcs3/rpcs3qt/register_editor_dialog.cpp
Expand Up @@ -56,9 +56,9 @@ register_editor_dialog::register_editor_dialog(QWidget *parent, u32 _pc, const s
{
if (_cpu->id_type() == 1)
{
for (int i = 0; i < 32; i++) m_register_combo->addItem(qstr(fmt::format("GPR[%d]", i)));
for (int i = 0; i < 32; i++) m_register_combo->addItem(qstr(fmt::format("FPR[%d]", i)));
for (int i = 0; i < 32; i++) m_register_combo->addItem(qstr(fmt::format("VR[%d]", i)));
for (int i = 0; i < 32; i++) m_register_combo->addItem(qstr(fmt::format("r%d", i)));
for (int i = 0; i < 32; i++) m_register_combo->addItem(qstr(fmt::format("f%d", i)));
for (int i = 0; i < 32; i++) m_register_combo->addItem(qstr(fmt::format("v%d", i)));
m_register_combo->addItem("CR");
m_register_combo->addItem("LR");
m_register_combo->addItem("CTR");
Expand All @@ -67,7 +67,7 @@ register_editor_dialog::register_editor_dialog(QWidget *parent, u32 _pc, const s
}
else
{
for (int i = 0; i < 128; i++) m_register_combo->addItem(qstr(fmt::format("GPR[%d]", i)));
for (int i = 0; i < 128; i++) m_register_combo->addItem(qstr(fmt::format("r%d", i)));
}
}

Expand Down
6 changes: 6 additions & 0 deletions rpcs3/util/atomic.hpp
Expand Up @@ -707,6 +707,12 @@ class atomic_t
return m_data;
}

// Unsafe direct access
const type& raw() const
{
return m_data;
}

// Atomically compare data with cmp, replace with exch if equal, return previous data value anyway
type compare_and_swap(const type& cmp, const type& exch)
{
Expand Down