mirror of https://github.com/Treeki/WindEmu.git
added memory viewer/editor to the debugger
This commit is contained in:
parent
d1bc50448f
commit
9bc338ad18
|
@ -182,6 +182,19 @@ void Emu::writeReg32(uint32_t reg, uint32_t value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Emu::isPhysAddressValid(uint32_t physAddress) const {
|
||||||
|
uint8_t region = (physAddress >> 24) & 0xF1;
|
||||||
|
switch (region) {
|
||||||
|
case 0: return true;
|
||||||
|
case 0x80: return (physAddress <= 0x80000FFF);
|
||||||
|
case 0xC0: return true;
|
||||||
|
case 0xC1: return true;
|
||||||
|
case 0xD0: return true;
|
||||||
|
case 0xD1: return true;
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t Emu::readPhys8(uint32_t physAddress) {
|
uint32_t Emu::readPhys8(uint32_t physAddress) {
|
||||||
uint32_t result = 0xFF;
|
uint32_t result = 0xFF;
|
||||||
uint8_t region = (physAddress >> 24) & 0xF1;
|
uint8_t region = (physAddress >> 24) & 0xF1;
|
||||||
|
|
|
@ -45,6 +45,8 @@ class Emu {
|
||||||
void writeReg32(uint32_t reg, uint32_t value);
|
void writeReg32(uint32_t reg, uint32_t value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
bool isPhysAddressValid(uint32_t physAddress) const;
|
||||||
|
|
||||||
uint32_t readPhys8(uint32_t physAddress);
|
uint32_t readPhys8(uint32_t physAddress);
|
||||||
uint32_t readPhys16(uint32_t physAddress);
|
uint32_t readPhys16(uint32_t physAddress);
|
||||||
uint32_t readPhys32(uint32_t physAddress);
|
uint32_t readPhys32(uint32_t physAddress);
|
||||||
|
|
|
@ -30,6 +30,8 @@ void MainWindow::updateScreen()
|
||||||
{
|
{
|
||||||
ui->cycleCounter->setText(QString("Cycles: %1").arg(emu->currentCycles()));
|
ui->cycleCounter->setText(QString("Cycles: %1").arg(emu->currentCycles()));
|
||||||
|
|
||||||
|
updateMemory();
|
||||||
|
|
||||||
ui->regsLabel->setText(
|
ui->regsLabel->setText(
|
||||||
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")
|
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(0), 8, 16)
|
||||||
|
@ -260,3 +262,80 @@ void MainWindow::updateBreakpointsList()
|
||||||
ui->breakpointsList->addItem(QString::number(addr, 16));
|
ui->breakpointsList->addItem(QString::number(addr, 16));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_memoryViewAddress_textEdited(const QString &)
|
||||||
|
{
|
||||||
|
updateMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateMemory()
|
||||||
|
{
|
||||||
|
uint32_t virtBase = ui->memoryViewAddress->text().toUInt(nullptr, 16) & ~0xFF;
|
||||||
|
uint32_t physBase = emu->virtToPhys(virtBase);
|
||||||
|
bool ok = (physBase != 0xFFFFFFFF) && emu->isPhysAddressValid(physBase);
|
||||||
|
|
||||||
|
uint8_t block[0x100];
|
||||||
|
if (ok) {
|
||||||
|
for (int i = 0; i < 0x100; i++) {
|
||||||
|
block[i] = emu->readPhys8(physBase + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList output;
|
||||||
|
for (int row = 0; row < 16; row++) {
|
||||||
|
QString outLine;
|
||||||
|
outLine.reserve(8 + 2 + (2 * 16) + 3 + 16);
|
||||||
|
outLine.append(QStringLiteral("%1 |").arg(virtBase + (row * 16), 8, 16));
|
||||||
|
for (int col = 0; col < 16; col++) {
|
||||||
|
if (ok)
|
||||||
|
outLine.append(QStringLiteral(" %1").arg(block[row*16+col], 2, 16, QLatin1Char('0')));
|
||||||
|
else
|
||||||
|
outLine.append(QStringLiteral(" ??"));
|
||||||
|
}
|
||||||
|
outLine.append(QStringLiteral(" | "));
|
||||||
|
for (int col = 0; col < 16; col++) {
|
||||||
|
uint8_t byte = block[row*16+col];
|
||||||
|
if (!ok)
|
||||||
|
outLine.append('?');
|
||||||
|
else if (byte >= 0x20 && byte <= 0x7E)
|
||||||
|
outLine.append(byte);
|
||||||
|
else
|
||||||
|
outLine.append('.');
|
||||||
|
}
|
||||||
|
output.append(outLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->memoryViewLabel->setText(output.join('\n'));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_memoryAdd1_clicked() { adjustMemoryAddress(1); }
|
||||||
|
void MainWindow::on_memoryAdd4_clicked() { adjustMemoryAddress(4); }
|
||||||
|
void MainWindow::on_memoryAdd10_clicked() { adjustMemoryAddress(0x10); }
|
||||||
|
void MainWindow::on_memoryAdd100_clicked() { adjustMemoryAddress(0x100); }
|
||||||
|
void MainWindow::on_memorySub1_clicked() { adjustMemoryAddress(-1); }
|
||||||
|
void MainWindow::on_memorySub4_clicked() { adjustMemoryAddress(-4); }
|
||||||
|
void MainWindow::on_memorySub10_clicked() { adjustMemoryAddress(-0x10); }
|
||||||
|
void MainWindow::on_memorySub100_clicked() { adjustMemoryAddress(-0x100); }
|
||||||
|
|
||||||
|
void MainWindow::adjustMemoryAddress(int offset) {
|
||||||
|
uint32_t address = ui->memoryViewAddress->text().toUInt(nullptr, 16);
|
||||||
|
address += offset;
|
||||||
|
ui->memoryViewAddress->setText(QString("%1").arg(address, 8, 16, QLatin1Char('0')));
|
||||||
|
updateMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_writeByteButton_clicked()
|
||||||
|
{
|
||||||
|
uint32_t address = ui->memoryViewAddress->text().toUInt(nullptr, 16);
|
||||||
|
uint8_t value = (uint8_t)ui->memoryWriteValue->text().toUInt(nullptr, 16);
|
||||||
|
emu->writeVirt8(address, value);
|
||||||
|
updateMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_writeDwordButton_clicked()
|
||||||
|
{
|
||||||
|
uint32_t address = ui->memoryViewAddress->text().toUInt(nullptr, 16);
|
||||||
|
uint32_t value = ui->memoryWriteValue->text().toUInt(nullptr, 16);
|
||||||
|
emu->writeVirt32(address, value);
|
||||||
|
updateMemory();
|
||||||
|
}
|
||||||
|
|
|
@ -28,12 +28,28 @@ private slots:
|
||||||
|
|
||||||
void on_removeBreakButton_clicked();
|
void on_removeBreakButton_clicked();
|
||||||
|
|
||||||
|
void on_memoryViewAddress_textEdited(const QString &arg1);
|
||||||
|
void on_memoryAdd1_clicked();
|
||||||
|
void on_memoryAdd4_clicked();
|
||||||
|
void on_memoryAdd10_clicked();
|
||||||
|
void on_memoryAdd100_clicked();
|
||||||
|
void on_memorySub1_clicked();
|
||||||
|
void on_memorySub4_clicked();
|
||||||
|
void on_memorySub10_clicked();
|
||||||
|
void on_memorySub100_clicked();
|
||||||
|
|
||||||
|
void on_writeByteButton_clicked();
|
||||||
|
|
||||||
|
void on_writeDwordButton_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
Emu *emu;
|
Emu *emu;
|
||||||
QTimer *timer;
|
QTimer *timer;
|
||||||
void updateScreen();
|
void updateScreen();
|
||||||
void updateBreakpointsList();
|
void updateBreakpointsList();
|
||||||
|
void updateMemory();
|
||||||
|
void adjustMemoryAddress(int offset);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent *event) override;
|
void keyPressEvent(QKeyEvent *event) override;
|
||||||
|
|
|
@ -15,13 +15,46 @@
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget">
|
<widget class="QWidget" name="centralWidget">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="4">
|
<item row="1" column="0">
|
||||||
<widget class="QPushButton" name="stopButton">
|
<widget class="QLabel" name="cycleCounter">
|
||||||
<property name="enabled">
|
<property name="text">
|
||||||
<bool>false</bool>
|
<string>Cycles</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="5">
|
||||||
|
<widget class="QLabel" name="regsLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Courier New</family>
|
||||||
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Stop</string>
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QPushButton" name="startButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Start</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="4">
|
||||||
|
<widget class="QPushButton" name="stepTickButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Step (Tick)</string>
|
||||||
|
</property>
|
||||||
|
</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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -32,15 +65,174 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="4">
|
||||||
|
<widget class="QPushButton" name="stopButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Stop</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="4" column="0" colspan="5">
|
<item row="4" column="0" colspan="5">
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Memory</string>
|
<string>Memory</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="1" column="4">
|
||||||
|
<widget class="QToolButton" name="memorySub1">
|
||||||
|
<property name="text">
|
||||||
|
<string>-1</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="7">
|
||||||
|
<widget class="QToolButton" name="memorySub100">
|
||||||
|
<property name="text">
|
||||||
|
<string>-100</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="5">
|
||||||
|
<widget class="QToolButton" name="memoryAdd4">
|
||||||
|
<property name="text">
|
||||||
|
<string>+4</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" colspan="8">
|
||||||
|
<widget class="QLineEdit" name="memoryViewAddress">
|
||||||
|
<property name="text">
|
||||||
|
<string>00000000</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="6">
|
||||||
|
<widget class="QToolButton" name="memorySub10">
|
||||||
|
<property name="text">
|
||||||
|
<string>-10</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="5">
|
||||||
|
<widget class="QToolButton" name="memorySub4">
|
||||||
|
<property name="text">
|
||||||
|
<string>-4</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="6">
|
||||||
|
<widget class="QToolButton" name="memoryAdd10">
|
||||||
|
<property name="text">
|
||||||
|
<string>+10</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Address:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="4">
|
||||||
|
<widget class="QToolButton" name="memoryAdd1">
|
||||||
|
<property name="text">
|
||||||
|
<string>+1</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="7">
|
||||||
|
<widget class="QToolButton" name="memoryAdd100">
|
||||||
|
<property name="text">
|
||||||
|
<string>+100</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="9">
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="5">
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<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="10" rowspan="3">
|
||||||
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>Write</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_5">
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="writeDwordButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Dword</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QPushButton" name="writeByteButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Byte</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QLineEdit" name="memoryWriteValue"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0" colspan="11">
|
||||||
|
<widget class="QLabel" name="memoryViewLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Courier New</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_2">
|
<widget class="QWidget" name="tab_2">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
@ -116,62 +308,6 @@
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="3">
|
|
||||||
<widget class="QPushButton" name="startButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Start</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="cycleCounter">
|
|
||||||
<property name="text">
|
|
||||||
<string>Cycles</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2">
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="4">
|
|
||||||
<widget class="QPushButton" name="stepTickButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Step (Tick)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0" colspan="5">
|
|
||||||
<widget class="QLabel" name="regsLabel">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Courier New</family>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
Loading…
Reference in New Issue