Skip to content

Commit

Permalink
Qt/Debugger: Don't move entire list if it's not needed
Browse files Browse the repository at this point in the history
With 4 buffer spaces at the bottom.
  • Loading branch information
VelocityRa committed Mar 31, 2020
1 parent 7f69e1c commit 6d96109
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions rpcs3/rpcs3qt/debugger_list.cpp
Expand Up @@ -58,22 +58,31 @@ void debugger_list::ShowAddress(u32 addr)
return m_breakpoint_handler->HasBreakpoint(pc);
};

if (xgui_settings->GetValue(gui::d_centerPC).toBool())
{
m_pc = GetCenteredAddress(addr);
}
else
const bool center_pc = xgui_settings->GetValue(gui::d_centerPC).toBool();

// How many spaces addr can move down without us needing to move the entire view
const u32 addr_margin = (m_item_count / (center_pc ? 2 : 1) - 4); // 4 is just a buffer of 4 spaces at the bottom

if (s32(addr) - m_pc > addr_margin * 4) // 4 is the number of bytes in each instruction
{
m_pc = addr;
if (center_pc)
{
m_pc = GetCenteredAddress(addr);
}
else
{
m_pc = addr;
}
}

const auto cpu = this->cpu.lock();

if (!cpu)
{
for (uint i = 0; i < m_item_count; ++i, m_pc += 4)
u32 pc = m_pc;
for (uint i = 0; i < m_item_count; ++i, pc += 4)
{
item(i)->setText(qstr(fmt::format(" [%08x] illegal address", m_pc)));
item(i)->setText(qstr(fmt::format(" [%08x] illegal address", pc)));
}
}
else
Expand All @@ -83,25 +92,27 @@ void debugger_list::ShowAddress(u32 addr)
const u32 address_limits = (is_spu ? 0x3fffc : ~3);
m_pc &= address_limits;
m_disasm->offset = vm::get_super_ptr(cpu_offset);
for (uint i = 0, count = 4; i<m_item_count; ++i, m_pc = (m_pc + count) & address_limits)
u32 pc = m_pc;

for (uint i = 0, count = 4; i<m_item_count; ++i, pc = (pc + count) & address_limits)
{
if (!vm::check_addr(cpu_offset + m_pc, 4))
if (!vm::check_addr(cpu_offset + pc, 4))
{
item(i)->setText((IsBreakpoint(m_pc) ? ">> " : " ") + qstr(fmt::format("[%08x] illegal address", m_pc)));
item(i)->setText((IsBreakpoint(pc) ? ">> " : " ") + qstr(fmt::format("[%08x] illegal address", pc)));
count = 4;
continue;
}

count = m_disasm->disasm(m_disasm->dump_pc = m_pc);
count = m_disasm->disasm(m_disasm->dump_pc = pc);

item(i)->setText((IsBreakpoint(m_pc) ? ">> " : " ") + qstr(m_disasm->last_opcode));
item(i)->setText((IsBreakpoint(pc) ? ">> " : " ") + qstr(m_disasm->last_opcode));

if (cpu->is_paused() && m_pc == GetPc())
if (cpu->is_paused() && pc == GetPc())
{
item(i)->setForeground(m_text_color_pc);
item(i)->setBackground(m_color_pc);
}
else if (IsBreakpoint(m_pc))
else if (IsBreakpoint(pc))
{
item(i)->setForeground(m_text_color_bp);
item(i)->setBackground(m_color_bp);
Expand Down

0 comments on commit 6d96109

Please sign in to comment.