diff options
Diffstat (limited to '')
-rw-r--r-- | src/citra_qt/debugger/disassembler.cpp | 81 | ||||
-rw-r--r-- | src/citra_qt/debugger/disassembler.h | 9 |
2 files changed, 49 insertions, 41 deletions
diff --git a/src/citra_qt/debugger/disassembler.cpp b/src/citra_qt/debugger/disassembler.cpp index f9423e1d6..6400bb856 100644 --- a/src/citra_qt/debugger/disassembler.cpp +++ b/src/citra_qt/debugger/disassembler.cpp @@ -4,7 +4,6 @@ #include "disassembler.h" -#include "../main.h" #include "../bootmanager.h" #include "../hotkeys.h" @@ -19,8 +18,8 @@ #include "core/arm/disassembler/arm_disasm.h" -DisassemblerModel::DisassemblerModel(QObject* parent) : QAbstractListModel(parent), base_address(0), code_size(0), program_counter(0), selection(QModelIndex()) { - +DisassemblerModel::DisassemblerModel(QObject* parent) : + QAbstractListModel(parent), base_address(0), code_size(0), program_counter(0), selection(QModelIndex()) { } int DisassemblerModel::columnCount(const QModelIndex& parent) const { @@ -159,35 +158,28 @@ void DisassemblerModel::SetNextInstruction(unsigned int address) { emit dataChanged(prev_index, prev_index); } -DisassemblerWidget::DisassemblerWidget(QWidget* parent, GMainWindow& main_window) : - QDockWidget(parent), main_window(main_window), base_addr(0) { +DisassemblerWidget::DisassemblerWidget(QWidget* parent, EmuThread* emu_thread) : + QDockWidget(parent), emu_thread(emu_thread), base_addr(0) { disasm_ui.setupUi(this); - model = new DisassemblerModel(this); - disasm_ui.treeView->setModel(model); - RegisterHotkey("Disassembler", "Start/Stop", QKeySequence(Qt::Key_F5), Qt::ApplicationShortcut); RegisterHotkey("Disassembler", "Step", QKeySequence(Qt::Key_F10), Qt::ApplicationShortcut); RegisterHotkey("Disassembler", "Step into", QKeySequence(Qt::Key_F11), Qt::ApplicationShortcut); RegisterHotkey("Disassembler", "Set Breakpoint", QKeySequence(Qt::Key_F9), Qt::ApplicationShortcut); - connect(disasm_ui.button_breakpoint, SIGNAL(clicked()), model, SLOT(OnSetOrUnsetBreakpoint())); connect(disasm_ui.button_step, SIGNAL(clicked()), this, SLOT(OnStep())); connect(disasm_ui.button_pause, SIGNAL(clicked()), this, SLOT(OnPause())); connect(disasm_ui.button_continue, SIGNAL(clicked()), this, SLOT(OnContinue())); - connect(disasm_ui.treeView->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), - model, SLOT(OnSelectionChanged(const QModelIndex&))); - connect(GetHotkey("Disassembler", "Start/Stop", this), SIGNAL(activated()), this, SLOT(OnToggleStartStop())); connect(GetHotkey("Disassembler", "Step", this), SIGNAL(activated()), this, SLOT(OnStep())); connect(GetHotkey("Disassembler", "Step into", this), SIGNAL(activated()), this, SLOT(OnStepInto())); - connect(GetHotkey("Disassembler", "Set Breakpoint", this), SIGNAL(activated()), model, SLOT(OnSetOrUnsetBreakpoint())); + + setEnabled(false); } -void DisassemblerWidget::Init() -{ +void DisassemblerWidget::Init() { model->ParseFromAddress(Core::g_app_core->GetPC()); disasm_ui.treeView->resizeColumnToContents(0); @@ -199,25 +191,21 @@ void DisassemblerWidget::Init() disasm_ui.treeView->selectionModel()->setCurrentIndex(model_index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); } -void DisassemblerWidget::OnContinue() -{ - main_window.GetEmuThread()->SetRunning(true); +void DisassemblerWidget::OnContinue() { + emu_thread->SetRunning(true); } -void DisassemblerWidget::OnStep() -{ +void DisassemblerWidget::OnStep() { OnStepInto(); // change later } -void DisassemblerWidget::OnStepInto() -{ - main_window.GetEmuThread()->SetRunning(false); - main_window.GetEmuThread()->ExecStep(); +void DisassemblerWidget::OnStepInto() { + emu_thread->SetRunning(false); + emu_thread->ExecStep(); } -void DisassemblerWidget::OnPause() -{ - main_window.GetEmuThread()->SetRunning(false); +void DisassemblerWidget::OnPause() { + emu_thread->SetRunning(false); // TODO: By now, the CPU might not have actually stopped... if (Core::g_app_core) { @@ -225,17 +213,15 @@ void DisassemblerWidget::OnPause() } } -void DisassemblerWidget::OnToggleStartStop() -{ - main_window.GetEmuThread()->SetRunning(!main_window.GetEmuThread()->IsRunning()); +void DisassemblerWidget::OnToggleStartStop() { + emu_thread->SetRunning(!emu_thread->IsRunning()); } -void DisassemblerWidget::OnDebugModeEntered() -{ +void DisassemblerWidget::OnDebugModeEntered() { ARMword next_instr = Core::g_app_core->GetPC(); if (model->GetBreakPoints().IsAddressBreakPoint(next_instr)) - main_window.GetEmuThread()->SetRunning(false); + emu_thread->SetRunning(false); model->SetNextInstruction(next_instr); @@ -244,16 +230,35 @@ void DisassemblerWidget::OnDebugModeEntered() disasm_ui.treeView->selectionModel()->setCurrentIndex(model_index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); } -void DisassemblerWidget::OnDebugModeLeft() -{ - +void DisassemblerWidget::OnDebugModeLeft() { } -int DisassemblerWidget::SelectedRow() -{ +int DisassemblerWidget::SelectedRow() { QModelIndex index = disasm_ui.treeView->selectionModel()->currentIndex(); if (!index.isValid()) return -1; return disasm_ui.treeView->selectionModel()->currentIndex().row(); } + +void DisassemblerWidget::OnEmulationStarted(EmuThread* emu_thread) { + this->emu_thread = emu_thread; + + model = new DisassemblerModel(this); + disasm_ui.treeView->setModel(model); + + connect(disasm_ui.treeView->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), + model, SLOT(OnSelectionChanged(const QModelIndex&))); + connect(disasm_ui.button_breakpoint, SIGNAL(clicked()), model, SLOT(OnSetOrUnsetBreakpoint())); + connect(GetHotkey("Disassembler", "Set Breakpoint", this), SIGNAL(activated()), model, SLOT(OnSetOrUnsetBreakpoint())); + + Init(); + setEnabled(true); +} + +void DisassemblerWidget::OnEmulationStopped() { + disasm_ui.treeView->setModel(nullptr); + delete model; + emu_thread = nullptr; + setEnabled(false); +} diff --git a/src/citra_qt/debugger/disassembler.h b/src/citra_qt/debugger/disassembler.h index d9e32dbdf..b771e95b7 100644 --- a/src/citra_qt/debugger/disassembler.h +++ b/src/citra_qt/debugger/disassembler.h @@ -13,7 +13,7 @@ #include "common/break_points.h" class QAction; -class GMainWindow; +class EmuThread; class DisassemblerModel : public QAbstractListModel { @@ -51,7 +51,7 @@ class DisassemblerWidget : public QDockWidget Q_OBJECT public: - DisassemblerWidget(QWidget* parent, GMainWindow& main_window); + DisassemblerWidget(QWidget* parent, EmuThread* emu_thread); void Init(); @@ -65,6 +65,9 @@ public slots: void OnDebugModeEntered(); void OnDebugModeLeft(); + void OnEmulationStarted(EmuThread* emu_thread); + void OnEmulationStopped(); + private: // returns -1 if no row is selected int SelectedRow(); @@ -75,5 +78,5 @@ private: u32 base_addr; - GMainWindow& main_window; + EmuThread* emu_thread; }; |