From 9fcbad326ac8d5575b155624b5e5955006fe947e Mon Sep 17 00:00:00 2001 From: Eladash Date: Sat, 27 Jun 2020 13:45:51 +0300 Subject: [PATCH] debugger: Fix registers editor --- rpcs3/rpcs3qt/register_editor_dialog.cpp | 36 ++++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/rpcs3/rpcs3qt/register_editor_dialog.cpp b/rpcs3/rpcs3qt/register_editor_dialog.cpp index adaced70b8..6069a1b864 100644 --- a/rpcs3/rpcs3qt/register_editor_dialog.cpp +++ b/rpcs3/rpcs3qt/register_editor_dialog.cpp @@ -110,13 +110,13 @@ void register_editor_dialog::updateRegister(const QString& text) if (first_brk != umax) { long reg_index = std::atol(reg.substr(first_brk + 1, reg.length() - first_brk - 2).c_str()); - if (reg.starts_with("GPR")) str = fmt::format("%016llx", ppu.gpr[reg_index]); - if (reg.starts_with("FPR")) str = fmt::format("%016llx", ppu.fpr[reg_index]); - if (reg.starts_with("VR")) str = fmt::format("%016llx%016llx", ppu.vr[reg_index]._u64[1], ppu.vr[reg_index]._u64[0]); + if (reg.starts_with("r")) str = fmt::format("%016llx", ppu.gpr[reg_index]); + else if (reg.starts_with("f")) str = fmt::format("%016llx", ppu.fpr[reg_index]); + else if (reg.starts_with("v")) str = fmt::format("%016llx%016llx", ppu.vr[reg_index]._u64[1], ppu.vr[reg_index]._u64[0]); } - if (reg == "CR") str = fmt::format("%08x", ppu.cr.pack()); - if (reg == "LR") str = fmt::format("%016llx", ppu.lr); - if (reg == "CTR") str = fmt::format("%016llx", ppu.ctr); + else if (reg == "CR") str = fmt::format("%08x", ppu.cr.pack()); + else if (reg == "LR") str = fmt::format("%016llx", ppu.lr); + else if (reg == "CTR") str = fmt::format("%016llx", ppu.ctr); } else { @@ -127,7 +127,7 @@ void register_editor_dialog::updateRegister(const QString& text) { long reg_index; reg_index = atol(reg.substr(first_brk + 1, reg.length() - 2).c_str()); - if (reg.starts_with("GPR")) str = fmt::format("%016llx%016llx", spu.gpr[reg_index]._u64[1], spu.gpr[reg_index]._u64[0]); + if (reg.starts_with("r")) str = fmt::format("%016llx%016llx", spu.gpr[reg_index]._u64[1], spu.gpr[reg_index]._u64[0]); } } @@ -145,21 +145,21 @@ void register_editor_dialog::OnOkay(const std::shared_ptr& _cpu) { auto& ppu = *static_cast(cpu); - while (value.length() < 32) value = "0" + value; + if (auto len = value.length(); len < 32) value.insert(0, 32 - len, '0'); const auto first_brk = reg.find('['); // TODO: handle invalid conversions { if (first_brk != umax) { const long reg_index = std::atol(reg.substr(first_brk + 1, reg.length() - first_brk - 2).c_str()); - if (reg.starts_with("GPR") || reg.starts_with("FPR")) + if (reg.starts_with("r") || reg.starts_with("f")) { const ullong reg_value = std::stoull(value.substr(16, 31), 0, 16); - if (reg.starts_with("GPR")) ppu.gpr[reg_index] = static_cast(reg_value); - if (reg.starts_with("FPR")) ppu.fpr[reg_index] = std::bit_cast(reg_value); + if (reg.starts_with("r")) ppu.gpr[reg_index] = static_cast(reg_value); + else if (reg.starts_with("f")) ppu.fpr[reg_index] = std::bit_cast(reg_value); return; } - if (reg.starts_with("VR")) + else if (reg.starts_with("v")) { const ullong reg_value0 = std::stoull(value.substr(16, 31), 0, 16); const ullong reg_value1 = std::stoull(value.substr(0, 15), 0, 16); @@ -168,17 +168,17 @@ void register_editor_dialog::OnOkay(const std::shared_ptr& _cpu) return; } } - if (reg == "LR" || reg == "CTR") + else if (reg == "LR" || reg == "CTR") { const ullong reg_value = std::stoull(value.substr(16, 31), 0, 16); if (reg == "LR") ppu.lr = static_cast(reg_value); - if (reg == "CTR") ppu.ctr = static_cast(reg_value); + else if (reg == "CTR") ppu.ctr = static_cast(reg_value); return; } - if (reg == "CR") + else if (reg == "CR") { const ullong reg_value = std::stoull(value.substr(24, 31), 0, 16); - if (reg == "CR") ppu.cr.unpack(static_cast(reg_value)); + ppu.cr.unpack(static_cast(reg_value)); return; } } @@ -187,14 +187,14 @@ void register_editor_dialog::OnOkay(const std::shared_ptr& _cpu) { auto& spu = *static_cast(cpu); - while (value.length() < 32) value = "0" + value; + if (auto len = value.length(); len < 32) value.insert(0, 32 - len, '0'); const auto first_brk = reg.find('['); // TODO: handle invalid conversions { if (first_brk != umax) { const long reg_index = std::atol(reg.substr(first_brk + 1, reg.length() - 2).c_str()); - if (reg.starts_with("GPR")) + if (reg.starts_with("r")) { const ullong reg_value0 = std::stoull(value.substr(16, 31), 0, 16); const ullong reg_value1 = std::stoull(value.substr(0, 15), 0, 16);