forked from qt-creator/qt-creator
LLDB-DAP: Add "env" to "launch" command
On Windows where there are no RPATHs we need to pass the environment to the "launch" event, otherwise applications can't be started. Also only add "sourceMap" and "preRunCommands" if the arrays are not empty. Change-Id: If631d36db8e28d2c30962b4e9c6a3aa3162000a1 Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
This commit is contained in:
@@ -115,6 +115,14 @@ LldbDapEngine::LldbDapEngine()
|
|||||||
setDebuggerType("DAP");
|
setDebuggerType("DAP");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonArray LldbDapEngine::environment() const
|
||||||
|
{
|
||||||
|
QJsonArray envArray;
|
||||||
|
for (const QString &value : runParameters().inferior.environment.toDictionary().toStringList())
|
||||||
|
envArray.append(value);
|
||||||
|
return envArray;
|
||||||
|
}
|
||||||
|
|
||||||
QJsonArray LldbDapEngine::sourceMap() const
|
QJsonArray LldbDapEngine::sourceMap() const
|
||||||
{
|
{
|
||||||
QJsonArray sourcePathMapping;
|
QJsonArray sourcePathMapping;
|
||||||
@@ -148,19 +156,25 @@ void LldbDapEngine::handleDapInitialize()
|
|||||||
// * https://github.com/llvm/llvm-project/blob/main/lldb/tools/lldb-dap/package.json
|
// * https://github.com/llvm/llvm-project/blob/main/lldb/tools/lldb-dap/package.json
|
||||||
|
|
||||||
const DebuggerRunParameters &rp = runParameters();
|
const DebuggerRunParameters &rp = runParameters();
|
||||||
|
const QJsonArray map = sourceMap();
|
||||||
|
const QJsonArray commands = preRunCommands();
|
||||||
|
|
||||||
if (!isLocalAttachEngine()) {
|
if (!isLocalAttachEngine()) {
|
||||||
m_dapClient->postRequest(
|
const QJsonArray env = environment();
|
||||||
"launch",
|
QJsonObject launchJson{
|
||||||
QJsonObject{
|
|
||||||
{"noDebug", false},
|
{"noDebug", false},
|
||||||
{"program", rp.inferior.command.executable().path()},
|
{"program", rp.inferior.command.executable().path()},
|
||||||
{"args", rp.inferior.command.arguments()},
|
{"args", rp.inferior.command.arguments()},
|
||||||
{"cwd", rp.inferior.workingDirectory.path()},
|
{"cwd", rp.inferior.workingDirectory.path()},
|
||||||
{"sourceMap", sourceMap()},
|
{"env", env},
|
||||||
{"preRunCommands", preRunCommands()},
|
|
||||||
{"__restart", ""},
|
{"__restart", ""},
|
||||||
});
|
};
|
||||||
|
if (!map.isEmpty())
|
||||||
|
launchJson.insert("sourceMap", map);
|
||||||
|
if (!commands.isEmpty())
|
||||||
|
launchJson.insert("preRunCommands", commands);
|
||||||
|
|
||||||
|
m_dapClient->postRequest("launch", launchJson);
|
||||||
|
|
||||||
qCDebug(logCategory()) << "handleDapLaunch";
|
qCDebug(logCategory()) << "handleDapLaunch";
|
||||||
return;
|
return;
|
||||||
@@ -168,15 +182,17 @@ void LldbDapEngine::handleDapInitialize()
|
|||||||
|
|
||||||
QTC_ASSERT(state() == EngineRunRequested, qCDebug(logCategory()) << state());
|
QTC_ASSERT(state() == EngineRunRequested, qCDebug(logCategory()) << state());
|
||||||
|
|
||||||
m_dapClient->postRequest(
|
QJsonObject attachJson{
|
||||||
"attach",
|
|
||||||
QJsonObject{
|
|
||||||
{"program", rp.inferior.command.executable().path()},
|
{"program", rp.inferior.command.executable().path()},
|
||||||
{"pid", QString::number(rp.attachPID.pid())},
|
{"pid", QString::number(rp.attachPID.pid())},
|
||||||
{"sourceMap", sourceMap()},
|
|
||||||
{"preRunCommands", preRunCommands()},
|
|
||||||
{"__restart", ""},
|
{"__restart", ""},
|
||||||
});
|
};
|
||||||
|
if (!map.isEmpty())
|
||||||
|
attachJson.insert("sourceMap", map);
|
||||||
|
if (!commands.isEmpty())
|
||||||
|
attachJson.insert("preRunCommands", commands);
|
||||||
|
|
||||||
|
m_dapClient->postRequest("attach", attachJson);
|
||||||
|
|
||||||
qCDebug(logCategory()) << "handleDapAttach";
|
qCDebug(logCategory()) << "handleDapAttach";
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ private:
|
|||||||
bool acceptsBreakpoint(const BreakpointParameters &bp) const override;
|
bool acceptsBreakpoint(const BreakpointParameters &bp) const override;
|
||||||
const QLoggingCategory &logCategory() override;
|
const QLoggingCategory &logCategory() override;
|
||||||
|
|
||||||
|
QJsonArray environment() const;
|
||||||
QJsonArray sourceMap() const;
|
QJsonArray sourceMap() const;
|
||||||
QJsonArray preRunCommands() const;
|
QJsonArray preRunCommands() const;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user