Add memory contents to "Addr=" string in debugger

Tweaks the format of the addr= string in the debugger/trace so that it includes the memory contents.
It will also take the 2nd character of the opcode and if it's b or h it will size it accordingly.
so
addr=800BC2D0
becomes
addr=800BC2D0[00000000]  or addr=800BC2D0[0000]  or addr=800BC2D0[00]

This change amongst other things will facilitate a widescreen cheat scanner, that will take a lot of the work away from making widescreen cheats.
This commit is contained in:
PugsyMAME 2024-05-26 14:39:15 +01:00 committed by Stenzek
parent ed5a99066f
commit d372609bdc
No known key found for this signature in database

View file

@ -434,8 +434,35 @@ void CPU::FormatComment(SmallStringBase* dest, const Instruction inst, u32 pc, c
else if (std::strncmp(str, "offsetrs", 8) == 0)
{
const s32 offset = static_cast<s32>(inst.i.imm_sext32());
dest->append_format("{}addr={:08X}", dest->empty() ? "" : ", ",
regs->r[static_cast<u8>(inst.i.rs.GetValue())] + offset);
const VirtualMemoryAddress address = (regs->r[static_cast<u8>(inst.i.rs.GetValue())] + offset);
if (!dest->empty())
dest->append_format(", ");
if (inst.op == InstructionOp::lb || inst.op == InstructionOp::lbu)
{
u8 data = 0;
CPU::SafeReadMemoryByte(address, &data);
dest->append_format("addr={:08X}[{:02X}]", address, data);
}
else if (inst.op == InstructionOp::lh || inst.op == InstructionOp::lhu)
{
u16 data = 0;
CPU::SafeReadMemoryHalfWord(address, &data);
dest->append_format("addr={:08X}[{:04X}]", address, data);
}
else if (inst.op == InstructionOp::lw || (inst.op >= InstructionOp::lwc0 && inst.op <= InstructionOp::lwc3) ||
inst.op == InstructionOp::lwl || inst.op == InstructionOp::lwr)
{
u32 data = 0;
CPU::SafeReadMemoryWord(address, &data);
dest->append_format("addr={:08X}[{:08X}]", address, data);
}
else
{
dest->append_format("addr={:08X}", address);
}
str += 8;
}
else if (std::strncmp(str, "jt", 2) == 0)