Debugger: Fix LLDB-DAP attach to process

Change-Id: I464db537d85de7bce943334379b6ce499b32dc2b
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
This commit is contained in:
Cristian Adam
2024-06-14 14:41:40 +02:00
parent ba73e3e50a
commit 0cb8760338
4 changed files with 15 additions and 4 deletions

View File

@@ -237,6 +237,8 @@ void DapClient::emitSignals(const QJsonDocument &doc)
type = DapResponseType::SetBreakpoints;
} else if (command == "setFunctionBreakpoints") {
type = DapResponseType::SetFunctionBreakpoints;
} else if (command == "attach") {
type = DapResponseType::Attach;
}
emit responseReady(type, ob);
return;

View File

@@ -54,6 +54,7 @@ enum class DapResponseType
Evaluate,
SetBreakpoints,
SetFunctionBreakpoints,
Attach,
Unknown
};

View File

@@ -692,6 +692,9 @@ void DapEngine::handleResponse(DapResponseType type, const QJsonObject &response
case DapResponseType::SetBreakpoints:
handleBreakpointResponse(response);
break;
case DapResponseType::Attach:
notifyInferiorRunOk();
break;
default:
showMessage("UNKNOWN RESPONSE:" + command);
};

View File

@@ -120,7 +120,15 @@ void LldbDapEngine::handleDapInitialize()
}
QTC_ASSERT(state() == EngineRunRequested, qCDebug(logCategory()) << state());
m_dapClient->postRequest("attach", QJsonObject{{"__restart", ""}});
const DebuggerRunParameters &rp = runParameters();
m_dapClient->postRequest(
"attach",
QJsonObject{
{"program", rp.inferior.command.executable().path()},
{"pid", QString::number(rp.attachPID.pid())},
{"__restart", ""}});
qCDebug(logCategory()) << "handleDapAttach";
}
@@ -146,9 +154,6 @@ void LldbDapEngine::setupEngine()
const DebuggerRunParameters &rp = runParameters();
CommandLine cmd{rp.debugger.command.executable()};
if (isLocalAttachEngine())
cmd.addArgs({"--debugger-pid", QString::number(rp.attachPID.pid())});
IDataProvider *dataProvider = new ProcessDataProvider(rp, cmd, this);
m_dapClient = new LldbDapClient(dataProvider, this);