diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index 27927f71..f985bb1e 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -85,12 +85,19 @@ bool Debugger::start(const QString& inferior) mWatchModel->resetAllVarInfos(); if (pSettings->debugger().useGDBServer()) { mTarget = new DebugTarget(inferior,compilerSet->debugServer(),pSettings->debugger().GDBServerPort()); + connect(mTarget, &QThread::finished,[this](){ + if (mExecuting) { + stop(); + } + mTarget->deleteLater(); + mTarget = nullptr; + }); mTarget->start(); mTarget->waitStart(); } mReader = new DebugReader(this); mReader->setDebuggerPath(debuggerPath); - connect(mReader, &QThread::finished,this,&Debugger::clearUpReader); + connect(mReader, &QThread::finished,this,&Debugger::cleanUpReader); connect(mReader, &DebugReader::parseFinished,this,&Debugger::syncFinishedParsing,Qt::BlockingQueuedConnection); connect(mReader, &DebugReader::changeDebugConsoleLastLine,this,&Debugger::onChangeDebugConsoleLastline); connect(mReader, &DebugReader::cmdStarted,pMainWindow, &MainWindow::disableDebugActions); @@ -138,24 +145,22 @@ bool Debugger::start(const QString& inferior) } void Debugger::stop() { if (mExecuting) { + if (mTarget) { + mTarget->stopDebug(); + mTarget = nullptr; + } mReader->stopDebug(); } } -void Debugger::clearUpReader() +void Debugger::cleanUpReader() { if (mExecuting) { mExecuting = false; - if (mTarget) { - mTarget->deleteLater(); - mTarget = nullptr; - } //stop debugger mReader->deleteLater(); mReader=nullptr; - - if (pMainWindow->cpuDialog()!=nullptr) { pMainWindow->cpuDialog()->close(); } diff --git a/RedPandaIDE/debugger.h b/RedPandaIDE/debugger.h index 891806d2..d7883109 100644 --- a/RedPandaIDE/debugger.h +++ b/RedPandaIDE/debugger.h @@ -252,7 +252,7 @@ private slots: void updateEval(const QString& value); void updateDisassembly(const QString& file, const QString& func,const QStringList& value); void onChangeDebugConsoleLastline(const QString& text); - void clearUpReader(); + void cleanUpReader(); void updateRegisterNames(const QStringList& registerNames); void updateRegisterValues(const QHash& values); void refreshWatchVars(); diff --git a/RedPandaIDE/gdbmiresultparser.cpp b/RedPandaIDE/gdbmiresultparser.cpp index d6767850..73ab34a7 100644 --- a/RedPandaIDE/gdbmiresultparser.cpp +++ b/RedPandaIDE/gdbmiresultparser.cpp @@ -335,7 +335,7 @@ const GDBMIResultParser::ParseObject &GDBMIResultParser::ParseValue::object() co int GDBMIResultParser::ParseValue::intValue(int defaultValue) const { - Q_ASSERT(mType == ParseValueType::Value); + //Q_ASSERT(mType == ParseValueType::Value); bool ok; int value = QString(mValue).toInt(&ok); if (ok) @@ -346,7 +346,7 @@ int GDBMIResultParser::ParseValue::intValue(int defaultValue) const int GDBMIResultParser::ParseValue::hexValue(int defaultValue) const { - Q_ASSERT(mType == ParseValueType::Value); + //Q_ASSERT(mType == ParseValueType::Value); bool ok; int value = QString(mValue).toInt(&ok,16); if (ok) @@ -357,7 +357,7 @@ int GDBMIResultParser::ParseValue::hexValue(int defaultValue) const QString GDBMIResultParser::ParseValue::pathValue() const { - Q_ASSERT(mType == ParseValueType::Value); + //Q_ASSERT(mType == ParseValueType::Value); return QFileInfo(QString::fromLocal8Bit(mValue)).absoluteFilePath(); } diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 414311f2..dfaa8ca0 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -1668,6 +1668,9 @@ void MainWindow::debug() mDebugger->sendCommand("-environment-cd", excludeTrailingPathDelimiter(debugFile.path())); // restore working directory if (pSettings->debugger().useGDBServer()) { mDebugger->sendCommand("-target-select",QString("remote localhost:%1").arg(pSettings->debugger().GDBServerPort())); + if (debugInferiorhasBreakpoint()) { + mDebugger->sendCommand("-break-insert","main"); + } mDebugger->sendCommand("-exec-continue",""); } else { #ifdef Q_OS_WIN