Commit 0f46ad4a authored by BogDan Vatra's avatar BogDan Vatra
Browse files

Debugger: Set debuggee environment vars.



Env vars should be set to debuggee not to debugger.

Change-Id: I1ff877e295cb61f3a47c3aec5ffb43dea64df1cc
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent 2901b008
......@@ -59,8 +59,6 @@ void GdbAttachEngine::setupEngine()
if (!runParameters().workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(runParameters().workingDirectory);
if (runParameters().environment.size())
m_gdbProc.setEnvironment(runParameters().environment);
startGdb();
}
......
......@@ -4260,6 +4260,14 @@ void GdbEngine::loadInitScript()
}
}
void GdbEngine::setEnvironmentVariables()
{
if (runParameters().environment.size()) {
foreach (const QString &env, runParameters().environment.toStringList())
postCommand("-gdb-set environment " + env.toUtf8());
}
}
void GdbEngine::reloadDebuggingHelpers()
{
runCommand("reloadDumpers");
......@@ -4570,7 +4578,7 @@ bool GdbEngine::prepareCommand()
QtcProcess::SplitError perr;
rp.processArgs = QtcProcess::prepareArgs(rp.processArgs, &perr,
HostOsInfo::hostOs(),
&rp.environment, &rp.workingDirectory).toWindowsArgs();
nullptr, &rp.workingDirectory).toWindowsArgs();
if (perr != QtcProcess::SplitOk) {
// perr == BadQuoting is never returned on Windows
// FIXME? QTCREATORBUG-2809
......
......@@ -103,6 +103,7 @@ protected: ////////// Gdb Process Management //////////
void handleGdbExit(const DebuggerResponse &response);
void loadInitScript();
void setEnvironmentVariables();
// Something went wrong with the adapter *before* adapterStarted() was emitted.
// Make sure to clean up everything before emitting this signal.
......
......@@ -57,6 +57,7 @@ GdbPlainEngine::GdbPlainEngine(const DebuggerRunParameters &startParameters)
void GdbPlainEngine::setupInferior()
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
setEnvironmentVariables();
if (!runParameters().processArgs.isEmpty()) {
QString args = runParameters().processArgs;
postCommand("-exec-arguments " + toLocalEncoding(args));
......@@ -127,9 +128,6 @@ void GdbPlainEngine::setupEngine()
if (!runParameters().workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(runParameters().workingDirectory);
Utils::Environment env = runParameters().environment;
if (env.size())
m_gdbProc.setEnvironment(env);
startGdb(gdbArgs);
}
......
......@@ -91,8 +91,6 @@ void GdbRemoteServerEngine::setupEngine()
}
if (!runParameters().workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(runParameters().workingDirectory);
if (runParameters().environment.size())
m_gdbProc.setEnvironment(runParameters().environment);
if (runParameters().remoteSetupNeeded)
notifyEngineRequestRemoteSetup();
......@@ -186,6 +184,8 @@ void GdbRemoteServerEngine::setupInferior()
if (!args.isEmpty())
postCommand("-exec-arguments " + args.toLocal8Bit());
setEnvironmentVariables();
// This has to be issued before 'target remote'. On pre-7.0 the
// command is not present and will result in ' No symbol table is
// loaded. Use the "file" command.' as gdb tries to set the
......
......@@ -182,7 +182,7 @@ bool LldbEngine::prepareCommand()
QtcProcess::SplitError perr;
rp.processArgs = QtcProcess::prepareArgs(rp.processArgs, &perr,
HostOsInfo::hostOs(),
&rp.environment, &rp.workingDirectory).toWindowsArgs();
nullptr, &rp.workingDirectory).toWindowsArgs();
if (perr != QtcProcess::SplitOk) {
// perr == BadQuoting is never returned on Windows
// FIXME? QTCREATORBUG-2809
......@@ -290,6 +290,11 @@ void LldbEngine::startLldbStage2()
void LldbEngine::setupInferior()
{
if (runParameters().environment.size()) {
foreach (const QString &env, runParameters().environment.toStringList())
runCommand("env " + env.toUtf8());
}
const QString path = stringSetting(ExtraDumperFile);
if (!path.isEmpty() && QFileInfo(path).isReadable()) {
DebuggerCommand cmd("addDumperModule");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment