mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-20 15:25:38 +00:00
Qt: Cache CPU register values
That way they don't update while running.
This commit is contained in:
parent
4599109854
commit
ef4389cea8
|
@ -825,7 +825,6 @@ const std::array<CPU::DebuggerRegisterListEntry, CPU::NUM_DEBUGGER_REGISTER_LIST
|
||||||
{"hi", &CPU::g_state.regs.hi},
|
{"hi", &CPU::g_state.regs.hi},
|
||||||
{"lo", &CPU::g_state.regs.lo},
|
{"lo", &CPU::g_state.regs.lo},
|
||||||
{"pc", &CPU::g_state.pc},
|
{"pc", &CPU::g_state.pc},
|
||||||
{"npc", &CPU::g_state.npc},
|
|
||||||
|
|
||||||
{"COP0_SR", &CPU::g_state.cop0_regs.sr.bits},
|
{"COP0_SR", &CPU::g_state.cop0_regs.sr.bits},
|
||||||
{"COP0_CAUSE", &CPU::g_state.cop0_regs.cause.bits},
|
{"COP0_CAUSE", &CPU::g_state.cop0_regs.cause.bits},
|
||||||
|
|
|
@ -227,7 +227,7 @@ struct DebuggerRegisterListEntry
|
||||||
u32* value_ptr;
|
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;
|
extern const std::array<DebuggerRegisterListEntry, NUM_DEBUGGER_REGISTER_LIST_ENTRIES> g_debugger_register_list;
|
||||||
|
|
||||||
} // namespace CPU
|
} // namespace CPU
|
||||||
|
|
|
@ -333,11 +333,11 @@ QVariant DebuggerRegistersModel::data(const QModelIndex& index, int role /*= Qt:
|
||||||
{
|
{
|
||||||
if (role == Qt::DisplayRole)
|
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)
|
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);
|
return QColor(255, 50, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -370,16 +370,19 @@ QVariant DebuggerRegistersModel::headerData(int section, Qt::Orientation orienta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerRegistersModel::invalidateView()
|
void DebuggerRegistersModel::updateValues()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
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();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerRegistersModel::saveCurrentValues()
|
void DebuggerRegistersModel::saveCurrentValues()
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < static_cast<u32>(CPU::Reg::count); i++)
|
m_old_reg_values = m_reg_values;
|
||||||
m_old_reg_values[i] = CPU::g_state.regs.r[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DebuggerStackModel::DebuggerStackModel(QObject* parent /*= nullptr*/) : QAbstractListModel(parent)
|
DebuggerStackModel::DebuggerStackModel(QObject* parent /*= nullptr*/) : QAbstractListModel(parent)
|
||||||
|
|
|
@ -64,11 +64,12 @@ public:
|
||||||
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
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;
|
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||||
|
|
||||||
void invalidateView();
|
void updateValues();
|
||||||
void saveCurrentValues();
|
void saveCurrentValues();
|
||||||
|
|
||||||
private:
|
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
|
class DebuggerStackModel : public QAbstractListModel
|
||||||
|
|
|
@ -66,7 +66,7 @@ void DebuggerWindow::onDebuggerMessageReported(const QString& message)
|
||||||
|
|
||||||
void DebuggerWindow::refreshAll()
|
void DebuggerWindow::refreshAll()
|
||||||
{
|
{
|
||||||
m_registers_model->invalidateView();
|
m_registers_model->updateValues();
|
||||||
m_stack_model->invalidateView();
|
m_stack_model->invalidateView();
|
||||||
m_ui.memoryView->repaint();
|
m_ui.memoryView->repaint();
|
||||||
|
|
||||||
|
@ -196,7 +196,6 @@ void DebuggerWindow::onStepIntoActionTriggered()
|
||||||
Assert(System::IsPaused());
|
Assert(System::IsPaused());
|
||||||
m_registers_model->saveCurrentValues();
|
m_registers_model->saveCurrentValues();
|
||||||
g_emu_thread->singleStepCPU();
|
g_emu_thread->singleStepCPU();
|
||||||
refreshAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerWindow::onStepOverActionTriggered()
|
void DebuggerWindow::onStepOverActionTriggered()
|
||||||
|
|
Loading…
Reference in a new issue