diff --git a/3rdparty/cppdap/src/session.cpp b/3rdparty/cppdap/src/session.cpp index 20a72d318..934d60ef1 100644 --- a/3rdparty/cppdap/src/session.cpp +++ b/3rdparty/cppdap/src/session.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef ENABLE_LOG #define Log(message) printf("%s", message); @@ -418,7 +419,9 @@ class Impl : public dap::Session { // "body" is an optional field for some events, such as "Terminated Event". bool body_ok = true; d->field("body", [&](dap::Deserializer* d) { - if (!typeinfo->deserialize(d, data)) { + // todo: to completed + std::set bodyCanBeEmpty { "terminated" }; + if (!typeinfo->deserialize(d, data) && bodyCanBeEmpty.find(event) == bodyCanBeEmpty.end()) { body_ok = false; } return true; diff --git a/src/common/widget/appoutputpane.cpp b/src/common/widget/appoutputpane.cpp index 7a61b3c17..60ed366da 100644 --- a/src/common/widget/appoutputpane.cpp +++ b/src/common/widget/appoutputpane.cpp @@ -267,6 +267,15 @@ void AppOutputPane::createApplicationPane(const QString &id, const QString &prog emit paneCreated(id); } +void AppOutputPane::setProcessStarted(const QString &id) +{ + if (!d->appIsRunning.contains(id)) + return; + d->appIsRunning[id] = true; + if (d->stackWidget->currentWidget() == d->appPane[id]) + d->closeProcessBtn->setEnabled(true); +} + void AppOutputPane::setProcessFinished(const QString &id) { if (!d->appIsRunning.contains(id)) diff --git a/src/common/widget/appoutputpane.h b/src/common/widget/appoutputpane.h index bb8be63b2..f052a001c 100644 --- a/src/common/widget/appoutputpane.h +++ b/src/common/widget/appoutputpane.h @@ -32,6 +32,7 @@ class AppOutputPane : public DTK_WIDGET_NAMESPACE::DFrame OutputPane::OutputFormat format, OutputPane::AppendMode mode); + void setProcessStarted(const QString &id); void setProcessFinished(const QString &id); using StopHandler = std::function; diff --git a/src/plugins/debugger/dap/dapdebugger.cpp b/src/plugins/debugger/dap/dapdebugger.cpp index ba2dbb548..ae1309379 100644 --- a/src/plugins/debugger/dap/dapdebugger.cpp +++ b/src/plugins/debugger/dap/dapdebugger.cpp @@ -89,7 +89,6 @@ class DebuggerPrivate DEBUG::DebugSession *currentSession { nullptr }; dap::integer threadId = 0; - QList threads; StackFrameData currentValidFrame; /** @@ -214,6 +213,19 @@ void DAPDebugger::startDebug() if (d->currentSession == d->remoteSession) d->currentSession = d->localSession; + QMetaObject::invokeMethod(this, [=](){ + auto appOutPutPane = AppOutputPane::instance(); + appOutPutPane->createApplicationPane("debugPane", "debugTarget"); + appOutPutPane->setStopHandler("debugPane", [=]() { + abortDebug(); + d->outputPane = appOutPutPane->defaultPane(); + }); + d->outputPane = appOutPutPane->getOutputPaneById("debugPane"); + + appOutPutPane->bindToolBarToPane(debugToolBarName, d->outputPane); + AppOutputPane::instance()->setProcessFinished("debugPane"); // only show log untill debuggee launching + }); + auto &ctx = dpfInstance.serviceContext(); LanguageService *service = ctx.service(LanguageService::name()); if (service) { @@ -736,17 +748,6 @@ void DAPDebugger::registerDapHandlers() Q_UNUSED(event) qInfo() << "\n--> recv : " << "ThreadEvent"; - - if (event.reason == "started") - d->threads.append(event.threadId); - - if (event.reason == "exited") { - d->threads.removeOne(event.threadId); - if (d->threads.isEmpty()) { - printOutput(tr("\nThe debugee has Terminated.\n"), OutputPane::OutputFormat::NormalMessage); - updateRunState(kNoRun); - } - } }); // The event indicates that the target has produced some output. @@ -1361,7 +1362,6 @@ void DAPDebugger::exitDebug() d->threadId = 0; - d->threads.clear(); d->threadSelector->clear(); } @@ -1613,16 +1613,7 @@ void DAPDebugger::launchSession(int port, const QMap ¶m, } else { debugService->getModel()->clear(); debugService->getModel()->addSession(d->currentSession); - - auto appOutPutPane = AppOutputPane::instance(); - appOutPutPane->createApplicationPane("debugPane", "debugTarget"); - appOutPutPane->setStopHandler("debugPane", [=]() { - abortDebug(); - d->outputPane = appOutPutPane->defaultPane(); - }); - d->outputPane = appOutPutPane->getOutputPaneById("debugPane"); - - appOutPutPane->bindToolBarToPane(debugToolBarName, d->outputPane); + AppOutputPane::instance()->setProcessStarted("debugPane"); } } diff --git a/src/plugins/debugger/dap/dapdebugger.h b/src/plugins/debugger/dap/dapdebugger.h index 4df9150c5..bf54cc93d 100644 --- a/src/plugins/debugger/dap/dapdebugger.h +++ b/src/plugins/debugger/dap/dapdebugger.h @@ -132,7 +132,7 @@ public slots: void launchSession(int port, const QMap ¶m, const QString &kitName); void disassemble(const QString &address); void handleAssemble(const QString &content); - + QString transformRemotePath(const QString &remotePath); dpfservice::ProjectInfo getActiveProjectInfo() const;