From cd3729b4aa5d6aa762c07db9ac3eaf41ee37ec36 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Thu, 20 Jun 2024 11:32:16 +0200 Subject: [PATCH] DAP: Handle failed "launch" response On Windows if the application being debugged has missing dlls it will not be able to be started by the debugger. Now the user will be informed that the application failed to start. Change-Id: I0a76a8c6cd122970b00adec371b254adc60915c0 Reviewed-by: Artem Sokolovskii --- src/plugins/debugger/dap/dapclient.cpp | 2 ++ src/plugins/debugger/dap/dapclient.h | 1 + src/plugins/debugger/dap/dapengine.cpp | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/plugins/debugger/dap/dapclient.cpp b/src/plugins/debugger/dap/dapclient.cpp index b67d7ec4754..c7839d55822 100644 --- a/src/plugins/debugger/dap/dapclient.cpp +++ b/src/plugins/debugger/dap/dapclient.cpp @@ -239,6 +239,8 @@ void DapClient::emitSignals(const QJsonDocument &doc) type = DapResponseType::SetFunctionBreakpoints; } else if (command == "attach") { type = DapResponseType::Attach; + } else if (command == "launch") { + type = DapResponseType::Launch; } emit responseReady(type, ob); return; diff --git a/src/plugins/debugger/dap/dapclient.h b/src/plugins/debugger/dap/dapclient.h index f4c3df2ef3a..268e1e1f37f 100644 --- a/src/plugins/debugger/dap/dapclient.h +++ b/src/plugins/debugger/dap/dapclient.h @@ -55,6 +55,7 @@ enum class DapResponseType SetBreakpoints, SetFunctionBreakpoints, Attach, + Launch, Unknown }; diff --git a/src/plugins/debugger/dap/dapengine.cpp b/src/plugins/debugger/dap/dapengine.cpp index e311bb36822..da659921c2e 100644 --- a/src/plugins/debugger/dap/dapengine.cpp +++ b/src/plugins/debugger/dap/dapengine.cpp @@ -645,6 +645,7 @@ void DapEngine::readDapStandardError() void DapEngine::handleResponse(DapResponseType type, const QJsonObject &response) { const QString command = response.value("command").toString(); + const bool success = response.value("success").toBool(); switch (type) { case DapResponseType::Initialize: @@ -675,7 +676,7 @@ void DapEngine::handleResponse(DapResponseType type, const QJsonObject &response case DapResponseType::StepIn: case DapResponseType::StepOut: case DapResponseType::StepOver: - if (response.value("success").toBool()) { + if (success) { showMessage(command, LogDebug); notifyInferiorRunOk(); } else { @@ -692,11 +693,21 @@ void DapEngine::handleResponse(DapResponseType type, const QJsonObject &response case DapResponseType::SetBreakpoints: handleBreakpointResponse(response); break; + case DapResponseType::Launch: + if (!success) { + notifyEngineRunFailed(); + AsynchronousMessageBox::critical( + Tr::tr("Failed to Start Application"), + Tr::tr("\"%1\" could not be started. Error message: %2") + .arg(runParameters().inferior.command.toUserOutput()) + .arg(response.value("message").toString())); + } + break; default: showMessage("UNKNOWN RESPONSE:" + command); }; - if (response.contains("success") && !response.value("success").toBool()) { + if (!success) { showMessage(QString("DAP COMMAND FAILED: %1").arg(command)); qCDebug(logCategory()) << "DAP COMMAND FAILED:" << command; return;