diff options
Diffstat (limited to '')
-rw-r--r-- | src/citra_qt/debugger/registers.cpp | 212 | ||||
-rw-r--r-- | src/citra_qt/debugger/registers.h | 12 | ||||
-rw-r--r-- | src/core/arm/arm_interface.h | 28 | ||||
-rw-r--r-- | src/core/arm/dyncom/arm_dyncom.cpp | 16 | ||||
-rw-r--r-- | src/core/arm/dyncom/arm_dyncom.h | 4 | ||||
-rw-r--r-- | src/core/arm/skyeye_common/arm_regformat.h | 2 |
6 files changed, 225 insertions, 49 deletions
diff --git a/src/citra_qt/debugger/registers.cpp b/src/citra_qt/debugger/registers.cpp index 5527a2afd..4174b3945 100644 --- a/src/citra_qt/debugger/registers.cpp +++ b/src/citra_qt/debugger/registers.cpp @@ -11,32 +11,23 @@ RegistersWidget::RegistersWidget(QWidget* parent) : QDockWidget(parent) { cpu_regs_ui.setupUi(this); tree = cpu_regs_ui.treeWidget; - tree->addTopLevelItem(registers = new QTreeWidgetItem(QStringList("Registers"))); - tree->addTopLevelItem(CSPR = new QTreeWidgetItem(QStringList("CSPR"))); - - registers->setExpanded(true); - CSPR->setExpanded(true); + tree->addTopLevelItem(core_registers = new QTreeWidgetItem(QStringList(tr("Registers")))); + tree->addTopLevelItem(vfp_registers = new QTreeWidgetItem(QStringList(tr("VFP Registers")))); + tree->addTopLevelItem(vfp_system_registers = new QTreeWidgetItem(QStringList(tr("VFP System Registers")))); + tree->addTopLevelItem(cpsr = new QTreeWidgetItem(QStringList("CPSR"))); for (int i = 0; i < 16; ++i) { - QTreeWidgetItem* child = new QTreeWidgetItem(QStringList(QString("R[%1]").arg(i, 2, 10, QLatin1Char('0')))); - registers->addChild(child); + QTreeWidgetItem* child = new QTreeWidgetItem(QStringList(QString("R[%1]").arg(i))); + core_registers->addChild(child); + } + + for (int i = 0; i < 32; ++i) { + QTreeWidgetItem* child = new QTreeWidgetItem(QStringList(QString("S[%1]").arg(i))); + vfp_registers->addChild(child); } - CSPR->addChild(new QTreeWidgetItem(QStringList("M"))); - CSPR->addChild(new QTreeWidgetItem(QStringList("T"))); - CSPR->addChild(new QTreeWidgetItem(QStringList("F"))); - CSPR->addChild(new QTreeWidgetItem(QStringList("I"))); - CSPR->addChild(new QTreeWidgetItem(QStringList("A"))); - CSPR->addChild(new QTreeWidgetItem(QStringList("E"))); - CSPR->addChild(new QTreeWidgetItem(QStringList("IT"))); - CSPR->addChild(new QTreeWidgetItem(QStringList("GE"))); - CSPR->addChild(new QTreeWidgetItem(QStringList("DNM"))); - CSPR->addChild(new QTreeWidgetItem(QStringList("J"))); - CSPR->addChild(new QTreeWidgetItem(QStringList("Q"))); - CSPR->addChild(new QTreeWidgetItem(QStringList("V"))); - CSPR->addChild(new QTreeWidgetItem(QStringList("C"))); - CSPR->addChild(new QTreeWidgetItem(QStringList("Z"))); - CSPR->addChild(new QTreeWidgetItem(QStringList("N"))); + CreateCPSRChildren(); + CreateVFPSystemRegisterChildren(); setEnabled(false); } @@ -47,25 +38,14 @@ void RegistersWidget::OnDebugModeEntered() { if (app_core == nullptr) return; - for (int i = 0; i < 16; ++i) - registers->child(i)->setText(1, QString("0x%1").arg(app_core->GetReg(i), 8, 16, QLatin1Char('0'))); - - CSPR->setText(1, QString("0x%1").arg(app_core->GetCPSR(), 8, 16, QLatin1Char('0'))); - CSPR->child(0)->setText(1, QString("b%1").arg(app_core->GetCPSR() & 0x1F, 5, 2, QLatin1Char('0'))); // M - Mode - CSPR->child(1)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 5) & 0x1)); // T - State - CSPR->child(2)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 6) & 0x1)); // F - FIQ disable - CSPR->child(3)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 7) & 0x1)); // I - IRQ disable - CSPR->child(4)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 8) & 0x1)); // A - Imprecise abort - CSPR->child(5)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 9) & 0x1)); // E - Data endianess - CSPR->child(6)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 10) & 0x3F)); // IT - If-Then state (DNM) - CSPR->child(7)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 16) & 0xF)); // GE - Greater-than-or-Equal - CSPR->child(8)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 20) & 0xF)); // DNM - Do not modify - CSPR->child(9)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 24) & 0x1)); // J - Java state - CSPR->child(10)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 27) & 0x1)); // Q - Sticky overflow - CSPR->child(11)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 28) & 0x1)); // V - Overflow - CSPR->child(12)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 29) & 0x1)); // C - Carry/Borrow/Extend - CSPR->child(13)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 30) & 0x1)); // Z - Zero - CSPR->child(14)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 31) & 0x1)); // N - Negative/Less than + for (int i = 0; i < core_registers->childCount(); ++i) + core_registers->child(i)->setText(1, QString("0x%1").arg(app_core->GetReg(i), 8, 16, QLatin1Char('0'))); + + for (int i = 0; i < vfp_registers->childCount(); ++i) + vfp_registers->child(i)->setText(1, QString("0x%1").arg(app_core->GetVFPReg(i), 8, 16, QLatin1Char('0'))); + + UpdateCPSRValues(); + UpdateVFPSystemRegisterValues(); } void RegistersWidget::OnDebugModeLeft() { @@ -77,13 +57,153 @@ void RegistersWidget::OnEmulationStarting(EmuThread* emu_thread) { void RegistersWidget::OnEmulationStopping() { // Reset widget text - for (int i = 0; i < 16; ++i) - registers->child(i)->setText(1, QString("")); + for (int i = 0; i < core_registers->childCount(); ++i) + core_registers->child(i)->setText(1, QString("")); + + for (int i = 0; i < vfp_registers->childCount(); ++i) + vfp_registers->child(i)->setText(1, QString("")); + + for (int i = 0; i < cpsr->childCount(); ++i) + cpsr->child(i)->setText(1, QString("")); + + cpsr->setText(1, QString("")); + + // FPSCR + for (int i = 0; i < vfp_system_registers->child(0)->childCount(); ++i) + vfp_system_registers->child(0)->child(i)->setText(1, QString("")); - for (int i = 0; i < 15; ++i) - CSPR->child(i)->setText(1, QString("")); + // FPEXC + for (int i = 0; i < vfp_system_registers->child(1)->childCount(); ++i) + vfp_system_registers->child(1)->child(i)->setText(1, QString("")); - CSPR->setText(1, QString("")); + vfp_system_registers->child(0)->setText(1, QString("")); + vfp_system_registers->child(1)->setText(1, QString("")); + vfp_system_registers->child(2)->setText(1, QString("")); + vfp_system_registers->child(3)->setText(1, QString("")); setEnabled(false); } + +void RegistersWidget::CreateCPSRChildren() { + cpsr->addChild(new QTreeWidgetItem(QStringList("M"))); + cpsr->addChild(new QTreeWidgetItem(QStringList("T"))); + cpsr->addChild(new QTreeWidgetItem(QStringList("F"))); + cpsr->addChild(new QTreeWidgetItem(QStringList("I"))); + cpsr->addChild(new QTreeWidgetItem(QStringList("A"))); + cpsr->addChild(new QTreeWidgetItem(QStringList("E"))); + cpsr->addChild(new QTreeWidgetItem(QStringList("IT"))); + cpsr->addChild(new QTreeWidgetItem(QStringList("GE"))); + cpsr->addChild(new QTreeWidgetItem(QStringList("DNM"))); + cpsr->addChild(new QTreeWidgetItem(QStringList("J"))); + cpsr->addChild(new QTreeWidgetItem(QStringList("Q"))); + cpsr->addChild(new QTreeWidgetItem(QStringList("V"))); + cpsr->addChild(new QTreeWidgetItem(QStringList("C"))); + cpsr->addChild(new QTreeWidgetItem(QStringList("Z"))); + cpsr->addChild(new QTreeWidgetItem(QStringList("N"))); +} + +void RegistersWidget::UpdateCPSRValues() { + const u32 cpsr_val = Core::g_app_core->GetCPSR(); + + cpsr->setText(1, QString("0x%1").arg(cpsr_val, 8, 16, QLatin1Char('0'))); + cpsr->child(0)->setText(1, QString("b%1").arg(cpsr_val & 0x1F, 5, 2, QLatin1Char('0'))); // M - Mode + cpsr->child(1)->setText(1, QString::number((cpsr_val >> 5) & 1)); // T - State + cpsr->child(2)->setText(1, QString::number((cpsr_val >> 6) & 1)); // F - FIQ disable + cpsr->child(3)->setText(1, QString::number((cpsr_val >> 7) & 1)); // I - IRQ disable + cpsr->child(4)->setText(1, QString::number((cpsr_val >> 8) & 1)); // A - Imprecise abort + cpsr->child(5)->setText(1, QString::number((cpsr_val >> 9) & 1)); // E - Data endianess + cpsr->child(6)->setText(1, QString::number((cpsr_val >> 10) & 0x3F)); // IT - If-Then state (DNM) + cpsr->child(7)->setText(1, QString::number((cpsr_val >> 16) & 0xF)); // GE - Greater-than-or-Equal + cpsr->child(8)->setText(1, QString::number((cpsr_val >> 20) & 0xF)); // DNM - Do not modify + cpsr->child(9)->setText(1, QString::number((cpsr_val >> 24) & 1)); // J - Jazelle + cpsr->child(10)->setText(1, QString::number((cpsr_val >> 27) & 1)); // Q - Saturation + cpsr->child(11)->setText(1, QString::number((cpsr_val >> 28) & 1)); // V - Overflow + cpsr->child(12)->setText(1, QString::number((cpsr_val >> 29) & 1)); // C - Carry/Borrow/Extend + cpsr->child(13)->setText(1, QString::number((cpsr_val >> 30) & 1)); // Z - Zero + cpsr->child(14)->setText(1, QString::number((cpsr_val >> 31) & 1)); // N - Negative/Less than +} + +void RegistersWidget::CreateVFPSystemRegisterChildren() { + QTreeWidgetItem* const fpscr = new QTreeWidgetItem(QStringList("FPSCR")); + fpscr->addChild(new QTreeWidgetItem(QStringList("IOC"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("DZC"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("OFC"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("UFC"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("IXC"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("IDC"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("IOE"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("DZE"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("OFE"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("UFE"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("IXE"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("IDE"))); + fpscr->addChild(new QTreeWidgetItem(QStringList(tr("Vector Length")))); + fpscr->addChild(new QTreeWidgetItem(QStringList(tr("Vector Stride")))); + fpscr->addChild(new QTreeWidgetItem(QStringList(tr("Rounding Mode")))); + fpscr->addChild(new QTreeWidgetItem(QStringList("FZ"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("DN"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("V"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("C"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("Z"))); + fpscr->addChild(new QTreeWidgetItem(QStringList("N"))); + + QTreeWidgetItem* const fpexc = new QTreeWidgetItem(QStringList("FPEXC")); + fpexc->addChild(new QTreeWidgetItem(QStringList("IOC"))); + fpexc->addChild(new QTreeWidgetItem(QStringList("OFC"))); + fpexc->addChild(new QTreeWidgetItem(QStringList("UFC"))); + fpexc->addChild(new QTreeWidgetItem(QStringList("INV"))); + fpexc->addChild(new QTreeWidgetItem(QStringList(tr("Vector Iteration Count")))); + fpexc->addChild(new QTreeWidgetItem(QStringList("FP2V"))); + fpexc->addChild(new QTreeWidgetItem(QStringList("EN"))); + fpexc->addChild(new QTreeWidgetItem(QStringList("EX"))); + + vfp_system_registers->addChild(fpscr); + vfp_system_registers->addChild(fpexc); + vfp_system_registers->addChild(new QTreeWidgetItem(QStringList("FPINST"))); + vfp_system_registers->addChild(new QTreeWidgetItem(QStringList("FPINST2"))); +} + +void RegistersWidget::UpdateVFPSystemRegisterValues() { + const u32 fpscr_val = Core::g_app_core->GetVFPSystemReg(VFP_FPSCR); + const u32 fpexc_val = Core::g_app_core->GetVFPSystemReg(VFP_FPEXC); + const u32 fpinst_val = Core::g_app_core->GetVFPSystemReg(VFP_FPINST); + const u32 fpinst2_val = Core::g_app_core->GetVFPSystemReg(VFP_FPINST2); + + QTreeWidgetItem* const fpscr = vfp_system_registers->child(0); + fpscr->setText(1, QString("0x%1").arg(fpscr_val, 8, 16, QLatin1Char('0'))); + fpscr->child(0)->setText(1, QString::number(fpscr_val & 1)); + fpscr->child(1)->setText(1, QString::number((fpscr_val >> 1) & 1)); + fpscr->child(2)->setText(1, QString::number((fpscr_val >> 2) & 1)); + fpscr->child(3)->setText(1, QString::number((fpscr_val >> 3) & 1)); + fpscr->child(4)->setText(1, QString::number((fpscr_val >> 4) & 1)); + fpscr->child(5)->setText(1, QString::number((fpscr_val >> 7) & 1)); + fpscr->child(6)->setText(1, QString::number((fpscr_val >> 8) & 1)); + fpscr->child(7)->setText(1, QString::number((fpscr_val >> 9) & 1)); + fpscr->child(8)->setText(1, QString::number((fpscr_val >> 10) & 1)); + fpscr->child(9)->setText(1, QString::number((fpscr_val >> 11) & 1)); + fpscr->child(10)->setText(1, QString::number((fpscr_val >> 12) & 1)); + fpscr->child(11)->setText(1, QString::number((fpscr_val >> 15) & 1)); + fpscr->child(12)->setText(1, QString("b%1").arg((fpscr_val >> 16) & 7, 3, 2, QLatin1Char('0'))); + fpscr->child(13)->setText(1, QString("b%1").arg((fpscr_val >> 20) & 3, 2, 2, QLatin1Char('0'))); + fpscr->child(14)->setText(1, QString("b%1").arg((fpscr_val >> 22) & 3, 2, 2, QLatin1Char('0'))); + fpscr->child(15)->setText(1, QString::number((fpscr_val >> 24) & 1)); + fpscr->child(16)->setText(1, QString::number((fpscr_val >> 25) & 1)); + fpscr->child(17)->setText(1, QString::number((fpscr_val >> 28) & 1)); + fpscr->child(18)->setText(1, QString::number((fpscr_val >> 29) & 1)); + fpscr->child(19)->setText(1, QString::number((fpscr_val >> 30) & 1)); + fpscr->child(20)->setText(1, QString::number((fpscr_val >> 31) & 1)); + + QTreeWidgetItem* const fpexc = vfp_system_registers->child(1); + fpexc->setText(1, QString("0x%1").arg(fpexc_val, 8, 16, QLatin1Char('0'))); + fpexc->child(0)->setText(1, QString::number(fpexc_val & 1)); + fpexc->child(1)->setText(1, QString::number((fpexc_val >> 2) & 1)); + fpexc->child(2)->setText(1, QString::number((fpexc_val >> 3) & 1)); + fpexc->child(3)->setText(1, QString::number((fpexc_val >> 7) & 1)); + fpexc->child(4)->setText(1, QString("b%1").arg((fpexc_val >> 8) & 7, 3, 2, QLatin1Char('0'))); + fpexc->child(5)->setText(1, QString::number((fpexc_val >> 28) & 1)); + fpexc->child(6)->setText(1, QString::number((fpexc_val >> 30) & 1)); + fpexc->child(7)->setText(1, QString::number((fpexc_val >> 31) & 1)); + + vfp_system_registers->child(2)->setText(1, QString("0x%1").arg(fpinst_val, 8, 16, QLatin1Char('0'))); + vfp_system_registers->child(3)->setText(1, QString("0x%1").arg(fpinst2_val, 8, 16, QLatin1Char('0'))); +} diff --git a/src/citra_qt/debugger/registers.h b/src/citra_qt/debugger/registers.h index 68e3fb908..09b830e80 100644 --- a/src/citra_qt/debugger/registers.h +++ b/src/citra_qt/debugger/registers.h @@ -25,10 +25,18 @@ public slots: void OnEmulationStopping(); private: + void CreateCPSRChildren(); + void UpdateCPSRValues(); + + void CreateVFPSystemRegisterChildren(); + void UpdateVFPSystemRegisterValues(); + Ui::ARMRegisters cpu_regs_ui; QTreeWidget* tree; - QTreeWidgetItem* registers; - QTreeWidgetItem* CSPR; + QTreeWidgetItem* core_registers; + QTreeWidgetItem* vfp_registers; + QTreeWidgetItem* vfp_system_registers; + QTreeWidgetItem* cpsr; }; diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h index 85ed2c698..5cffe513c 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h @@ -62,6 +62,34 @@ public: virtual void SetReg(int index, u32 value) = 0; /** + * Gets the value of a VFP register + * @param index Register index (0-31) + * @return Returns the value in the register + */ + virtual u32 GetVFPReg(int index) const = 0; + + /** + * Sets a VFP register to the given value + * @param index Register index (0-31) + * @param value Value to set register to + */ + virtual void SetVFPReg(int index, u32 value) = 0; + + /** + * Gets the current value within a given VFP system register + * @param reg The VFP system register + * @return The value within the VFP system register + */ + virtual u32 GetVFPSystemReg(VFPSystemRegister reg) const = 0; + + /** + * Sets the VFP system register to the given value + * @param reg The VFP system register + * @param value Value to set the VFP system register to + */ + virtual void SetVFPSystemReg(VFPSystemRegister reg, u32 value) = 0; + + /** * Get the current CPSR register * @return Returns the value of the CPSR register */ diff --git a/src/core/arm/dyncom/arm_dyncom.cpp b/src/core/arm/dyncom/arm_dyncom.cpp index c665f706f..f3be2c857 100644 --- a/src/core/arm/dyncom/arm_dyncom.cpp +++ b/src/core/arm/dyncom/arm_dyncom.cpp @@ -40,6 +40,22 @@ void ARM_DynCom::SetReg(int index, u32 value) { state->Reg[index] = value; } +u32 ARM_DynCom::GetVFPReg(int index) const { + return state->ExtReg[index]; +} + +void ARM_DynCom::SetVFPReg(int index, u32 value) { + state->ExtReg[index] = value; +} + +u32 ARM_DynCom::GetVFPSystemReg(VFPSystemRegister reg) const { + return state->VFP[reg]; +} + +void ARM_DynCom::SetVFPSystemReg(VFPSystemRegister reg, u32 value) { + state->VFP[reg] = value; +} + u32 ARM_DynCom::GetCPSR() const { return state->Cpsr; } diff --git a/src/core/arm/dyncom/arm_dyncom.h b/src/core/arm/dyncom/arm_dyncom.h index 87ab6908a..3664fd728 100644 --- a/src/core/arm/dyncom/arm_dyncom.h +++ b/src/core/arm/dyncom/arm_dyncom.h @@ -25,6 +25,10 @@ public: u32 GetPC() const override; u32 GetReg(int index) const override; void SetReg(int index, u32 value) override; + u32 GetVFPReg(int index) const override; + void SetVFPReg(int index, u32 value) override; + u32 GetVFPSystemReg(VFPSystemRegister reg) const override; + void SetVFPSystemReg(VFPSystemRegister reg, u32 value) override; u32 GetCPSR() const override; void SetCPSR(u32 cpsr) override; u32 GetCP15Register(CP15Register reg) override; diff --git a/src/core/arm/skyeye_common/arm_regformat.h b/src/core/arm/skyeye_common/arm_regformat.h index d1c721809..38fa97ab9 100644 --- a/src/core/arm/skyeye_common/arm_regformat.h +++ b/src/core/arm/skyeye_common/arm_regformat.h @@ -55,7 +55,7 @@ enum { }; // VFP system registers -enum { +enum VFPSystemRegister { VFP_FPSID, VFP_FPSCR, VFP_FPEXC, |