Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

Commit

Permalink
feat: 实现单步与断点时内存和寄存器更新
Browse files Browse the repository at this point in the history
  • Loading branch information
camel-exvl committed May 18, 2023
1 parent 9d5b30a commit a350650
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 15 deletions.
30 changes: 29 additions & 1 deletion front/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Window {
columnWidthProvider: function (column) {
switch (column) {
case 0:
return dp(200);
return dp(250);
case 1:
case 2:
case 3:
Expand Down Expand Up @@ -717,6 +717,8 @@ Window {
return;
}
codeTableModel.executeToNextBreakpoint();
registerTableModel.initTable();
memoryTableModel.initTable();
}
Connections {
target: codeTableModel
Expand All @@ -727,6 +729,18 @@ Window {
message.show(err, "red", 5000);
}
}
Connections {
target: registerTableModel
function onFail(err) {
message.show(err, "red", 5000);
}
}
Connections {
target: memoryTableModel
function onFail(err) {
message.show(err, "red", 5000);
}
}
}
MenuItem {
text: qsTr("单步")
Expand All @@ -736,6 +750,8 @@ Window {
return;
}
codeTableModel.executeOneStep();
registerTableModel.initTable();
memoryTableModel.initTable();
}
Connections {
target: codeTableModel
Expand All @@ -746,6 +762,18 @@ Window {
message.show(err, "red", 5000);
}
}
Connections {
target: registerTableModel
function onFail(err) {
message.show(err, "red", 5000);
}
}
Connections {
target: memoryTableModel
function onFail(err) {
message.show(err, "red", 5000);
}
}
}
}
Menu {
Expand Down
26 changes: 14 additions & 12 deletions middle/memorytablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ void MemoryTableModel::initTable() {
try {
table.clear();
table.append({"地址", "值(+0)", "值(+4)", "值(+8)", "值(+c)", "值(+10)", "值(+14)", "值(+18)", "值(+1c)"});
// for (int i = 0x10010000; i <= 0x100101e0; i += 0x20) {
// QVector<QString> row;
// row.append(QString::fromStdString("0x" + to_string(i)));
// for (int j = 0; j < 8; j++) {
// bitset<32> value = sys.AccessMemory(bitset<32>(i + j * 4));
// stringstream ss;
// ss << hex << value.to_ulong();
// row.append(QString::fromStdString("0x" + ss.str()));
// }
// table.append(row);
// }
for (int i = 0x10010000; i <= 0x100101e0; i += 0x20) {
QVector<QString> row;
stringstream ss;
ss << hex << i;
row.append(QString::fromStdString("0x" + ss.str()));
for (int j = 0; j < 8; j++) {
bitset<32> value = sys.ReadMemory(bitset<32>(i + j * 4));
stringstream ss;
ss << hex << value.to_ulong();
row.append(QString::fromStdString("0x" + ss.str()));
}
table.append(row);
}
} catch (exception &e) {
cerr << e.what() << endl;
emit fail(QString{e.what()});
}
endResetModel();
}
2 changes: 2 additions & 0 deletions middle/memorytablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class MemoryTableModel : public QAbstractTableModel {

private:
QVector<QVector<QString>> table;
signals:
void fail(QString);
};

#endif // MEMORYTABLEMODEL_H
2 changes: 1 addition & 1 deletion middle/registertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void RegisterTableModel::initTable() {
QString::fromStdString("0x" + ss.str())});
}
} catch (exception &e) {
cerr << e.what() << endl;
emit fail(QString{e.what()});
}
endResetModel();
}
5 changes: 4 additions & 1 deletion middle/registertablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ class RegisterTableModel : public QAbstractTableModel {
return roles;
}

void initTable();
Q_INVOKABLE void initTable();

private:
QVector<QVector<QString>> table;

signals:
void fail(QString);
};

#endif // REGISTERTABLEMODEL_H

0 comments on commit a350650

Please sign in to comment.