summaryrefslogtreecommitdiffstats
path: root/src/citra_qt/debugger
diff options
context:
space:
mode:
Diffstat (limited to 'src/citra_qt/debugger')
-rw-r--r--src/citra_qt/debugger/callstack.cpp8
-rw-r--r--src/citra_qt/debugger/disassembler.cpp2
-rw-r--r--src/citra_qt/debugger/graphics_tracing.cpp6
-rw-r--r--src/citra_qt/debugger/graphics_vertex_shader.cpp256
-rw-r--r--src/citra_qt/debugger/graphics_vertex_shader.h51
-rw-r--r--src/citra_qt/debugger/registers.cpp212
-rw-r--r--src/citra_qt/debugger/registers.h12
7 files changed, 458 insertions, 89 deletions
diff --git a/src/citra_qt/debugger/callstack.cpp b/src/citra_qt/debugger/callstack.cpp
index 6799ce844..e97e81b65 100644
--- a/src/citra_qt/debugger/callstack.cpp
+++ b/src/citra_qt/debugger/callstack.cpp
@@ -4,12 +4,14 @@
#include <QStandardItemModel>
+#include "common/common_types.h"
+#include "common/symbols.h"
+
#include "callstack.h"
#include "core/core.h"
#include "core/arm/arm_interface.h"
#include "core/memory.h"
-#include "common/symbols.h"
#include "core/arm/disassembler/arm_disasm.h"
CallstackWidget::CallstackWidget(QWidget* parent): QDockWidget(parent)
@@ -49,8 +51,8 @@ void CallstackWidget::OnDebugModeEntered()
{
std::string name;
// ripped from disasm
- uint8_t cond = (insn >> 28) & 0xf;
- uint32_t i_offset = insn & 0xffffff;
+ u8 cond = (insn >> 28) & 0xf;
+ u32 i_offset = insn & 0xffffff;
// Sign-extend the 24-bit offset
if ((i_offset >> 23) & 1)
i_offset |= 0xff000000;
diff --git a/src/citra_qt/debugger/disassembler.cpp b/src/citra_qt/debugger/disassembler.cpp
index 1e5ef5299..d3629bbf6 100644
--- a/src/citra_qt/debugger/disassembler.cpp
+++ b/src/citra_qt/debugger/disassembler.cpp
@@ -159,7 +159,7 @@ void DisassemblerModel::SetNextInstruction(unsigned int address) {
}
DisassemblerWidget::DisassemblerWidget(QWidget* parent, EmuThread* emu_thread) :
- QDockWidget(parent), emu_thread(emu_thread), base_addr(0) {
+ QDockWidget(parent), base_addr(0), emu_thread(emu_thread) {
disasm_ui.setupUi(this);
diff --git a/src/citra_qt/debugger/graphics_tracing.cpp b/src/citra_qt/debugger/graphics_tracing.cpp
index 3f20f149d..f80cb7493 100644
--- a/src/citra_qt/debugger/graphics_tracing.cpp
+++ b/src/citra_qt/debugger/graphics_tracing.cpp
@@ -14,6 +14,8 @@
#include <boost/range/algorithm/copy.hpp>
+#include "common/common_types.h"
+
#include "core/hw/gpu.h"
#include "core/hw/lcd.h"
@@ -66,14 +68,14 @@ void GraphicsTracingWidget::StartRecording() {
// Encode floating point numbers to 24-bit values
// TODO: Drop this explicit conversion once we store float24 values bit-correctly internally.
- std::array<uint32_t, 4 * 16> default_attributes;
+ std::array<u32, 4 * 16> default_attributes;
for (unsigned i = 0; i < 16; ++i) {
for (unsigned comp = 0; comp < 3; ++comp) {
default_attributes[4 * i + comp] = nihstro::to_float24(Pica::g_state.vs.default_attributes[i][comp].ToFloat32());
}
}
- std::array<uint32_t, 4 * 96> vs_float_uniforms;
+ std::array<u32, 4 * 96> vs_float_uniforms;
for (unsigned i = 0; i < 96; ++i)
for (unsigned comp = 0; comp < 3; ++comp)
vs_float_uniforms[4 * i + comp] = nihstro::to_float24(Pica::g_state.vs.uniforms.f[i][comp].ToFloat32());
diff --git a/src/citra_qt/debugger/graphics_vertex_shader.cpp b/src/citra_qt/debugger/graphics_vertex_shader.cpp
index f42a2f4ce..0c17edee0 100644
--- a/src/citra_qt/debugger/graphics_vertex_shader.cpp
+++ b/src/citra_qt/debugger/graphics_vertex_shader.cpp
@@ -6,9 +6,16 @@
#include <sstream>
#include <QBoxLayout>
+#include <QFileDialog>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QSignalMapper>
+#include <QSpinBox>
#include <QTreeView>
-#include "video_core/vertex_shader.h"
+#include "video_core/shader/shader.h"
#include "graphics_vertex_shader.h"
@@ -17,7 +24,7 @@ using nihstro::Instruction;
using nihstro::SourceRegister;
using nihstro::SwizzlePattern;
-GraphicsVertexShaderModel::GraphicsVertexShaderModel(QObject* parent): QAbstractItemModel(parent) {
+GraphicsVertexShaderModel::GraphicsVertexShaderModel(GraphicsVertexShaderWidget* parent): QAbstractItemModel(parent), par(parent) {
}
@@ -34,7 +41,7 @@ int GraphicsVertexShaderModel::columnCount(const QModelIndex& parent) const {
}
int GraphicsVertexShaderModel::rowCount(const QModelIndex& parent) const {
- return static_cast<int>(info.code.size());
+ return static_cast<int>(par->info.code.size());
}
QVariant GraphicsVertexShaderModel::headerData(int section, Qt::Orientation orientation, int role) const {
@@ -62,21 +69,21 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con
{
switch (index.column()) {
case 0:
- if (info.HasLabel(index.row()))
- return QString::fromStdString(info.GetLabel(index.row()));
+ if (par->info.HasLabel(index.row()))
+ return QString::fromStdString(par->info.GetLabel(index.row()));
return QString("%1").arg(4*index.row(), 4, 16, QLatin1Char('0'));
case 1:
- return QString("%1").arg(info.code[index.row()].hex, 8, 16, QLatin1Char('0'));
+ return QString("%1").arg(par->info.code[index.row()].hex, 8, 16, QLatin1Char('0'));
case 2:
{
std::stringstream output;
output.flags(std::ios::hex);
- Instruction instr = info.code[index.row()];
- const SwizzlePattern& swizzle = info.swizzle_info[instr.common.operand_desc_id].pattern;
+ Instruction instr = par->info.code[index.row()];
+ const SwizzlePattern& swizzle = par->info.swizzle_info[instr.common.operand_desc_id].pattern;
// longest known instruction name: "setemit "
output << std::setw(8) << std::left << instr.opcode.Value().GetInfo().name;
@@ -130,13 +137,13 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con
print_input_indexed_compact(output, src1, swizzle.negate_src1, swizzle.SelectorToString(false).substr(0,1), instr.common.AddressRegisterName());
output << " " << instr.common.compare_op.ToString(instr.common.compare_op.x) << " ";
- print_input(output, src2, swizzle.negate_src2, swizzle.SelectorToString(false).substr(0,1));
+ print_input(output, src2, swizzle.negate_src2, swizzle.SelectorToString(true).substr(0,1));
output << ", ";
print_input_indexed_compact(output, src1, swizzle.negate_src1, swizzle.SelectorToString(false).substr(1,1), instr.common.AddressRegisterName());
output << " " << instr.common.compare_op.ToString(instr.common.compare_op.y) << " ";
- print_input(output, src2, swizzle.negate_src2, swizzle.SelectorToString(false).substr(1,1));
+ print_input(output, src2, swizzle.negate_src2, swizzle.SelectorToString(true).substr(1,1));
break;
}
@@ -167,7 +174,7 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con
// TODO: In some cases, the Address Register is used as an index for SRC2 instead of SRC1
if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::Src2) {
SourceRegister src2 = instr.common.GetSrc2(src_is_inverted);
- print_input(output, src2, swizzle.negate_src2, swizzle.SelectorToString(false));
+ print_input(output, src2, swizzle.negate_src2, swizzle.SelectorToString(true));
}
break;
}
@@ -240,6 +247,18 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con
case Qt::FontRole:
return QFont("monospace");
+ case Qt::BackgroundRole:
+ // Highlight instructions which have no debug data associated to them
+ for (const auto& record : par->debug_data.records)
+ if (index.row() == record.instruction_offset)
+ return QVariant();
+
+ return QBrush(QColor(255, 255, 127));
+
+
+ // TODO: Draw arrows for each "reachable" instruction to visualize control flow
+
+
default:
break;
}
@@ -247,53 +266,232 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con
return QVariant();
}
-void GraphicsVertexShaderModel::OnUpdate()
-{
- beginResetModel();
-
- info.Clear();
-
- for (auto instr : Pica::g_state.vs.program_code)
- info.code.push_back({instr});
+void GraphicsVertexShaderWidget::DumpShader() {
+ QString filename = QFileDialog::getSaveFileName(this, tr("Save Shader Dump"), "shader_dump.shbin",
+ tr("Shader Binary (*.shbin)"));
- for (auto pattern : Pica::g_state.vs.swizzle_data)
- info.swizzle_info.push_back({pattern});
+ if (filename.isEmpty()) {
+ // If the user canceled the dialog, don't dump anything.
+ return;
+ }
- info.labels.insert({ Pica::g_state.regs.vs.main_offset, "main" });
+ auto& setup = Pica::g_state.vs;
+ auto& config = Pica::g_state.regs.vs;
- endResetModel();
+ Pica::DebugUtils::DumpShader(filename.toStdString(), config, setup, Pica::g_state.regs.vs_output_attributes);
}
-
GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::DebugContext > debug_context,
QWidget* parent)
: BreakPointObserverDock(debug_context, "Pica Vertex Shader", parent) {
setObjectName("PicaVertexShader");
- auto binary_model = new GraphicsVertexShaderModel(this);
- auto binary_list = new QTreeView;
- binary_list->setModel(binary_model);
+ auto input_data_mapper = new QSignalMapper(this);
+
+ // TODO: Support inputting data in hexadecimal raw format
+ for (unsigned i = 0; i < ARRAY_SIZE(input_data); ++i) {
+ input_data[i] = new QLineEdit;
+ input_data[i]->setValidator(new QDoubleValidator(input_data[i]));
+ }
+
+ breakpoint_warning = new QLabel(tr("(data only available at VertexLoaded breakpoints)"));
+
+ // TODO: Add some button for jumping to the shader entry point
+
+ model = new GraphicsVertexShaderModel(this);
+ binary_list = new QTreeView;
+ binary_list->setModel(model);
binary_list->setRootIsDecorated(false);
binary_list->setAlternatingRowColors(true);
- connect(this, SIGNAL(Update()), binary_model, SLOT(OnUpdate()));
+ auto dump_shader = new QPushButton(QIcon::fromTheme("document-save"), tr("Dump"));
+
+ instruction_description = new QLabel;
+
+ cycle_index = new QSpinBox;
+
+ connect(this, SIGNAL(SelectCommand(const QModelIndex&, QItemSelectionModel::SelectionFlags)),
+ binary_list->selectionModel(), SLOT(select(const QModelIndex&, QItemSelectionModel::SelectionFlags)));
+
+ connect(dump_shader, SIGNAL(clicked()), this, SLOT(DumpShader()));
+
+ connect(cycle_index, SIGNAL(valueChanged(int)), this, SLOT(OnCycleIndexChanged(int)));
+
+ for (unsigned i = 0; i < ARRAY_SIZE(input_data); ++i) {
+ connect(input_data[i], SIGNAL(textEdited(const QString&)), input_data_mapper, SLOT(map()));
+ input_data_mapper->setMapping(input_data[i], i);
+ }
+ connect(input_data_mapper, SIGNAL(mapped(int)), this, SLOT(OnInputAttributeChanged(int)));
auto main_widget = new QWidget;
auto main_layout = new QVBoxLayout;
{
+ auto input_data_group = new QGroupBox(tr("Input Data"));
+
+ // For each vertex attribute, add a QHBoxLayout consisting of:
+ // - A QLabel denoting the source attribute index
+ // - Four QLineEdits for showing and manipulating attribute data
+ // - A QLabel denoting the shader input attribute index
+ auto sub_layout = new QVBoxLayout;
+ for (unsigned i = 0; i < 16; ++i) {
+ // Create an HBoxLayout to store the widgets used to specify a particular attribute
+ // and store it in a QWidget to allow for easy hiding and unhiding.
+ auto row_layout = new QHBoxLayout;
+ row_layout->addWidget(new QLabel(tr("Attribute %1").arg(i, 2)));
+ for (unsigned comp = 0; comp < 4; ++comp)
+ row_layout->addWidget(input_data[4 * i + comp]);
+
+ row_layout->addWidget(input_data_mapping[i] = new QLabel);
+
+ input_data_container[i] = new QWidget;
+ input_data_container[i]->setLayout(row_layout);
+ input_data_container[i]->hide();
+
+ sub_layout->addWidget(input_data_container[i]);
+ }
+
+ sub_layout->addWidget(breakpoint_warning);
+ breakpoint_warning->hide();
+
+ input_data_group->setLayout(sub_layout);
+ main_layout->addWidget(input_data_group);
+ }
+ {
auto sub_layout = new QHBoxLayout;
sub_layout->addWidget(binary_list);
main_layout->addLayout(sub_layout);
}
+ main_layout->addWidget(dump_shader);
+ {
+ auto sub_layout = new QHBoxLayout;
+ sub_layout->addWidget(new QLabel(tr("Cycle Index:")));
+ sub_layout->addWidget(cycle_index);
+ main_layout->addLayout(sub_layout);
+ }
+ main_layout->addWidget(instruction_description);
+ main_layout->addStretch();
main_widget->setLayout(main_layout);
setWidget(main_widget);
+
+ widget()->setEnabled(false);
}
void GraphicsVertexShaderWidget::OnBreakPointHit(Pica::DebugContext::Event event, void* data) {
- emit Update();
+ auto input = static_cast<Pica::Shader::InputVertex*>(data);
+ if (event == Pica::DebugContext::Event::VertexLoaded) {
+ Reload(true, data);
+ } else {
+ // No vertex data is retrievable => invalidate currently stored vertex data
+ Reload(true, nullptr);
+ }
widget()->setEnabled(true);
}
+void GraphicsVertexShaderWidget::Reload(bool replace_vertex_data, void* vertex_data) {
+ model->beginResetModel();
+
+ if (replace_vertex_data) {
+ if (vertex_data) {
+ memcpy(&input_vertex, vertex_data, sizeof(input_vertex));
+ for (unsigned attr = 0; attr < 16; ++attr) {
+ for (unsigned comp = 0; comp < 4; ++comp) {
+ input_data[4 * attr + comp]->setText(QString("%1").arg(input_vertex.attr[attr][comp].ToFloat32()));
+ }
+ }
+ breakpoint_warning->hide();
+ } else {
+ for (unsigned attr = 0; attr < 16; ++attr) {
+ for (unsigned comp = 0; comp < 4; ++comp) {
+ input_data[4 * attr + comp]->setText(QString("???"));
+ }
+ }
+ breakpoint_warning->show();
+ }
+ }
+
+ // Reload shader code
+ info.Clear();
+
+ auto& shader_setup = Pica::g_state.vs;
+ auto& shader_config = Pica::g_state.regs.vs;
+ for (auto instr : shader_setup.program_code)
+ info.code.push_back({instr});
+
+ for (auto pattern : shader_setup.swizzle_data)
+ info.swizzle_info.push_back({pattern});
+
+ u32 entry_point = Pica::g_state.regs.vs.main_offset;
+ info.labels.insert({ entry_point, "main" });
+
+ // Generate debug information
+ debug_data = Pica::Shader::ProduceDebugInfo(input_vertex, 1, shader_config, shader_setup);
+
+ // Reload widget state
+
+ // Only show input attributes which are used as input to the shader
+ for (unsigned int attr = 0; attr < 16; ++attr) {
+ input_data_container[attr]->setVisible(false);
+ }
+ for (unsigned int attr = 0; attr < Pica::g_state.regs.vertex_attributes.GetNumTotalAttributes(); ++attr) {
+ unsigned source_attr = shader_config.input_register_map.GetRegisterForAttribute(attr);
+ input_data_mapping[source_attr]->setText(QString("-> v%1").arg(attr));
+ input_data_container[source_attr]->setVisible(true);
+ }
+
+ // Initialize debug info text for current cycle count
+ cycle_index->setMaximum(debug_data.records.size() - 1);
+ OnCycleIndexChanged(cycle_index->value());
+
+ model->endResetModel();
+}
+
void GraphicsVertexShaderWidget::OnResumed() {
widget()->setEnabled(false);
}
+
+void GraphicsVertexShaderWidget::OnInputAttributeChanged(int index) {
+ float value = input_data[index]->text().toFloat();
+ Reload();
+}
+
+void GraphicsVertexShaderWidget::OnCycleIndexChanged(int index) {
+ QString text;
+
+ auto& record = debug_data.records[index];
+ if (record.mask & Pica::Shader::DebugDataRecord::SRC1)
+ text += tr("SRC1: %1, %2, %3, %4\n").arg(record.src1.x.ToFloat32()).arg(record.src1.y.ToFloat32()).arg(record.src1.z.ToFloat32()).arg(record.src1.w.ToFloat32());
+ if (record.mask & Pica::Shader::DebugDataRecord::SRC2)
+ text += tr("SRC2: %1, %2, %3, %4\n").arg(record.src2.x.ToFloat32()).arg(record.src2.y.ToFloat32()).arg(record.src2.z.ToFloat32()).arg(record.src2.w.ToFloat32());
+ if (record.mask & Pica::Shader::DebugDataRecord::SRC3)
+ text += tr("SRC3: %1, %2, %3, %4\n").arg(record.src3.x.ToFloat32()).arg(record.src3.y.ToFloat32()).arg(record.src3.z.ToFloat32()).arg(record.src3.w.ToFloat32());
+ if (record.mask & Pica::Shader::DebugDataRecord::DEST_IN)
+ text += tr("DEST_IN: %1, %2, %3, %4\n").arg(record.dest_in.x.ToFloat32()).arg(record.dest_in.y.ToFloat32()).arg(record.dest_in.z.ToFloat32()).arg(record.dest_in.w.ToFloat32());
+ if (record.mask & Pica::Shader::DebugDataRecord::DEST_OUT)
+ text += tr("DEST_OUT: %1, %2, %3, %4\n").arg(record.dest_out.x.ToFloat32()).arg(record.dest_out.y.ToFloat32()).arg(record.dest_out.z.ToFloat32()).arg(record.dest_out.w.ToFloat32());
+
+ if (record.mask & Pica::Shader::DebugDataRecord::ADDR_REG_OUT)
+ text += tr("Addres Registers: %1, %2\n").arg(record.address_registers[0]).arg(record.address_registers[1]);
+ if (record.mask & Pica::Shader::DebugDataRecord::CMP_RESULT)
+ text += tr("Compare Result: %1, %2\n").arg(record.conditional_code[0] ? "true" : "false").arg(record.conditional_code[1] ? "true" : "false");
+
+ if (record.mask & Pica::Shader::DebugDataRecord::COND_BOOL_IN)
+ text += tr("Static Condition: %1\n").arg(record.cond_bool ? "true" : "false");
+ if (record.mask & Pica::Shader::DebugDataRecord::COND_CMP_IN)
+ text += tr("Dynamic Conditions: %1, %2\n").arg(record.cond_cmp[0] ? "true" : "false").arg(record.cond_cmp[1] ? "true" : "false");
+ if (record.mask & Pica::Shader::DebugDataRecord::LOOP_INT_IN)
+ text += tr("Loop Parameters: %1 (repeats), %2 (initializer), %3 (increment), %4\n").arg(record.loop_int.x).arg(record.loop_int.y).arg(record.loop_int.z).arg(record.loop_int.w);
+
+ text += tr("Instruction offset: 0x%1").arg(4 * record.instruction_offset, 4, 16, QLatin1Char('0'));
+ if (record.mask & Pica::Shader::DebugDataRecord::NEXT_INSTR) {
+ text += tr(" -> 0x%2").arg(4 * record.next_instruction, 4, 16, QLatin1Char('0'));
+ } else {
+ text += tr(" (last instruction)");
+ }
+
+ instruction_description->setText(text);
+
+ // Scroll to current instruction
+ const QModelIndex& instr_index = model->index(record.instruction_offset, 0);
+ emit SelectCommand(instr_index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+ binary_list->scrollTo(instr_index, QAbstractItemView::EnsureVisible);
+}
diff --git a/src/citra_qt/debugger/graphics_vertex_shader.h b/src/citra_qt/debugger/graphics_vertex_shader.h
index 38339dc05..1b3f1f7ec 100644
--- a/src/citra_qt/debugger/graphics_vertex_shader.h
+++ b/src/citra_qt/debugger/graphics_vertex_shader.h
@@ -10,11 +10,18 @@
#include "nihstro/parser_shbin.h"
+#include "video_core/shader/shader.h"
+
+class QLabel;
+class QSpinBox;
+
+class GraphicsVertexShaderWidget;
+
class GraphicsVertexShaderModel : public QAbstractItemModel {
Q_OBJECT
public:
- GraphicsVertexShaderModel(QObject* parent);
+ GraphicsVertexShaderModel(GraphicsVertexShaderWidget* parent);
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex& child) const override;
@@ -23,11 +30,10 @@ public:
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
-public slots:
- void OnUpdate();
-
private:
- nihstro::ShaderInfo info;
+ GraphicsVertexShaderWidget* par;
+
+ friend class GraphicsVertexShaderWidget;
};
class GraphicsVertexShaderWidget : public BreakPointObserverDock {
@@ -43,9 +49,42 @@ private slots:
void OnBreakPointHit(Pica::DebugContext::Event event, void* data) override;
void OnResumed() override;
+ void OnInputAttributeChanged(int index);
+
+ void OnCycleIndexChanged(int index);
+
+ void DumpShader();
+
+ /**
+ * Reload widget based on the current PICA200 state
+ * @param replace_vertex_data If true, invalidate all current vertex data
+ * @param vertex_data New vertex data to use, as passed to OnBreakPointHit. May be nullptr to specify that no valid vertex data can be retrieved currently. Only used if replace_vertex_data is true.
+ */
+ void Reload(bool replace_vertex_data = false, void* vertex_data = nullptr);
+
+
signals:
- void Update();
+ // Call this to change the current command selection in the disassembly view
+ void SelectCommand(const QModelIndex&, QItemSelectionModel::SelectionFlags);
private:
+ QLabel* instruction_description;
+ QTreeView* binary_list;
+ GraphicsVertexShaderModel* model;
+
+ /// TODO: Move these into a single struct
+ std::array<QLineEdit*, 4*16> input_data; // A text box for each of the 4 components of up to 16 vertex attributes
+ std::array<QWidget*, 16> input_data_container; // QWidget containing the QLayout containing each vertex attribute
+ std::array<QLabel*, 16> input_data_mapping; // A QLabel denoting the shader input attribute which the vertex attribute maps to
+
+ // Text to be shown when input vertex data is not retrievable
+ QLabel* breakpoint_warning;
+
+ QSpinBox* cycle_index;
+
+ nihstro::ShaderInfo info;
+ Pica::Shader::DebugData<true> debug_data;
+ Pica::Shader::InputVertex input_vertex;
+ friend class GraphicsVertexShaderModel;
};
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;
};