diff options
Diffstat (limited to 'src/citra_qt/debugger')
| -rw-r--r-- | src/citra_qt/debugger/callstack.cpp | 66 | ||||
| -rw-r--r-- | src/citra_qt/debugger/callstack.hxx | 19 | ||||
| -rw-r--r-- | src/citra_qt/debugger/callstack.ui | 36 | ||||
| -rw-r--r-- | src/citra_qt/debugger/disassembler.cpp | 161 | ||||
| -rw-r--r-- | src/citra_qt/debugger/disassembler.hxx | 42 | ||||
| -rw-r--r-- | src/citra_qt/debugger/disassembler.ui | 88 | ||||
| -rw-r--r-- | src/citra_qt/debugger/ramview.cpp | 13 | ||||
| -rw-r--r-- | src/citra_qt/debugger/ramview.hxx | 12 | ||||
| -rw-r--r-- | src/citra_qt/debugger/registers.cpp | 63 | ||||
| -rw-r--r-- | src/citra_qt/debugger/registers.hxx | 25 | ||||
| -rw-r--r-- | src/citra_qt/debugger/registers.ui | 40 |
11 files changed, 565 insertions, 0 deletions
diff --git a/src/citra_qt/debugger/callstack.cpp b/src/citra_qt/debugger/callstack.cpp new file mode 100644 index 000000000..f59f2d8c8 --- /dev/null +++ b/src/citra_qt/debugger/callstack.cpp | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | #include <QStandardItemModel> | ||
| 2 | |||
| 3 | #include "callstack.hxx" | ||
| 4 | |||
| 5 | #include "core/core.h" | ||
| 6 | #include "core/arm/arm_interface.h" | ||
| 7 | #include "core/mem_map.h" | ||
| 8 | #include "common/symbols.h" | ||
| 9 | #include "core/arm/disassembler/arm_disasm.h" | ||
| 10 | |||
| 11 | CallstackWidget::CallstackWidget(QWidget* parent): QDockWidget(parent) | ||
| 12 | { | ||
| 13 | ui.setupUi(this); | ||
| 14 | |||
| 15 | callstack_model = new QStandardItemModel(this); | ||
| 16 | callstack_model->setColumnCount(4); | ||
| 17 | callstack_model->setHeaderData(0, Qt::Horizontal, "Stack pointer"); | ||
| 18 | callstack_model->setHeaderData(2, Qt::Horizontal, "Return address"); | ||
| 19 | callstack_model->setHeaderData(1, Qt::Horizontal, "Call address"); | ||
| 20 | callstack_model->setHeaderData(3, Qt::Horizontal, "Function"); | ||
| 21 | ui.treeView->setModel(callstack_model); | ||
| 22 | } | ||
| 23 | |||
| 24 | void CallstackWidget::OnCPUStepped() | ||
| 25 | { | ||
| 26 | ARM_Disasm* disasm = new ARM_Disasm(); | ||
| 27 | ARM_Interface* app_core = Core::g_app_core; | ||
| 28 | |||
| 29 | u32 sp = app_core->GetReg(13); //stack pointer | ||
| 30 | u32 addr, ret_addr, call_addr, func_addr; | ||
| 31 | |||
| 32 | int counter = 0; | ||
| 33 | for (int addr = 0x10000000; addr >= sp; addr -= 4) | ||
| 34 | { | ||
| 35 | ret_addr = Memory::Read32(addr); | ||
| 36 | call_addr = ret_addr - 4; //get call address??? | ||
| 37 | |||
| 38 | /* TODO (mattvail) clean me, move to debugger interface */ | ||
| 39 | u32 insn = Memory::Read32(call_addr); | ||
| 40 | if (disasm->decode(insn) == OP_BL) | ||
| 41 | { | ||
| 42 | std::string name; | ||
| 43 | // ripped from disasm | ||
| 44 | uint8_t cond = (insn >> 28) & 0xf; | ||
| 45 | uint32_t i_offset = insn & 0xffffff; | ||
| 46 | // Sign-extend the 24-bit offset | ||
| 47 | if ((i_offset >> 23) & 1) | ||
| 48 | i_offset |= 0xff000000; | ||
| 49 | |||
| 50 | // Pre-compute the left-shift and the prefetch offset | ||
| 51 | i_offset <<= 2; | ||
| 52 | i_offset += 8; | ||
| 53 | func_addr = call_addr + i_offset; | ||
| 54 | |||
| 55 | callstack_model->setItem(counter, 0, new QStandardItem(QString("0x%1").arg(addr, 8, 16, QLatin1Char('0')))); | ||
| 56 | callstack_model->setItem(counter, 1, new QStandardItem(QString("0x%1").arg(ret_addr, 8, 16, QLatin1Char('0')))); | ||
| 57 | callstack_model->setItem(counter, 2, new QStandardItem(QString("0x%1").arg(call_addr, 8, 16, QLatin1Char('0')))); | ||
| 58 | |||
| 59 | name = Symbols::HasSymbol(func_addr) ? Symbols::GetSymbol(func_addr).name : "unknown"; | ||
| 60 | callstack_model->setItem(counter, 3, new QStandardItem(QString("%1_%2").arg(QString::fromStdString(name)) | ||
| 61 | .arg(QString("0x%1").arg(func_addr, 8, 16, QLatin1Char('0'))))); | ||
| 62 | |||
| 63 | counter++; | ||
| 64 | } | ||
| 65 | } | ||
| 66 | } \ No newline at end of file | ||
diff --git a/src/citra_qt/debugger/callstack.hxx b/src/citra_qt/debugger/callstack.hxx new file mode 100644 index 000000000..3ad2af28b --- /dev/null +++ b/src/citra_qt/debugger/callstack.hxx | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | #include <QDockWidget> | ||
| 2 | #include "../ui_callstack.h" | ||
| 3 | |||
| 4 | class QStandardItemModel; | ||
| 5 | |||
| 6 | class CallstackWidget : public QDockWidget | ||
| 7 | { | ||
| 8 | Q_OBJECT | ||
| 9 | |||
| 10 | public: | ||
| 11 | CallstackWidget(QWidget* parent = 0); | ||
| 12 | |||
| 13 | public slots: | ||
| 14 | void OnCPUStepped(); | ||
| 15 | |||
| 16 | private: | ||
| 17 | Ui::CallStack ui; | ||
| 18 | QStandardItemModel* callstack_model; | ||
| 19 | }; | ||
diff --git a/src/citra_qt/debugger/callstack.ui b/src/citra_qt/debugger/callstack.ui new file mode 100644 index 000000000..b3c4db632 --- /dev/null +++ b/src/citra_qt/debugger/callstack.ui | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <ui version="4.0"> | ||
| 3 | <class>CallStack</class> | ||
| 4 | <widget class="QDockWidget" name="CallStack"> | ||
| 5 | <property name="geometry"> | ||
| 6 | <rect> | ||
| 7 | <x>0</x> | ||
| 8 | <y>0</y> | ||
| 9 | <width>400</width> | ||
| 10 | <height>300</height> | ||
| 11 | </rect> | ||
| 12 | </property> | ||
| 13 | <property name="windowTitle"> | ||
| 14 | <string>Call stack</string> | ||
| 15 | </property> | ||
| 16 | <widget class="QWidget" name="dockWidgetContents"> | ||
| 17 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
| 18 | <item> | ||
| 19 | <widget class="QTreeView" name="treeView"> | ||
| 20 | <property name="alternatingRowColors"> | ||
| 21 | <bool>true</bool> | ||
| 22 | </property> | ||
| 23 | <property name="rootIsDecorated"> | ||
| 24 | <bool>false</bool> | ||
| 25 | </property> | ||
| 26 | <property name="itemsExpandable"> | ||
| 27 | <bool>false</bool> | ||
| 28 | </property> | ||
| 29 | </widget> | ||
| 30 | </item> | ||
| 31 | </layout> | ||
| 32 | </widget> | ||
| 33 | </widget> | ||
| 34 | <resources/> | ||
| 35 | <connections/> | ||
| 36 | </ui> | ||
diff --git a/src/citra_qt/debugger/disassembler.cpp b/src/citra_qt/debugger/disassembler.cpp new file mode 100644 index 000000000..cc4cb13fa --- /dev/null +++ b/src/citra_qt/debugger/disassembler.cpp | |||
| @@ -0,0 +1,161 @@ | |||
| 1 | #include <QtGui> | ||
| 2 | |||
| 3 | #include "disassembler.hxx" | ||
| 4 | |||
| 5 | #include "../bootmanager.hxx" | ||
| 6 | #include "../hotkeys.hxx" | ||
| 7 | |||
| 8 | #include "common/common.h" | ||
| 9 | #include "core/mem_map.h" | ||
| 10 | |||
| 11 | #include "core/core.h" | ||
| 12 | #include "common/break_points.h" | ||
| 13 | #include "common/symbols.h" | ||
| 14 | #include "core/arm/interpreter/armdefs.h" | ||
| 15 | #include "core/arm/disassembler/arm_disasm.h" | ||
| 16 | |||
| 17 | DisassemblerWidget::DisassemblerWidget(QWidget* parent, EmuThread& emu_thread) : QDockWidget(parent), base_addr(0), emu_thread(emu_thread) | ||
| 18 | { | ||
| 19 | disasm_ui.setupUi(this); | ||
| 20 | |||
| 21 | breakpoints = new BreakPoints(); | ||
| 22 | |||
| 23 | model = new QStandardItemModel(this); | ||
| 24 | model->setColumnCount(3); | ||
| 25 | disasm_ui.treeView->setModel(model); | ||
| 26 | disasm_ui.tableView->setModel(model); | ||
| 27 | RegisterHotkey("Disassembler", "Start/Stop", QKeySequence(Qt::Key_F5), Qt::ApplicationShortcut); | ||
| 28 | RegisterHotkey("Disassembler", "Step", QKeySequence(Qt::Key_F10), Qt::ApplicationShortcut); | ||
| 29 | RegisterHotkey("Disassembler", "Step into", QKeySequence(Qt::Key_F11), Qt::ApplicationShortcut); | ||
| 30 | RegisterHotkey("Disassembler", "Set Breakpoint", QKeySequence(Qt::Key_F9), Qt::ApplicationShortcut); | ||
| 31 | |||
| 32 | connect(disasm_ui.button_breakpoint, SIGNAL(clicked()), this, SLOT(OnSetBreakpoint())); | ||
| 33 | connect(disasm_ui.button_step, SIGNAL(clicked()), this, SLOT(OnStep())); | ||
| 34 | connect(disasm_ui.button_pause, SIGNAL(clicked()), this, SLOT(OnPause())); | ||
| 35 | connect(disasm_ui.button_continue, SIGNAL(clicked()), this, SLOT(OnContinue())); | ||
| 36 | |||
| 37 | connect(GetHotkey("Disassembler", "Start/Stop", this), SIGNAL(activated()), this, SLOT(OnToggleStartStop())); | ||
| 38 | connect(GetHotkey("Disassembler", "Step", this), SIGNAL(activated()), this, SLOT(OnStep())); | ||
| 39 | connect(GetHotkey("Disassembler", "Step into", this), SIGNAL(activated()), this, SLOT(OnStepInto())); | ||
| 40 | connect(GetHotkey("Disassembler", "Set Breakpoint", this), SIGNAL(activated()), this, SLOT(OnSetBreakpoint())); | ||
| 41 | } | ||
| 42 | |||
| 43 | void DisassemblerWidget::Init() | ||
| 44 | { | ||
| 45 | ARM_Disasm* disasm = new ARM_Disasm(); | ||
| 46 | |||
| 47 | base_addr = Core::g_app_core->GetPC(); | ||
| 48 | unsigned int curInstAddr = base_addr; | ||
| 49 | char result[255]; | ||
| 50 | |||
| 51 | for (int i = 0; i < 10000; i++) // fixed for now | ||
| 52 | { | ||
| 53 | disasm->disasm(curInstAddr, Memory::Read32(curInstAddr), result); | ||
| 54 | model->setItem(i, 0, new QStandardItem(QString("0x%1").arg((uint)(curInstAddr), 8, 16, QLatin1Char('0')))); | ||
| 55 | model->setItem(i, 1, new QStandardItem(QString(result))); | ||
| 56 | if (Symbols::HasSymbol(curInstAddr)) | ||
| 57 | { | ||
| 58 | TSymbol symbol = Symbols::GetSymbol(curInstAddr); | ||
| 59 | model->setItem(i, 2, new QStandardItem(QString("%1 - Size:%2").arg(QString::fromStdString(symbol.name)) | ||
| 60 | .arg(symbol.size / 4))); // divide by 4 to get instruction count | ||
| 61 | |||
| 62 | } | ||
| 63 | curInstAddr += 4; | ||
| 64 | } | ||
| 65 | disasm_ui.treeView->resizeColumnToContents(0); | ||
| 66 | disasm_ui.treeView->resizeColumnToContents(1); | ||
| 67 | disasm_ui.treeView->resizeColumnToContents(2); | ||
| 68 | disasm_ui.tableView->resizeColumnToContents(0); | ||
| 69 | disasm_ui.tableView->resizeColumnToContents(1); | ||
| 70 | disasm_ui.tableView->resizeColumnToContents(2); | ||
| 71 | |||
| 72 | QModelIndex model_index = model->index(0, 0); | ||
| 73 | disasm_ui.treeView->scrollTo(model_index); | ||
| 74 | disasm_ui.treeView->selectionModel()->setCurrentIndex(model_index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); | ||
| 75 | |||
| 76 | disasm_ui.tableView->scrollTo(model_index); | ||
| 77 | disasm_ui.tableView->selectionModel()->setCurrentIndex(model_index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); | ||
| 78 | } | ||
| 79 | |||
| 80 | void DisassemblerWidget::OnSetBreakpoint() | ||
| 81 | { | ||
| 82 | int selected_row = SelectedRow(); | ||
| 83 | |||
| 84 | if (selected_row == -1) | ||
| 85 | return; | ||
| 86 | |||
| 87 | u32 address = base_addr + (selected_row * 4); | ||
| 88 | if (breakpoints->IsAddressBreakPoint(address)) | ||
| 89 | { | ||
| 90 | breakpoints->Remove(address); | ||
| 91 | model->item(selected_row, 0)->setBackground(QBrush()); | ||
| 92 | model->item(selected_row, 1)->setBackground(QBrush()); | ||
| 93 | } | ||
| 94 | else | ||
| 95 | { | ||
| 96 | breakpoints->Add(address); | ||
| 97 | model->item(selected_row, 0)->setBackground(QBrush(QColor(0xFF, 0x99, 0x99))); | ||
| 98 | model->item(selected_row, 1)->setBackground(QBrush(QColor(0xFF, 0x99, 0x99))); | ||
| 99 | } | ||
| 100 | } | ||
| 101 | |||
| 102 | void DisassemblerWidget::OnContinue() | ||
| 103 | { | ||
| 104 | emu_thread.SetCpuRunning(true); | ||
| 105 | } | ||
| 106 | |||
| 107 | void DisassemblerWidget::OnStep() | ||
| 108 | { | ||
| 109 | OnStepInto(); // change later | ||
| 110 | } | ||
| 111 | |||
| 112 | void DisassemblerWidget::OnStepInto() | ||
| 113 | { | ||
| 114 | emu_thread.SetCpuRunning(false); | ||
| 115 | emu_thread.ExecStep(); | ||
| 116 | } | ||
| 117 | |||
| 118 | void DisassemblerWidget::OnPause() | ||
| 119 | { | ||
| 120 | emu_thread.SetCpuRunning(false); | ||
| 121 | } | ||
| 122 | |||
| 123 | void DisassemblerWidget::OnToggleStartStop() | ||
| 124 | { | ||
| 125 | emu_thread.SetCpuRunning(!emu_thread.IsCpuRunning()); | ||
| 126 | } | ||
| 127 | |||
| 128 | void DisassemblerWidget::OnCPUStepped() | ||
| 129 | { | ||
| 130 | ARMword next_instr = Core::g_app_core->GetPC(); | ||
| 131 | |||
| 132 | if (breakpoints->IsAddressBreakPoint(next_instr)) | ||
| 133 | { | ||
| 134 | emu_thread.SetCpuRunning(false); | ||
| 135 | } | ||
| 136 | |||
| 137 | unsigned int index = (next_instr - base_addr) / 4; | ||
| 138 | QModelIndex model_index = model->index(index, 0); | ||
| 139 | disasm_ui.treeView->scrollTo(model_index); | ||
| 140 | disasm_ui.treeView->selectionModel()->setCurrentIndex(model_index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); | ||
| 141 | |||
| 142 | disasm_ui.tableView->scrollTo(model_index); | ||
| 143 | disasm_ui.tableView->selectionModel()->setCurrentIndex(model_index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); | ||
| 144 | disasm_ui.tableView->selectionModel()->select(model_index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); | ||
| 145 | } | ||
| 146 | |||
| 147 | int DisassemblerWidget::SelectedRow() | ||
| 148 | { | ||
| 149 | QModelIndex index = disasm_ui.treeView->selectionModel()->currentIndex(); | ||
| 150 | if (!index.isValid()) | ||
| 151 | return -1; | ||
| 152 | |||
| 153 | return model->itemFromIndex(disasm_ui.treeView->selectionModel()->currentIndex())->row(); | ||
| 154 | } | ||
| 155 | /* | ||
| 156 | void DisassemblerWidget::paintEvent() | ||
| 157 | { | ||
| 158 | QPainter painter(this); | ||
| 159 | painter.drawRect(10, 10, 50, 50); | ||
| 160 | } | ||
| 161 | */ \ No newline at end of file | ||
diff --git a/src/citra_qt/debugger/disassembler.hxx b/src/citra_qt/debugger/disassembler.hxx new file mode 100644 index 000000000..e5b152d20 --- /dev/null +++ b/src/citra_qt/debugger/disassembler.hxx | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | #include <QDockWidget> | ||
| 2 | #include "../ui_disassembler.h" | ||
| 3 | |||
| 4 | #include "common/common.h" | ||
| 5 | #include "common/break_points.h" | ||
| 6 | |||
| 7 | class QAction; | ||
| 8 | class QStandardItemModel; | ||
| 9 | class EmuThread; | ||
| 10 | |||
| 11 | class DisassemblerWidget : public QDockWidget | ||
| 12 | { | ||
| 13 | Q_OBJECT | ||
| 14 | |||
| 15 | public: | ||
| 16 | DisassemblerWidget(QWidget* parent, EmuThread& emu_thread); | ||
| 17 | |||
| 18 | void Init(); | ||
| 19 | |||
| 20 | public slots: | ||
| 21 | void OnSetBreakpoint(); | ||
| 22 | void OnContinue(); | ||
| 23 | void OnStep(); | ||
| 24 | void OnStepInto(); | ||
| 25 | void OnPause(); | ||
| 26 | void OnToggleStartStop(); | ||
| 27 | |||
| 28 | void OnCPUStepped(); | ||
| 29 | |||
| 30 | private: | ||
| 31 | // returns -1 if no row is selected | ||
| 32 | int SelectedRow(); | ||
| 33 | |||
| 34 | Ui::DockWidget disasm_ui; | ||
| 35 | QStandardItemModel* model; | ||
| 36 | |||
| 37 | u32 base_addr; | ||
| 38 | |||
| 39 | BreakPoints* breakpoints; | ||
| 40 | |||
| 41 | EmuThread& emu_thread; | ||
| 42 | }; | ||
diff --git a/src/citra_qt/debugger/disassembler.ui b/src/citra_qt/debugger/disassembler.ui new file mode 100644 index 000000000..e65b0aa9b --- /dev/null +++ b/src/citra_qt/debugger/disassembler.ui | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <ui version="4.0"> | ||
| 3 | <class>DockWidget</class> | ||
| 4 | <widget class="QDockWidget" name="DockWidget"> | ||
| 5 | <property name="geometry"> | ||
| 6 | <rect> | ||
| 7 | <x>0</x> | ||
| 8 | <y>0</y> | ||
| 9 | <width>430</width> | ||
| 10 | <height>401</height> | ||
| 11 | </rect> | ||
| 12 | </property> | ||
| 13 | <property name="windowTitle"> | ||
| 14 | <string>Disassembly</string> | ||
| 15 | </property> | ||
| 16 | <widget class="QWidget" name="dockWidgetContents"> | ||
| 17 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
| 18 | <item> | ||
| 19 | <layout class="QHBoxLayout" name="horizontalLayout"> | ||
| 20 | <item> | ||
| 21 | <widget class="QPushButton" name="button_step"> | ||
| 22 | <property name="text"> | ||
| 23 | <string>Step</string> | ||
| 24 | </property> | ||
| 25 | </widget> | ||
| 26 | </item> | ||
| 27 | <item> | ||
| 28 | <widget class="QPushButton" name="button_pause"> | ||
| 29 | <property name="text"> | ||
| 30 | <string>Pause</string> | ||
| 31 | </property> | ||
| 32 | </widget> | ||
| 33 | </item> | ||
| 34 | <item> | ||
| 35 | <widget class="QPushButton" name="button_continue"> | ||
| 36 | <property name="text"> | ||
| 37 | <string>Continue</string> | ||
| 38 | </property> | ||
| 39 | </widget> | ||
| 40 | </item> | ||
| 41 | <item> | ||
| 42 | <widget class="QPushButton" name="pushButton"> | ||
| 43 | <property name="text"> | ||
| 44 | <string>Step Into</string> | ||
| 45 | </property> | ||
| 46 | </widget> | ||
| 47 | </item> | ||
| 48 | <item> | ||
| 49 | <widget class="QPushButton" name="button_breakpoint"> | ||
| 50 | <property name="text"> | ||
| 51 | <string>Set Breakpoint</string> | ||
| 52 | </property> | ||
| 53 | </widget> | ||
| 54 | </item> | ||
| 55 | </layout> | ||
| 56 | </item> | ||
| 57 | <item> | ||
| 58 | <widget class="QTreeView" name="treeView"> | ||
| 59 | <property name="alternatingRowColors"> | ||
| 60 | <bool>true</bool> | ||
| 61 | </property> | ||
| 62 | <property name="indentation"> | ||
| 63 | <number>20</number> | ||
| 64 | </property> | ||
| 65 | <property name="rootIsDecorated"> | ||
| 66 | <bool>false</bool> | ||
| 67 | </property> | ||
| 68 | <attribute name="headerVisible"> | ||
| 69 | <bool>false</bool> | ||
| 70 | </attribute> | ||
| 71 | </widget> | ||
| 72 | </item> | ||
| 73 | <item> | ||
| 74 | <widget class="QTableView" name="tableView"> | ||
| 75 | <property name="alternatingRowColors"> | ||
| 76 | <bool>true</bool> | ||
| 77 | </property> | ||
| 78 | <attribute name="headerVisible"> | ||
| 79 | <bool>false</bool> | ||
| 80 | </attribute> | ||
| 81 | </widget> | ||
| 82 | </item> | ||
| 83 | </layout> | ||
| 84 | </widget> | ||
| 85 | </widget> | ||
| 86 | <resources/> | ||
| 87 | <connections/> | ||
| 88 | </ui> | ||
diff --git a/src/citra_qt/debugger/ramview.cpp b/src/citra_qt/debugger/ramview.cpp new file mode 100644 index 000000000..3f899b95e --- /dev/null +++ b/src/citra_qt/debugger/ramview.cpp | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | #include "ramview.hxx" | ||
| 2 | |||
| 3 | #include "common/common.h" | ||
| 4 | #include "core/mem_map.h" | ||
| 5 | GRamView::GRamView(QWidget* parent) : QHexEdit(parent) | ||
| 6 | { | ||
| 7 | } | ||
| 8 | |||
| 9 | void GRamView::OnCPUStepped() | ||
| 10 | { | ||
| 11 | // TODO: QHexEdit doesn't show vertical scroll bars for > 10MB data streams... | ||
| 12 | //setData(QByteArray((const char*)Mem_RAM,sizeof(Mem_RAM)/8)); | ||
| 13 | } \ No newline at end of file | ||
diff --git a/src/citra_qt/debugger/ramview.hxx b/src/citra_qt/debugger/ramview.hxx new file mode 100644 index 000000000..1db1546aa --- /dev/null +++ b/src/citra_qt/debugger/ramview.hxx | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | #include "qhexedit.h" | ||
| 2 | |||
| 3 | class GRamView : public QHexEdit | ||
| 4 | { | ||
| 5 | Q_OBJECT | ||
| 6 | |||
| 7 | public: | ||
| 8 | GRamView(QWidget* parent = NULL); | ||
| 9 | |||
| 10 | public slots: | ||
| 11 | void OnCPUStepped(); | ||
| 12 | }; | ||
diff --git a/src/citra_qt/debugger/registers.cpp b/src/citra_qt/debugger/registers.cpp new file mode 100644 index 000000000..96ceed480 --- /dev/null +++ b/src/citra_qt/debugger/registers.cpp | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | #include "registers.hxx" | ||
| 2 | |||
| 3 | #include "core/core.h" | ||
| 4 | #include "core/arm/arm_interface.h" | ||
| 5 | |||
| 6 | RegistersWidget::RegistersWidget(QWidget* parent) : QDockWidget(parent) | ||
| 7 | { | ||
| 8 | cpu_regs_ui.setupUi(this); | ||
| 9 | |||
| 10 | tree = cpu_regs_ui.treeWidget; | ||
| 11 | tree->addTopLevelItem(registers = new QTreeWidgetItem(QStringList("Registers"))); | ||
| 12 | tree->addTopLevelItem(CSPR = new QTreeWidgetItem(QStringList("CSPR"))); | ||
| 13 | |||
| 14 | registers->setExpanded(true); | ||
| 15 | CSPR->setExpanded(true); | ||
| 16 | |||
| 17 | for (int i = 0; i < 16; ++i) | ||
| 18 | { | ||
| 19 | QTreeWidgetItem* child = new QTreeWidgetItem(QStringList(QString("R[%1]").arg(i, 2, 10, QLatin1Char('0')))); | ||
| 20 | registers->addChild(child); | ||
| 21 | } | ||
| 22 | |||
| 23 | CSPR->addChild(new QTreeWidgetItem(QStringList("M"))); | ||
| 24 | CSPR->addChild(new QTreeWidgetItem(QStringList("T"))); | ||
| 25 | CSPR->addChild(new QTreeWidgetItem(QStringList("F"))); | ||
| 26 | CSPR->addChild(new QTreeWidgetItem(QStringList("I"))); | ||
| 27 | CSPR->addChild(new QTreeWidgetItem(QStringList("A"))); | ||
| 28 | CSPR->addChild(new QTreeWidgetItem(QStringList("E"))); | ||
| 29 | CSPR->addChild(new QTreeWidgetItem(QStringList("IT"))); | ||
| 30 | CSPR->addChild(new QTreeWidgetItem(QStringList("GE"))); | ||
| 31 | CSPR->addChild(new QTreeWidgetItem(QStringList("DNM"))); | ||
| 32 | CSPR->addChild(new QTreeWidgetItem(QStringList("J"))); | ||
| 33 | CSPR->addChild(new QTreeWidgetItem(QStringList("Q"))); | ||
| 34 | CSPR->addChild(new QTreeWidgetItem(QStringList("V"))); | ||
| 35 | CSPR->addChild(new QTreeWidgetItem(QStringList("C"))); | ||
| 36 | CSPR->addChild(new QTreeWidgetItem(QStringList("Z"))); | ||
| 37 | CSPR->addChild(new QTreeWidgetItem(QStringList("N"))); | ||
| 38 | } | ||
| 39 | |||
| 40 | void RegistersWidget::OnCPUStepped() | ||
| 41 | { | ||
| 42 | ARM_Interface* app_core = Core::g_app_core; | ||
| 43 | |||
| 44 | for (int i = 0; i < 16; ++i) | ||
| 45 | registers->child(i)->setText(1, QString("0x%1").arg(app_core->GetReg(i), 8, 16, QLatin1Char('0'))); | ||
| 46 | |||
| 47 | CSPR->setText(1, QString("0x%1").arg(app_core->GetCPSR(), 8, 16, QLatin1Char('0'))); | ||
| 48 | CSPR->child(0)->setText(1, QString("b%1").arg(app_core->GetCPSR() & 0x1F, 5, 2, QLatin1Char('0'))); // M - Mode | ||
| 49 | CSPR->child(1)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 5) & 0x1)); // T - State | ||
| 50 | CSPR->child(2)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 6) & 0x1)); // F - FIQ disable | ||
| 51 | CSPR->child(3)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 7) & 0x1)); // I - IRQ disable | ||
| 52 | CSPR->child(4)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 8) & 0x1)); // A - Imprecise abort | ||
| 53 | CSPR->child(5)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 9) & 0x1)); // E - Data endianess | ||
| 54 | CSPR->child(6)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 10) & 0x3F)); // IT - If-Then state (DNM) | ||
| 55 | CSPR->child(7)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 16) & 0xF)); // GE - Greater-than-or-Equal | ||
| 56 | CSPR->child(8)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 20) & 0xF)); // DNM - Do not modify | ||
| 57 | CSPR->child(9)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 24) & 0x1)); // J - Java state | ||
| 58 | CSPR->child(10)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 27) & 0x1)); // Q - Sticky overflow | ||
| 59 | CSPR->child(11)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 28) & 0x1)); // V - Overflow | ||
| 60 | CSPR->child(12)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 29) & 0x1)); // C - Carry/Borrow/Extend | ||
| 61 | CSPR->child(13)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 30) & 0x1)); // Z - Zero | ||
| 62 | CSPR->child(14)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 31) & 0x1)); // N - Negative/Less than | ||
| 63 | } | ||
diff --git a/src/citra_qt/debugger/registers.hxx b/src/citra_qt/debugger/registers.hxx new file mode 100644 index 000000000..318d95820 --- /dev/null +++ b/src/citra_qt/debugger/registers.hxx | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | #include "../ui_registers.h" | ||
| 2 | |||
| 3 | #include <QDockWidget> | ||
| 4 | #include <QTreeWidgetItem> | ||
| 5 | |||
| 6 | class QTreeWidget; | ||
| 7 | |||
| 8 | class RegistersWidget : public QDockWidget | ||
| 9 | { | ||
| 10 | Q_OBJECT | ||
| 11 | |||
| 12 | public: | ||
| 13 | RegistersWidget(QWidget* parent = NULL); | ||
| 14 | |||
| 15 | public slots: | ||
| 16 | void OnCPUStepped(); | ||
| 17 | |||
| 18 | private: | ||
| 19 | Ui::ARMRegisters cpu_regs_ui; | ||
| 20 | |||
| 21 | QTreeWidget* tree; | ||
| 22 | |||
| 23 | QTreeWidgetItem* registers; | ||
| 24 | QTreeWidgetItem* CSPR; | ||
| 25 | }; | ||
diff --git a/src/citra_qt/debugger/registers.ui b/src/citra_qt/debugger/registers.ui new file mode 100644 index 000000000..6537c9cd6 --- /dev/null +++ b/src/citra_qt/debugger/registers.ui | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <ui version="4.0"> | ||
| 3 | <class>ARMRegisters</class> | ||
| 4 | <widget class="QDockWidget" name="ARMRegisters"> | ||
| 5 | <property name="geometry"> | ||
| 6 | <rect> | ||
| 7 | <x>0</x> | ||
| 8 | <y>0</y> | ||
| 9 | <width>400</width> | ||
| 10 | <height>300</height> | ||
| 11 | </rect> | ||
| 12 | </property> | ||
| 13 | <property name="windowTitle"> | ||
| 14 | <string>ARM registers</string> | ||
| 15 | </property> | ||
| 16 | <widget class="QWidget" name="dockWidgetContents"> | ||
| 17 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
| 18 | <item> | ||
| 19 | <widget class="QTreeWidget" name="treeWidget"> | ||
| 20 | <property name="alternatingRowColors"> | ||
| 21 | <bool>true</bool> | ||
| 22 | </property> | ||
| 23 | <column> | ||
| 24 | <property name="text"> | ||
| 25 | <string>Register</string> | ||
| 26 | </property> | ||
| 27 | </column> | ||
| 28 | <column> | ||
| 29 | <property name="text"> | ||
| 30 | <string>Value</string> | ||
| 31 | </property> | ||
| 32 | </column> | ||
| 33 | </widget> | ||
| 34 | </item> | ||
| 35 | </layout> | ||
| 36 | </widget> | ||
| 37 | </widget> | ||
| 38 | <resources/> | ||
| 39 | <connections/> | ||
| 40 | </ui> | ||