diff options
Diffstat (limited to 'src/citra_qt/debugger/graphics_breakpoints.cpp')
| -rw-r--r-- | src/citra_qt/debugger/graphics_breakpoints.cpp | 106 |
1 files changed, 39 insertions, 67 deletions
diff --git a/src/citra_qt/debugger/graphics_breakpoints.cpp b/src/citra_qt/debugger/graphics_breakpoints.cpp index fe66918a8..d2a036dfa 100644 --- a/src/citra_qt/debugger/graphics_breakpoints.cpp +++ b/src/citra_qt/debugger/graphics_breakpoints.cpp | |||
| @@ -7,47 +7,39 @@ | |||
| 7 | #include <QPushButton> | 7 | #include <QPushButton> |
| 8 | #include <QTreeView> | 8 | #include <QTreeView> |
| 9 | #include <QVBoxLayout> | 9 | #include <QVBoxLayout> |
| 10 | |||
| 11 | #include "citra_qt/debugger/graphics_breakpoints.h" | 10 | #include "citra_qt/debugger/graphics_breakpoints.h" |
| 12 | #include "citra_qt/debugger/graphics_breakpoints_p.h" | 11 | #include "citra_qt/debugger/graphics_breakpoints_p.h" |
| 13 | |||
| 14 | #include "common/assert.h" | 12 | #include "common/assert.h" |
| 15 | 13 | ||
| 16 | BreakPointModel::BreakPointModel(std::shared_ptr<Pica::DebugContext> debug_context, QObject* parent) | 14 | BreakPointModel::BreakPointModel(std::shared_ptr<Pica::DebugContext> debug_context, QObject* parent) |
| 17 | : QAbstractListModel(parent), context_weak(debug_context), | 15 | : QAbstractListModel(parent), context_weak(debug_context), |
| 18 | at_breakpoint(debug_context->at_breakpoint), | 16 | at_breakpoint(debug_context->at_breakpoint), |
| 19 | active_breakpoint(debug_context->active_breakpoint) | 17 | active_breakpoint(debug_context->active_breakpoint) {} |
| 20 | { | ||
| 21 | |||
| 22 | } | ||
| 23 | 18 | ||
| 24 | int BreakPointModel::columnCount(const QModelIndex& parent) const | 19 | int BreakPointModel::columnCount(const QModelIndex& parent) const { |
| 25 | { | ||
| 26 | return 1; | 20 | return 1; |
| 27 | } | 21 | } |
| 28 | 22 | ||
| 29 | int BreakPointModel::rowCount(const QModelIndex& parent) const | 23 | int BreakPointModel::rowCount(const QModelIndex& parent) const { |
| 30 | { | ||
| 31 | return static_cast<int>(Pica::DebugContext::Event::NumEvents); | 24 | return static_cast<int>(Pica::DebugContext::Event::NumEvents); |
| 32 | } | 25 | } |
| 33 | 26 | ||
| 34 | QVariant BreakPointModel::data(const QModelIndex& index, int role) const | 27 | QVariant BreakPointModel::data(const QModelIndex& index, int role) const { |
| 35 | { | ||
| 36 | const auto event = static_cast<Pica::DebugContext::Event>(index.row()); | 28 | const auto event = static_cast<Pica::DebugContext::Event>(index.row()); |
| 37 | 29 | ||
| 38 | switch (role) { | 30 | switch (role) { |
| 39 | case Qt::DisplayRole: | 31 | case Qt::DisplayRole: { |
| 40 | { | ||
| 41 | if (index.column() == 0) { | 32 | if (index.column() == 0) { |
| 42 | static const std::map<Pica::DebugContext::Event, QString> map = { | 33 | static const std::map<Pica::DebugContext::Event, QString> map = { |
| 43 | { Pica::DebugContext::Event::PicaCommandLoaded, tr("Pica command loaded") }, | 34 | {Pica::DebugContext::Event::PicaCommandLoaded, tr("Pica command loaded")}, |
| 44 | { Pica::DebugContext::Event::PicaCommandProcessed, tr("Pica command processed") }, | 35 | {Pica::DebugContext::Event::PicaCommandProcessed, tr("Pica command processed")}, |
| 45 | { Pica::DebugContext::Event::IncomingPrimitiveBatch, tr("Incoming primitive batch") }, | 36 | {Pica::DebugContext::Event::IncomingPrimitiveBatch, tr("Incoming primitive batch")}, |
| 46 | { Pica::DebugContext::Event::FinishedPrimitiveBatch, tr("Finished primitive batch") }, | 37 | {Pica::DebugContext::Event::FinishedPrimitiveBatch, tr("Finished primitive batch")}, |
| 47 | { Pica::DebugContext::Event::VertexShaderInvocation, tr("Vertex shader invocation") }, | 38 | {Pica::DebugContext::Event::VertexShaderInvocation, tr("Vertex shader invocation")}, |
| 48 | { Pica::DebugContext::Event::IncomingDisplayTransfer, tr("Incoming display transfer") }, | 39 | {Pica::DebugContext::Event::IncomingDisplayTransfer, |
| 49 | { Pica::DebugContext::Event::GSPCommandProcessed, tr("GSP command processed") }, | 40 | tr("Incoming display transfer")}, |
| 50 | { Pica::DebugContext::Event::BufferSwapped, tr("Buffers swapped") } | 41 | {Pica::DebugContext::Event::GSPCommandProcessed, tr("GSP command processed")}, |
| 42 | {Pica::DebugContext::Event::BufferSwapped, tr("Buffers swapped")}, | ||
| 51 | }; | 43 | }; |
| 52 | 44 | ||
| 53 | DEBUG_ASSERT(map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents)); | 45 | DEBUG_ASSERT(map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents)); |
| @@ -57,23 +49,20 @@ QVariant BreakPointModel::data(const QModelIndex& index, int role) const | |||
| 57 | break; | 49 | break; |
| 58 | } | 50 | } |
| 59 | 51 | ||
| 60 | case Qt::CheckStateRole: | 52 | case Qt::CheckStateRole: { |
| 61 | { | ||
| 62 | if (index.column() == 0) | 53 | if (index.column() == 0) |
| 63 | return data(index, Role_IsEnabled).toBool() ? Qt::Checked : Qt::Unchecked; | 54 | return data(index, Role_IsEnabled).toBool() ? Qt::Checked : Qt::Unchecked; |
| 64 | break; | 55 | break; |
| 65 | } | 56 | } |
| 66 | 57 | ||
| 67 | case Qt::BackgroundRole: | 58 | case Qt::BackgroundRole: { |
| 68 | { | ||
| 69 | if (at_breakpoint && index.row() == static_cast<int>(active_breakpoint)) { | 59 | if (at_breakpoint && index.row() == static_cast<int>(active_breakpoint)) { |
| 70 | return QBrush(QColor(0xE0, 0xE0, 0x10)); | 60 | return QBrush(QColor(0xE0, 0xE0, 0x10)); |
| 71 | } | 61 | } |
| 72 | break; | 62 | break; |
| 73 | } | 63 | } |
| 74 | 64 | ||
| 75 | case Role_IsEnabled: | 65 | case Role_IsEnabled: { |
| 76 | { | ||
| 77 | auto context = context_weak.lock(); | 66 | auto context = context_weak.lock(); |
| 78 | return context && context->breakpoints[(int)event].enabled; | 67 | return context && context->breakpoints[(int)event].enabled; |
| 79 | } | 68 | } |
| @@ -84,8 +73,7 @@ QVariant BreakPointModel::data(const QModelIndex& index, int role) const | |||
| 84 | return QVariant(); | 73 | return QVariant(); |
| 85 | } | 74 | } |
| 86 | 75 | ||
| 87 | Qt::ItemFlags BreakPointModel::flags(const QModelIndex &index) const | 76 | Qt::ItemFlags BreakPointModel::flags(const QModelIndex& index) const { |
| 88 | { | ||
| 89 | if (!index.isValid()) | 77 | if (!index.isValid()) |
| 90 | return 0; | 78 | return 0; |
| 91 | 79 | ||
| @@ -95,14 +83,11 @@ Qt::ItemFlags BreakPointModel::flags(const QModelIndex &index) const | |||
| 95 | return flags; | 83 | return flags; |
| 96 | } | 84 | } |
| 97 | 85 | ||
| 98 | 86 | bool BreakPointModel::setData(const QModelIndex& index, const QVariant& value, int role) { | |
| 99 | bool BreakPointModel::setData(const QModelIndex& index, const QVariant& value, int role) | ||
| 100 | { | ||
| 101 | const auto event = static_cast<Pica::DebugContext::Event>(index.row()); | 87 | const auto event = static_cast<Pica::DebugContext::Event>(index.row()); |
| 102 | 88 | ||
| 103 | switch (role) { | 89 | switch (role) { |
| 104 | case Qt::CheckStateRole: | 90 | case Qt::CheckStateRole: { |
| 105 | { | ||
| 106 | if (index.column() != 0) | 91 | if (index.column() != 0) |
| 107 | return false; | 92 | return false; |
| 108 | 93 | ||
| @@ -120,9 +105,7 @@ bool BreakPointModel::setData(const QModelIndex& index, const QVariant& value, i | |||
| 120 | return false; | 105 | return false; |
| 121 | } | 106 | } |
| 122 | 107 | ||
| 123 | 108 | void BreakPointModel::OnBreakPointHit(Pica::DebugContext::Event event) { | |
| 124 | void BreakPointModel::OnBreakPointHit(Pica::DebugContext::Event event) | ||
| 125 | { | ||
| 126 | auto context = context_weak.lock(); | 109 | auto context = context_weak.lock(); |
| 127 | if (!context) | 110 | if (!context) |
| 128 | return; | 111 | return; |
| @@ -133,8 +116,7 @@ void BreakPointModel::OnBreakPointHit(Pica::DebugContext::Event event) | |||
| 133 | createIndex(static_cast<int>(event), 0)); | 116 | createIndex(static_cast<int>(event), 0)); |
| 134 | } | 117 | } |
| 135 | 118 | ||
| 136 | void BreakPointModel::OnResumed() | 119 | void BreakPointModel::OnResumed() { |
| 137 | { | ||
| 138 | auto context = context_weak.lock(); | 120 | auto context = context_weak.lock(); |
| 139 | if (!context) | 121 | if (!context) |
| 140 | return; | 122 | return; |
| @@ -145,12 +127,10 @@ void BreakPointModel::OnResumed() | |||
| 145 | active_breakpoint = context->active_breakpoint; | 127 | active_breakpoint = context->active_breakpoint; |
| 146 | } | 128 | } |
| 147 | 129 | ||
| 148 | 130 | GraphicsBreakPointsWidget::GraphicsBreakPointsWidget( | |
| 149 | GraphicsBreakPointsWidget::GraphicsBreakPointsWidget(std::shared_ptr<Pica::DebugContext> debug_context, | 131 | std::shared_ptr<Pica::DebugContext> debug_context, QWidget* parent) |
| 150 | QWidget* parent) | ||
| 151 | : QDockWidget(tr("Pica Breakpoints"), parent), | 132 | : QDockWidget(tr("Pica Breakpoints"), parent), |
| 152 | Pica::DebugContext::BreakPointObserver(debug_context) | 133 | Pica::DebugContext::BreakPointObserver(debug_context) { |
| 153 | { | ||
| 154 | setObjectName("PicaBreakPointsWidget"); | 134 | setObjectName("PicaBreakPointsWidget"); |
| 155 | 135 | ||
| 156 | status_text = new QLabel(tr("Emulation running")); | 136 | status_text = new QLabel(tr("Emulation running")); |
| @@ -165,23 +145,21 @@ GraphicsBreakPointsWidget::GraphicsBreakPointsWidget(std::shared_ptr<Pica::Debug | |||
| 165 | 145 | ||
| 166 | qRegisterMetaType<Pica::DebugContext::Event>("Pica::DebugContext::Event"); | 146 | qRegisterMetaType<Pica::DebugContext::Event>("Pica::DebugContext::Event"); |
| 167 | 147 | ||
| 168 | connect(breakpoint_list, SIGNAL(doubleClicked(const QModelIndex&)), | 148 | connect(breakpoint_list, SIGNAL(doubleClicked(const QModelIndex&)), this, |
| 169 | this, SLOT(OnItemDoubleClicked(const QModelIndex&))); | 149 | SLOT(OnItemDoubleClicked(const QModelIndex&))); |
| 170 | 150 | ||
| 171 | connect(resume_button, SIGNAL(clicked()), this, SLOT(OnResumeRequested())); | 151 | connect(resume_button, SIGNAL(clicked()), this, SLOT(OnResumeRequested())); |
| 172 | 152 | ||
| 173 | connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event,void*)), | 153 | connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event, void*)), this, |
| 174 | this, SLOT(OnBreakPointHit(Pica::DebugContext::Event,void*)), | 154 | SLOT(OnBreakPointHit(Pica::DebugContext::Event, void*)), Qt::BlockingQueuedConnection); |
| 175 | Qt::BlockingQueuedConnection); | ||
| 176 | connect(this, SIGNAL(Resumed()), this, SLOT(OnResumed())); | 155 | connect(this, SIGNAL(Resumed()), this, SLOT(OnResumed())); |
| 177 | 156 | ||
| 178 | connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event,void*)), | 157 | connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event, void*)), breakpoint_model, |
| 179 | breakpoint_model, SLOT(OnBreakPointHit(Pica::DebugContext::Event)), | 158 | SLOT(OnBreakPointHit(Pica::DebugContext::Event)), Qt::BlockingQueuedConnection); |
| 180 | Qt::BlockingQueuedConnection); | ||
| 181 | connect(this, SIGNAL(Resumed()), breakpoint_model, SLOT(OnResumed())); | 159 | connect(this, SIGNAL(Resumed()), breakpoint_model, SLOT(OnResumed())); |
| 182 | 160 | ||
| 183 | connect(this, SIGNAL(BreakPointsChanged(const QModelIndex&,const QModelIndex&)), | 161 | connect(this, SIGNAL(BreakPointsChanged(const QModelIndex&, const QModelIndex&)), |
| 184 | breakpoint_model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&))); | 162 | breakpoint_model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&))); |
| 185 | 163 | ||
| 186 | QWidget* main_widget = new QWidget; | 164 | QWidget* main_widget = new QWidget; |
| 187 | auto main_layout = new QVBoxLayout; | 165 | auto main_layout = new QVBoxLayout; |
| @@ -197,38 +175,32 @@ GraphicsBreakPointsWidget::GraphicsBreakPointsWidget(std::shared_ptr<Pica::Debug | |||
| 197 | setWidget(main_widget); | 175 | setWidget(main_widget); |
| 198 | } | 176 | } |
| 199 | 177 | ||
| 200 | void GraphicsBreakPointsWidget::OnPicaBreakPointHit(Event event, void* data) | 178 | void GraphicsBreakPointsWidget::OnPicaBreakPointHit(Event event, void* data) { |
| 201 | { | ||
| 202 | // Process in GUI thread | 179 | // Process in GUI thread |
| 203 | emit BreakPointHit(event, data); | 180 | emit BreakPointHit(event, data); |
| 204 | } | 181 | } |
| 205 | 182 | ||
| 206 | void GraphicsBreakPointsWidget::OnBreakPointHit(Pica::DebugContext::Event event, void* data) | 183 | void GraphicsBreakPointsWidget::OnBreakPointHit(Pica::DebugContext::Event event, void* data) { |
| 207 | { | ||
| 208 | status_text->setText(tr("Emulation halted at breakpoint")); | 184 | status_text->setText(tr("Emulation halted at breakpoint")); |
| 209 | resume_button->setEnabled(true); | 185 | resume_button->setEnabled(true); |
| 210 | } | 186 | } |
| 211 | 187 | ||
| 212 | void GraphicsBreakPointsWidget::OnPicaResume() | 188 | void GraphicsBreakPointsWidget::OnPicaResume() { |
| 213 | { | ||
| 214 | // Process in GUI thread | 189 | // Process in GUI thread |
| 215 | emit Resumed(); | 190 | emit Resumed(); |
| 216 | } | 191 | } |
| 217 | 192 | ||
| 218 | void GraphicsBreakPointsWidget::OnResumed() | 193 | void GraphicsBreakPointsWidget::OnResumed() { |
| 219 | { | ||
| 220 | status_text->setText(tr("Emulation running")); | 194 | status_text->setText(tr("Emulation running")); |
| 221 | resume_button->setEnabled(false); | 195 | resume_button->setEnabled(false); |
| 222 | } | 196 | } |
| 223 | 197 | ||
| 224 | void GraphicsBreakPointsWidget::OnResumeRequested() | 198 | void GraphicsBreakPointsWidget::OnResumeRequested() { |
| 225 | { | ||
| 226 | if (auto context = context_weak.lock()) | 199 | if (auto context = context_weak.lock()) |
| 227 | context->Resume(); | 200 | context->Resume(); |
| 228 | } | 201 | } |
| 229 | 202 | ||
| 230 | void GraphicsBreakPointsWidget::OnItemDoubleClicked(const QModelIndex& index) | 203 | void GraphicsBreakPointsWidget::OnItemDoubleClicked(const QModelIndex& index) { |
| 231 | { | ||
| 232 | if (!index.isValid()) | 204 | if (!index.isValid()) |
| 233 | return; | 205 | return; |
| 234 | 206 | ||