add basic breakpoint support

This commit is contained in:
Ash Wolf
2019-12-19 17:40:49 +00:00
parent 883197000d
commit e96c438003
5 changed files with 100 additions and 10 deletions

View File

@@ -31,7 +31,7 @@ void MainWindow::updateScreen()
ui->cycleCounter->setText(QString("Cycles: %1").arg(emu->currentCycles()));
ui->regsLabel->setText(
QString("R0: %1 / R1: %2 / R2: %3 / R3: %4 / R4: %5 / R5: %6 / R6: %7 / R7: %8 / R8: %9\nR9: %10 / R10:%11 / R11:%12 / R12:%13 / SP: %14 / LR: %15 / PC: %16")
QString("R0: %1 / R1: %2 / R2: %3 / R3: %4 / R4: %5 / R5: %6 / R6: %7 / R7: %8\nR8: %9 / R9: %10 / R10:%11 / R11:%12 / R12:%13 / SP: %14 / LR: %15 / PC: %16")
.arg(emu->getGPR(0), 8, 16)
.arg(emu->getGPR(1), 8, 16)
.arg(emu->getGPR(2), 8, 16)
@@ -243,3 +243,25 @@ void MainWindow::execTimer()
emu->executeUntil(emu->currentCycles() + (CLOCK_SPEED / 64));
updateScreen();
}
void MainWindow::on_addBreakButton_clicked()
{
uint32_t addr = ui->breakpointAddress->text().toUInt(nullptr, 16);
emu->breakpoints().insert(addr);
updateBreakpointsList();
}
void MainWindow::on_removeBreakButton_clicked()
{
uint32_t addr = ui->breakpointAddress->text().toUInt(nullptr, 16);
emu->breakpoints().erase(addr);
updateBreakpointsList();
}
void MainWindow::updateBreakpointsList()
{
ui->breakpointsList->clear();
for (uint32_t addr : emu->breakpoints()) {
ui->breakpointsList->addItem(QString::number(addr, 16));
}
}

View File

@@ -24,12 +24,16 @@ private slots:
void on_stepInsnButton_clicked();
void on_stepTickButton_clicked();
void on_addBreakButton_clicked();
void on_removeBreakButton_clicked();
private:
Ui::MainWindow *ui;
Emu *emu;
QTimer *timer;
void updateScreen();
void updateBreakpointsList();
protected:
void keyPressEvent(QKeyEvent *event) override;

View File

@@ -35,7 +35,7 @@
<item row="4" column="0" colspan="5">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@@ -61,10 +61,66 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Breakpoints</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Edit</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QPushButton" name="addBreakButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="removeBreakButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLineEdit" name="breakpointAddress">
<property name="placeholderText">
<string>hex address, no prefix</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" rowspan="2">
<widget class="QListWidget" name="breakpointsList"/>
</item>
</layout>
</widget>
</widget>
</item>
<item row="0" column="0" colspan="6">
<widget class="QLabel" name="screen">
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="text">
<string/>
</property>