From 5c17096e00b65fb3d3c22b26d1f5784c00bc583f Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 24 Nov 2021 21:22:01 +0800 Subject: [PATCH] work save --- RedPandaIDE/debugger.cpp | 50 ++++++++++++++------- RedPandaIDE/debugger.h | 16 ++----- RedPandaIDE/gdbmiresultparser.cpp | 26 +++++++---- RedPandaIDE/icons.qrc | 1 + RedPandaIDE/images/newlook24/093-pause.png | Bin 0 -> 1709 bytes RedPandaIDE/mainwindow.cpp | 27 +++++++---- RedPandaIDE/mainwindow.h | 2 + RedPandaIDE/mainwindow.ui | 14 ++++++ 8 files changed, 89 insertions(+), 47 deletions(-) create mode 100644 RedPandaIDE/images/newlook24/093-pause.png diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index b2df715a..80903ef4 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -65,6 +65,7 @@ bool Debugger::start() connect(mReader, &DebugReader::changeDebugConsoleLastLine,this,&Debugger::onChangeDebugConsoleLastline); connect(mReader, &DebugReader::cmdStarted,pMainWindow, &MainWindow::disableDebugActions); connect(mReader, &DebugReader::cmdFinished,pMainWindow, &MainWindow::enableDebugActions); + connect(mReader, &DebugReader::inferiorStopped, pMainWindow, &MainWindow::enableDebugActions); connect(mReader, &DebugReader::breakpointInfoGetted, mBreakpointModel, &BreakpointModel::updateBreakpointNumber); @@ -76,9 +77,13 @@ bool Debugger::start() connect(mReader, &DebugReader::evalUpdated,[this](const QString& value) { emit evalValueReady(value); }); + connect(mReader, &DebugReader::inferiorContinued,pMainWindow, + &MainWindow::removeActiveBreakpoints); connect(mReader, &DebugReader::inferiorStopped,pMainWindow, &MainWindow::setActiveBreakpoint); + mReader->registerInferiorStoppedCommand("-stack-list-frames",""); + mReader->registerInferiorStoppedCommand("-stack-list-variables", "--all-values"); mReader->start(); mReader->waitStart(); @@ -153,6 +158,14 @@ bool Debugger::commandRunning() return false; } +bool Debugger::inferiorRunning() +{ + if (mExecuting && mReader) { + return mReader->inferiorRunning(); + } + return false; +} + void Debugger::addBreakpoint(int line, const Editor* editor) { addBreakpoint(line,editor->filename()); @@ -373,12 +386,6 @@ void Debugger::notifyAfterProcessWatchVar() mWatchModel->endUpdate(); } -void Debugger::updateDebugInfo() -{ - sendCommand("-stack-list-frames", ""); - sendCommand("-stack-list-variables", "--skip-unavailable --allvalues"); -} - bool Debugger::useUTF8() const { return mUseUTF8; @@ -461,11 +468,7 @@ void Debugger::syncFinishedParsing() } } - // The program to debug has stopped. Stop the debugger - if (mReader->processExited()) { - stop(); - return; - } + // show command output if (pSettings->debugger().showCommandLog() ) { @@ -480,6 +483,12 @@ void Debugger::syncFinishedParsing() } } + // The program to debug has stopped. Stop the debugger + if (mReader->processExited()) { + stop(); + return; + } + // Some part of the CPU form has been updated if (pMainWindow->cpuDialog()!=nullptr && !mReader->signalReceived()) { // if (mReader->doregistersready) { @@ -646,7 +655,6 @@ void DebugReader::processExecAsyncRecord(const QByteArray &line) GDBMIResultParser parser; if (!parser.parseAsyncResult(line,result,multiValues)) return; - qDebug()< & stack PTrace trace = std::make_shared(); trace->funcname = frameObject["func"].value(); trace->filename = frameObject["fullname"].pathValue(); - trace->line = frameObject["fullname"].intValue(); + trace->line = frameObject["line"].intValue(); trace->level = frameObject["level"].intValue(0); trace->address = frameObject["addr"].value(); mDebugger->backtraceModel()->addTrace(trace); @@ -1180,6 +1189,11 @@ QByteArray DebugReader::removeToken(const QByteArray &line) return line; } +bool DebugReader::inferiorRunning() const +{ + return mInferiorRunning; +} + const QStringList &DebugReader::fullOutput() const { return mFullOutput; @@ -1308,7 +1322,11 @@ void DebugReader::run() readed = mProcess->readAll(); buffer += readed; - if ( readed.endsWith("\n")&& outputTerminated(buffer)) { + if (!readed.isEmpty()) { + qDebug()<<"*******"; + qDebug()< mInferiorStoppedHookCommands; bool mInferiorRunning; diff --git a/RedPandaIDE/gdbmiresultparser.cpp b/RedPandaIDE/gdbmiresultparser.cpp index 54a49104..35d256fb 100644 --- a/RedPandaIDE/gdbmiresultparser.cpp +++ b/RedPandaIDE/gdbmiresultparser.cpp @@ -51,8 +51,6 @@ bool GDBMIResultParser::parseAsyncResult(const QByteArray &record, QByteArray &r bool GDBMIResultParser::parseMultiValues(const char* p, ParseObject &multiValue) { - qDebug()<<"-------"; - qDebug()<images/editor/bookmark.png images/newlook24/091-openproblemanswer.png images/newlook24/092-runallproblemcases.png + images/newlook24/093-pause.png diff --git a/RedPandaIDE/images/newlook24/093-pause.png b/RedPandaIDE/images/newlook24/093-pause.png new file mode 100644 index 0000000000000000000000000000000000000000..4394cb520d238ec454e2c3e0d60bd0b8bae4b78a GIT binary patch literal 1709 zcmcIlO>f*p7zUm(S$mA_ zWOpNRDTlTae*tkqZ~`uH;ZOwJ0f~<*zkmvHDJW8Ty<%a2a9CF?5Fzd3q^eEoB{Nr*?H}3%*>Xm*6Ai0+ z;nED~`=>*rXpYYEtwXRf)%#fDtTjrww!<@VkOq9~kjMGz%oq#idy|8-KlYRb8t?N6 zU>OL*b5luAgF{y=hVym|AM=LJW1vo*ubb(wDb> uzJ2}Nr%R=uF1`28Z@tpX%?m$n+?DW4uU-N7(`4#B^ literal 0 HcmV?d00001 diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index cd609b8b..bdb1e3a8 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -1410,6 +1410,9 @@ void MainWindow::debug() updateEditorActions(); return; } + mDebugger->sendCommand("-gdb-set","mi-async on"); + mDebugger->sendCommand("-gdb-set","target-async on"); + mDebugger->sendCommand("-gdb-show", "mi-async"); updateEditorActions(); @@ -3013,13 +3016,13 @@ void MainWindow::disableDebugActions() void MainWindow::enableDebugActions() { - ui->actionStep_Into->setEnabled(true); - ui->actionStep_Over->setEnabled(true); - ui->actionStep_Out->setEnabled(true); - ui->actionRun_To_Cursor->setEnabled(true); - ui->actionContinue->setEnabled(true); - ui->cbEvaluate->setEnabled(true); - ui->cbMemoryAddress->setEnabled(true); + ui->actionStep_Into->setEnabled(!mDebugger->inferiorRunning()); + ui->actionStep_Over->setEnabled(!mDebugger->inferiorRunning()); + ui->actionStep_Out->setEnabled(!mDebugger->inferiorRunning()); + ui->actionRun_To_Cursor->setEnabled(!mDebugger->inferiorRunning()); + ui->actionContinue->setEnabled(!mDebugger->inferiorRunning()); + ui->cbEvaluate->setEnabled(!mDebugger->inferiorRunning()); + ui->cbMemoryAddress->setEnabled(!mDebugger->inferiorRunning()); } void MainWindow::onTodoParseStarted(const QString&) @@ -4018,8 +4021,6 @@ void MainWindow::on_actionContinue_triggered() //WatchView.Items.BeginUpdate(); mDebugger->invalidateAllVars(); mDebugger->sendCommand("-exec-continue", ""); - mDebugger->updateDebugInfo(); - mDebugger->refreshWatchVars(); } } @@ -5742,3 +5743,11 @@ void MainWindow::on_actionDelete_to_BOL_triggered() } } + +void MainWindow::on_actionPause_triggered() +{ + if (mDebugger->executing()) { + mDebugger->sendCommand("-exec-interrupt","-a"); + } +} + diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 39550f94..c6ad3f67 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -528,6 +528,8 @@ private slots: void on_actionDelete_to_BOL_triggered(); + void on_actionPause_triggered(); + private: Ui::MainWindow *ui; EditorList *mEditorList; diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index d45c3e17..987029a3 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -1424,6 +1424,7 @@ + @@ -1642,6 +1643,7 @@ + @@ -2649,6 +2651,18 @@ Ctrl+Backspace + + + + :/icons/images/newlook24/093-pause.png:/icons/images/newlook24/093-pause.png + + + Pause + + + F3 + +