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 <artem.sokolovskii@qt.io>
This commit is contained in:
Cristian Adam
2024-06-20 11:32:16 +02:00
parent 6e648ee931
commit cd3729b4aa
3 changed files with 16 additions and 2 deletions

View File

@@ -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;

View File

@@ -55,6 +55,7 @@ enum class DapResponseType
SetBreakpoints,
SetFunctionBreakpoints,
Attach,
Launch,
Unknown
};

View File

@@ -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;