- fix: current line of the disassembly in the cpu window not correctly setted

- enhancement: add "step into one machine instruction" and "step over one machine instruction" in the cpu window
This commit is contained in:
Roy Qu 2021-12-16 10:46:38 +08:00
parent 436a299ebb
commit 879f001d0c
10 changed files with 96 additions and 47 deletions

View File

@ -2,6 +2,8 @@ Version 0.11.2 For Dev-C++ 7 Beta
- fix: button "run all problem cases" not disabled when compiling or debugging
- enhancement: set font for problem case input/output textedits
- enhancement: when run problem cases, updates output immediately
- fix: current line of the disassembly in the cpu window not correctly setted
- enhancement: add "step into one machine instruction" and "step over one machine instruction" in the cpu window
Version 0.11.1 For Dev-C++ 7 Beta
- enhancement: Problem's test case shouldn't accept rich text inputs

View File

@ -84,10 +84,11 @@ void ExecutableRunner::run()
args->startupInfo -> dwFlags &= ~STARTF_USESTDHANDLES;
}
});
process.connect(&process, &QProcess::errorOccurred,
[&](){
errorOccurred= true;
});
process.connect(
&process, &QProcess::errorOccurred,
[&](){
errorOccurred= true;
});
// if (!redirectInput()) {
// process.closeWriteChannel();
// }

View File

@ -47,18 +47,14 @@ void OJProblemCasesRunner::runCase(int index,POJProblemCase problemCase)
}
env.insert("PATH",path);
process.setProcessEnvironment(env);
process.setCreateProcessArgumentsModifier([this](QProcess::CreateProcessArguments * args){
args->flags |= CREATE_NEW_CONSOLE;
args->startupInfo -> dwFlags |= STARTF_USESHOWWINDOW;
args->startupInfo->wShowWindow = SW_HIDE;
});
process.setProcessChannelMode(QProcess::MergedChannels);
process.connect(&process, &QProcess::errorOccurred,
[&](){
errorOccurred= true;
});
process.connect(
&process, &QProcess::errorOccurred,
[&](){
errorOccurred= true;
});
problemCase->output.clear();
process.start(QProcess::ReadWrite|QProcess::Unbuffered);
process.start();
process.waitForStarted(5000);
if (process.state()==QProcess::Running) {
process.write(problemCase->input.toUtf8());
@ -85,10 +81,10 @@ void OJProblemCasesRunner::runCase(int index,POJProblemCase problemCase)
if (errorOccurred)
break;
QList<QByteArray> lines = splitByteArrayToLines(buffer);
qDebug()<<"----do buffer----";
qDebug()<<readed;
qDebug()<<buffer;
qDebug()<<lines.count();
// qDebug()<<"----do buffer----";
// qDebug()<<readed;
// qDebug()<<buffer;
// qDebug()<<lines.count();
if (lines.count()>=2) {
for (int i=0;i<lines.count()-1;i++) {
QString line = QString::fromLocal8Bit(lines[i]);
@ -140,10 +136,10 @@ void OJProblemCasesRunner::run()
auto action = finally([this]{
emit terminated();
});
for (int i=0;i<mProblemCases.size();i++) {
for (int i=0; i < mProblemCases.size(); i++) {
if (mStop)
break;
POJProblemCase problemCase =mProblemCases[i];
POJProblemCase problemCase = mProblemCases[i];
runCase(i,problemCase);
}
}

View File

@ -1249,7 +1249,7 @@ void Editor::copyAsHTML()
void Editor::setCaretPosition(int line, int aChar)
{
this->uncollapseAroundLine(line);
this->setCaretXYCentered(true,BufferCoord{aChar,line});
this->setCaretXYCentered(BufferCoord{aChar,line});
}
void Editor::setCaretPositionAndActivate(int line, int aChar)
@ -1257,7 +1257,7 @@ void Editor::setCaretPositionAndActivate(int line, int aChar)
this->uncollapseAroundLine(line);
if (!this->hasFocus())
this->activate();
this->setCaretXYCentered(true,BufferCoord{aChar,line});
this->setCaretXYCentered(BufferCoord{aChar,line});
}
void Editor::addSyntaxIssues(int line, int startChar, int endChar, CompileIssueType errorType, const QString &hint)

View File

@ -3076,6 +3076,9 @@ void MainWindow::disableDebugActions()
ui->actionContinue->setEnabled(false);
ui->cbEvaluate->setEnabled(false);
ui->cbMemoryAddress->setEnabled(false);
if (mCPUDialog) {
mCPUDialog->updateButtonStates(false);
}
}
void MainWindow::enableDebugActions()
@ -3087,6 +3090,9 @@ void MainWindow::enableDebugActions()
ui->actionContinue->setEnabled(!mDebugger->inferiorRunning());
ui->cbEvaluate->setEnabled(!mDebugger->inferiorRunning());
ui->cbMemoryAddress->setEnabled(!mDebugger->inferiorRunning());
if (mCPUDialog) {
mCPUDialog->updateButtonStates(true);
}
}
void MainWindow::onTodoParseStarted(const QString&)

View File

