diff --git a/NEWS.md b/NEWS.md index c5117230..866a4e51 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/RedPandaIDE/compiler/executablerunner.cpp b/RedPandaIDE/compiler/executablerunner.cpp index cd91faef..71071f19 100644 --- a/RedPandaIDE/compiler/executablerunner.cpp +++ b/RedPandaIDE/compiler/executablerunner.cpp @@ -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(); // } diff --git a/RedPandaIDE/compiler/ojproblemcasesrunner.cpp b/RedPandaIDE/compiler/ojproblemcasesrunner.cpp index a2731b8b..65b6aa18 100644 --- a/RedPandaIDE/compiler/ojproblemcasesrunner.cpp +++ b/RedPandaIDE/compiler/ojproblemcasesrunner.cpp @@ -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 lines = splitByteArrayToLines(buffer); - qDebug()<<"----do buffer----"; - qDebug()<=2) { for (int i=0;iuncollapseAroundLine(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) diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 7c8093b8..51a5a280 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -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&) diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 4c2a976d..a7924814 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -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) diff --git a/RedPandaIDE/qsynedit/SynEdit.h b/RedPandaIDE/qsynedit/SynEdit.h index 3f7511be..512c6d98 100644 --- a/RedPandaIDE/qsynedit/SynEdit.h +++ b/RedPandaIDE/qsynedit/SynEdit.h @@ -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); diff --git a/RedPandaIDE/widgets/cpudialog.cpp b/RedPandaIDE/widgets/cpudialog.cpp index 8494e430..66769b2f 100644 --- a/RedPandaIDE/widgets/cpudialog.cpp +++ b/RedPandaIDE/widgets/cpudialog.cpp @@ -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",""); +} + diff --git a/RedPandaIDE/widgets/cpudialog.h b/RedPandaIDE/widgets/cpudialog.h index 6cbcbc17..08c6a3c4 100644 --- a/RedPandaIDE/widgets/cpudialog.h +++ b/RedPandaIDE/widgets/cpudialog.h @@ -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 diff --git a/RedPandaIDE/widgets/cpudialog.ui b/RedPandaIDE/widgets/cpudialog.ui index 21651ee7..dc3b809a 100644 --- a/RedPandaIDE/widgets/cpudialog.ui +++ b/RedPandaIDE/widgets/cpudialog.ui @@ -6,7 +6,7 @@ 0 0 - 767 + 879 498 @@ -110,6 +110,41 @@ 0 + + + + Step over one machine instruction + + + + :/icons/images/newlook24/052-next.png:/icons/images/newlook24/052-next.png + + + + + + + Step into one machine instruction + + + + :/icons/images/newlook24/040-goto.png:/icons/images/newlook24/040-goto.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -130,19 +165,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -181,7 +203,9 @@ 1 - + + +