Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion 3rdparty/cppdap/src/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <thread>
#include <unordered_map>
#include <vector>
#include <set>

#ifdef ENABLE_LOG
#define Log(message) printf("%s", message);
Expand Down Expand Up @@ -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<std::string> bodyCanBeEmpty { "terminated" };
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Optimize optional-body lookup and broaden handling

Make bodyCanBeEmpty a static const to avoid reallocations, and review the DAP spec for other events (e.g. initialized, stopped) that may omit a body to prevent false negatives.

if (!typeinfo->deserialize(d, data) && bodyCanBeEmpty.find(event) == bodyCanBeEmpty.end()) {
body_ok = false;
}
return true;
Expand Down
9 changes: 9 additions & 0 deletions src/common/widget/appoutputpane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions src/common/widget/appoutputpane.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<void()>;
Expand Down
37 changes: 14 additions & 23 deletions src/plugins/debugger/dap/dapdebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class DebuggerPrivate
DEBUG::DebugSession *currentSession { nullptr };

dap::integer threadId = 0;
QList<dap::integer> threads;
StackFrameData currentValidFrame;

/**
Expand Down Expand Up @@ -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>(LanguageService::name());
if (service) {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1361,7 +1362,6 @@ void DAPDebugger::exitDebug()

d->threadId = 0;

d->threads.clear();
d->threadSelector->clear();
}

Expand Down Expand Up @@ -1613,16 +1613,7 @@ void DAPDebugger::launchSession(int port, const QMap<QString, QVariant> &param,
} 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");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/debugger/dap/dapdebugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public slots:
void launchSession(int port, const QMap<QString, QVariant> &param, const QString &kitName);
void disassemble(const QString &address);
void handleAssemble(const QString &content);

QString transformRemotePath(const QString &remotePath);

dpfservice::ProjectInfo getActiveProjectInfo() const;
Expand Down
Loading