@ -203,10 +203,10 @@ void SynEdit::setCaretY(int value)
void SynEdit::setCaretXY(const BufferCoord &value)
{
setCaretXYCentered(false,value);
setCaretXYEx(true,value);
}
void SynEdit::setCaretXYEx(bool CallEnsureCursorPos, BufferCoord value)
void SynEdit::setCaretXYEx(bool CallEnsureCursorPosVisible, BufferCoord value)
{
bool vTriggerPaint=true; //how to test it?
@ -260,7 +260,7 @@ void SynEdit::setCaretXYEx(bool CallEnsureCursorPos, BufferCoord value)
// calls could raise an exception, and we don't want fLastCaretX to be
// left in an undefined state if that happens.
updateLastCaretX();
if (CallEnsureCursorPos)
if (CallEnsureCursorPosVisible)
ensureCursorPosVisible();
mStateFlags.setFlag(SynStateFlag::sfCaretChanged);
mStateFlags.setFlag(SynStateFlag::sfScrollbarChanged);
@ -279,21 +279,20 @@ void SynEdit::setCaretXYEx(bool CallEnsureCursorPos, BufferCoord value)
}
void SynEdit::setCaretXYCentered(bool ForceToMiddle, const BufferCoord &value)
void SynEdit::setCaretXYCentered(const BufferCoord &value)
{
incPaintLock();
auto action = finally([this] {
decPaintLock();
});
mStatusChanges.setFlag(SynStatusChange::scSelection);
setCaretXYEx(ForceToMiddle,value);
setCaretXYEx(false,value);
if (selAvail())
invalidateSelection();
mBlockBegin.Char = mCaretX;
mBlockBegin.Line = mCaretY;
mBlockEnd = mBlockBegin;
if (ForceToMiddle)
ensureCursorPosVisibleEx(true); // but here after block has been set
ensureCursorPosVisibleEx(true); // but here after block has been set
}
void SynEdit::uncollapseAroundLine(int line)

View File

@ -213,8 +213,8 @@ public:
void setCaretX(int value);
void setCaretY(int value);
void setCaretXY(const BufferCoord& value);
void setCaretXYEx(bool CallEnsureCursorPos, BufferCoord value);
void setCaretXYCentered(bool ForceToMiddle, const BufferCoord& value);
void setCaretXYEx(bool CallEnsureCursorPosVisible, BufferCoord value);
void setCaretXYCentered(const BufferCoord& value);
void setCaretAndSelection(const BufferCoord& ptCaret,
const BufferCoord& ptBefore,
const BufferCoord& ptAfter);

View File

@ -65,6 +65,12 @@ void CPUDialog::updateInfo()
}
}
void CPUDialog::updateButtonStates(bool enable)
{
ui->btnStepIntoInstruction->setEnabled(enable);
ui->btnStepOverInstruction->setEnabled(enable);
}
void CPUDialog::setDisassembly(const QString& file, const QString& funcName,const QStringList& lines)
{
ui->txtFunctionName->setText(QString("%1:%2").arg(file, funcName));
@ -78,7 +84,7 @@ void CPUDialog::setDisassembly(const QString& file, const QString& funcName,cons
ui->txtCode->lines()->add(line);
}
if (activeLine!=-1)
ui->txtCode->setCaretXYCentered(true,BufferCoord{1,activeLine});
ui->txtCode->setCaretXYEx(true,BufferCoord{1,activeLine+1});
}
void CPUDialog::sendSyntaxCommand()
@ -117,3 +123,15 @@ void CPUDialog::on_chkBlendMode_stateChanged(int)
pSettings->debugger().setBlendMode(ui->chkBlendMode->isCheckable());
pSettings->debugger().save();
}
void CPUDialog::on_btnStepOverInstruction_clicked()
{
pMainWindow->debugger()->sendCommand("-exec-next-instruction","");
}
void CPUDialog::on_btnStepIntoInstruction_clicked()
{
pMainWindow->debugger()->sendCommand("-exec-step-instruction","");
}

View File

@ -15,6 +15,7 @@ public:
explicit CPUDialog(QWidget *parent = nullptr);
~CPUDialog();
void updateInfo();
void updateButtonStates(bool enable);
public slots:
void setDisassembly(const QString& file, const QString& funcName,const QStringList& lines);
signals:
@ -30,6 +31,8 @@ private slots:
void on_rdIntel_toggled(bool checked);
void on_rdATT_toggled(bool checked);
void on_chkBlendMode_stateChanged(int arg1);
void on_btnStepOverInstruction_clicked();
void on_btnStepIntoInstruction_clicked();
};
#endif // CPUDIALOG_H

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>767</width>
<width>879</width>
<height>498</height>
</rect>
</property>
@ -110,6 +110,41 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="btnStepOverInstruction">
<property name="text">
<string>Step over one machine instruction</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/images/newlook24/052-next.png</normaloff>:/icons/images/newlook24/052-next.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnStepIntoInstruction">
<property name="text">
<string>Step into one machine instruction</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/images/newlook24/040-goto.png</normaloff>:/icons/images/newlook24/040-goto.png</iconset>
</property>
</widget>
</item>
<item>
<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>
<widget class="QRadioButton" name="rdATT">
<property name="text">
@ -130,19 +165,6 @@
</attribute>
</widget>
</item>
<item>
<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>
<widget class="QCheckBox" name="chkBlendMode">
<property name="text">
@ -181,7 +203,9 @@
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="../icons.qrc"/>
</resources>
<connections/>
<buttongroups>
<buttongroup name="buttonGroup"/>