2015-01-04 18:36:57 +01:00
|
|
|
// Copyright 2014 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2015-09-11 06:23:00 +02:00
|
|
|
#include <QTreeWidgetItem>
|
2014-04-01 04:26:50 +02:00
|
|
|
|
2015-09-11 06:23:00 +02:00
|
|
|
#include "citra_qt/debugger/registers.h"
|
|
|
|
#include "citra_qt/util/util.h"
|
2015-09-07 10:33:18 +02:00
|
|
|
|
2014-04-19 00:30:53 +02:00
|
|
|
#include "core/arm/arm_interface.h"
|
2016-09-18 02:38:01 +02:00
|
|
|
#include "core/core.h"
|
2014-04-01 04:26:50 +02:00
|
|
|
|
2015-04-30 05:26:59 +02:00
|
|
|
RegistersWidget::RegistersWidget(QWidget* parent) : QDockWidget(parent) {
|
2014-04-01 04:26:50 +02:00
|
|
|
cpu_regs_ui.setupUi(this);
|
|
|
|
|
|
|
|
tree = cpu_regs_ui.treeWidget;
|
2015-08-07 03:36:44 +02:00
|
|
|
tree->addTopLevelItem(core_registers = new QTreeWidgetItem(QStringList(tr("Registers"))));
|
|
|
|
tree->addTopLevelItem(vfp_registers = new QTreeWidgetItem(QStringList(tr("VFP Registers"))));
|
2016-09-18 02:38:01 +02:00
|
|
|
tree->addTopLevelItem(vfp_system_registers =
|
|
|
|
new QTreeWidgetItem(QStringList(tr("VFP System Registers"))));
|
2015-08-07 03:11:25 +02:00
|
|
|
tree->addTopLevelItem(cpsr = new QTreeWidgetItem(QStringList("CPSR")));
|
2014-04-01 04:26:50 +02:00
|
|
|
|
2015-04-30 05:26:59 +02:00
|
|
|
for (int i = 0; i < 16; ++i) {
|
2015-08-07 03:36:44 +02:00
|
|
|
QTreeWidgetItem* child = new QTreeWidgetItem(QStringList(QString("R[%1]").arg(i)));
|
|
|
|
core_registers->addChild(child);
|
2014-04-01 04:26:50 +02:00
|
|
|
}
|
|
|
|
|
2015-08-07 03:36:44 +02:00
|
|
|
for (int i = 0; i < 32; ++i) {
|
|
|
|
QTreeWidgetItem* child = new QTreeWidgetItem(QStringList(QString("S[%1]").arg(i)));
|
|
|
|
vfp_registers->addChild(child);
|
|
|
|
}
|
|
|
|
|
2015-09-07 10:33:18 +02:00
|
|
|
QFont font = GetMonospaceFont();
|
|
|
|
|
2015-08-07 03:36:44 +02:00
|
|
|
CreateCPSRChildren();
|
|
|
|
CreateVFPSystemRegisterChildren();
|
2015-04-30 05:26:59 +02:00
|
|
|
|
2015-09-07 10:33:18 +02:00
|
|
|
// Set Registers to display in monospace font
|
|
|
|
for (int i = 0; i < core_registers->childCount(); ++i)
|
|
|
|
core_registers->child(i)->setFont(1, font);
|
|
|
|
|
|
|
|
for (int i = 0; i < vfp_registers->childCount(); ++i)
|
|
|
|
vfp_registers->child(i)->setFont(1, font);
|
|
|
|
|
|
|
|
for (int i = 0; i < vfp_system_registers->childCount(); ++i) {
|
|
|
|
vfp_system_registers->child(i)->setFont(1, font);
|
|
|
|
for (int x = 0; x < vfp_system_registers->child(i)->childCount(); ++x) {
|
|
|
|
vfp_system_registers->child(i)->child(x)->setFont(1, font);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Set CSPR to display in monospace font
|
|
|
|
cpsr->setFont(1, font);
|
|
|
|
for (int i = 0; i < cpsr->childCount(); ++i) {
|
|
|
|
cpsr->child(i)->setFont(1, font);
|
|
|
|
for (int x = 0; x < cpsr->child(i)->childCount(); ++x) {
|
|
|
|
cpsr->child(i)->child(x)->setFont(1, font);
|
|
|
|
}
|
|
|
|
}
|
2015-04-30 05:26:59 +02:00
|
|
|
setEnabled(false);
|
2014-04-01 04:26:50 +02:00
|
|
|
}
|
|
|
|
|
2015-04-30 05:26:59 +02:00
|
|
|
void RegistersWidget::OnDebugModeEntered() {
|
2015-12-30 00:03:08 +01:00
|
|
|
if (!Core::g_app_core)
|
2015-04-30 05:26:59 +02:00
|
|
|
return;
|
|
|
|
|
2015-08-07 03:36:44 +02:00
|
|
|
for (int i = 0; i < core_registers->childCount(); ++i)
|
2016-09-18 02:38:01 +02:00
|
|
|
core_registers->child(i)->setText(
|
|
|
|
1, QString("0x%1").arg(Core::g_app_core->GetReg(i), 8, 16, QLatin1Char('0')));
|
2015-08-07 03:36:44 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < vfp_registers->childCount(); ++i)
|
2016-09-18 02:38:01 +02:00
|
|
|
vfp_registers->child(i)->setText(
|
|
|
|
1, QString("0x%1").arg(Core::g_app_core->GetVFPReg(i), 8, 16, QLatin1Char('0')));
|
2015-08-07 03:36:44 +02:00
|
|
|
|
|
|
|
UpdateCPSRValues();
|
|
|
|
UpdateVFPSystemRegisterValues();
|
2014-04-01 04:26:50 +02:00
|
|
|
}
|
2015-01-07 12:14:23 +01:00
|
|
|
|
2016-09-19 03:01:46 +02:00
|
|
|
void RegistersWidget::OnDebugModeLeft() {}
|
2015-04-30 05:26:59 +02:00
|
|
|
|
2015-05-01 01:46:50 +02:00
|
|
|
void RegistersWidget::OnEmulationStarting(EmuThread* emu_thread) {
|
2015-04-30 05:26:59 +02:00
|
|
|
setEnabled(true);
|
|
|
|
}
|
|
|
|
|
2015-05-01 01:46:50 +02:00
|
|
|
void RegistersWidget::OnEmulationStopping() {
|
2015-04-30 05:26:59 +02:00
|
|
|
// Reset widget text
|
2015-08-07 03:36:44 +02:00
|
|
|
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(""));
|
2015-04-30 05:26:59 +02:00
|
|
|
|
2015-08-07 03:36:44 +02:00
|
|
|
for (int i = 0; i < cpsr->childCount(); ++i)
|
2015-08-07 03:11:25 +02:00
|
|
|
cpsr->child(i)->setText(1, QString(""));
|
2015-04-30 05:26:59 +02:00
|
|
|
|
2015-08-07 03:11:25 +02:00
|
|
|
cpsr->setText(1, QString(""));
|
2015-01-07 12:14:23 +01:00
|
|
|
|
2015-08-07 03:36:44 +02:00
|
|
|
// FPSCR
|
|
|
|
for (int i = 0; i < vfp_system_registers->child(0)->childCount(); ++i)
|
|
|
|
vfp_system_registers->child(0)->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(""));
|
|
|
|
|
|
|
|
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(""));
|
|
|
|
|
2015-04-30 05:26:59 +02:00
|
|
|
setEnabled(false);
|
2015-01-07 12:14:23 +01:00
|
|
|
}
|
2015-08-07 03:36:44 +02:00
|
|
|
|
|
|
|
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')));
|
2016-09-18 02:38:01 +02:00
|
|
|
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
|
2015-08-07 03:36:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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() {
|
2016-09-18 02:38:01 +02:00
|
|
|
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);
|
2015-08-07 03:36:44 +02:00
|
|
|
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));
|
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
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')));
|
2015-08-07 03:36:44 +02:00
|
|
|
}
|