Qt: Cache CPU register values

That way they don't update while running.
This commit is contained in:
Stenzek 2024-02-27 22:38:02 +10:00
parent 4599109854
commit ef4389cea8
No known key found for this signature in database
5 changed files with 13 additions and 11 deletions

View file

@ -825,7 +825,6 @@ const std::array<CPU::DebuggerRegisterListEntry, CPU::NUM_DEBUGGER_REGISTER_LIST
{"hi", &CPU::g_state.regs.hi},
{"lo", &CPU::g_state.regs.lo},
{"pc", &CPU::g_state.pc},
{"npc", &CPU::g_state.npc},
{"COP0_SR", &CPU::g_state.cop0_regs.sr.bits},
{"COP0_CAUSE", &CPU::g_state.cop0_regs.cause.bits},

View file

@ -227,7 +227,7 @@ struct DebuggerRegisterListEntry
u32* value_ptr;
};
static constexpr u32 NUM_DEBUGGER_REGISTER_LIST_ENTRIES = 104;
static constexpr u32 NUM_DEBUGGER_REGISTER_LIST_ENTRIES = 103;
extern const std::array<DebuggerRegisterListEntry, NUM_DEBUGGER_REGISTER_LIST_ENTRIES> g_debugger_register_list;
} // namespace CPU

View file

@ -333,11 +333,11 @@ QVariant DebuggerRegistersModel::data(const QModelIndex& index, int role /*= Qt:
{
if (role == Qt::DisplayRole)
{
return QString::asprintf("0x%08X", *CPU::g_debugger_register_list[reg_index].value_ptr);
return QString::asprintf("0x%08X", m_reg_values[reg_index]);
}
else if (role == Qt::ForegroundRole)
{
if (*CPU::g_debugger_register_list[reg_index].value_ptr != m_old_reg_values[reg_index])
if (m_reg_values[reg_index] != m_old_reg_values[reg_index])
return QColor(255, 50, 50);
}
}
@ -370,16 +370,19 @@ QVariant DebuggerRegistersModel::headerData(int section, Qt::Orientation orienta
}
}
void DebuggerRegistersModel::invalidateView()
void DebuggerRegistersModel::updateValues()
{
beginResetModel();
for (u32 i = 0; i < CPU::NUM_DEBUGGER_REGISTER_LIST_ENTRIES; i++)
m_reg_values[i] = *CPU::g_debugger_register_list[i].value_ptr;
endResetModel();
}
void DebuggerRegistersModel::saveCurrentValues()
{
for (u32 i = 0; i < static_cast<u32>(CPU::Reg::count); i++)
m_old_reg_values[i] = CPU::g_state.regs.r[i];
m_old_reg_values = m_reg_values;
}
DebuggerStackModel::DebuggerStackModel(QObject* parent /*= nullptr*/) : QAbstractListModel(parent)

View file

@ -64,11 +64,12 @@ public:
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
void invalidateView();
void updateValues();
void saveCurrentValues();
private:
u32 m_old_reg_values[CPU::NUM_DEBUGGER_REGISTER_LIST_ENTRIES] = {};
std::array<u32 ,CPU::NUM_DEBUGGER_REGISTER_LIST_ENTRIES> m_reg_values = {};
std::array<u32, CPU::NUM_DEBUGGER_REGISTER_LIST_ENTRIES> m_old_reg_values = {};
};
class DebuggerStackModel : public QAbstractListModel

View file

@ -66,7 +66,7 @@ void DebuggerWindow::onDebuggerMessageReported(const QString& message)
void DebuggerWindow::refreshAll()
{
m_registers_model->invalidateView();
m_registers_model->updateValues();
m_stack_model->invalidateView();
m_ui.memoryView->repaint();
@ -196,7 +196,6 @@ void DebuggerWindow::onStepIntoActionTriggered()
Assert(System::IsPaused());
m_registers_model->saveCurrentValues();
g_emu_thread->singleStepCPU();
refreshAll();
}
void DebuggerWindow::onStepOverActionTriggered()