diff options
author | Marcus Tillmanns <marcus.tillmanns@qt.io> | 2022-07-12 11:34:34 +0200 |
---|---|---|
committer | Marcus Tillmanns <marcus.tillmanns@qt.io> | 2022-07-12 10:43:43 +0000 |
commit | 78e7c7b2a640fda7534721c303141243598b04bc (patch) | |
tree | 03c3324b56ec627447b78e8a50a50c03c56ce6d6 | |
parent | 226abd4de75dfa9542af5be043cda74a5ebdc4af (diff) |
docker: Fix run environment setup
When starting a debug session the systemEnvironment() was used
as the basis for the debugger process. If the docker device
did not have the same shell installed as the host, this would
break gdb as the SHELL= env variable might point to a
non-existing shell binary.
Change-Id: I7253ad3c4995eed857279146f1b258febe1ca710
Reviewed-by: hjk <hjk@qt.io>
-rw-r--r-- | src/plugins/debugger/gdb/gdbengine.cpp | 5 | ||||
-rw-r--r-- | src/plugins/projectexplorer/buildconfiguration.cpp | 8 | ||||
-rw-r--r-- | src/plugins/projectexplorer/kit.cpp | 7 |
3 files changed, 14 insertions, 6 deletions
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 6dc3cb9d80..9da5a188f3 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -3854,6 +3854,7 @@ void GdbEngine::setupEngine() if (!debuggerSettings()->loadGdbInit.value()) gdbCommand.addArg("-n"); + // This is filled in DebuggerKitAspect::runnable Environment gdbEnv = rp.debugger.environment; gdbEnv.setupEnglishOutput(); if (rp.runAsRoot) @@ -4046,9 +4047,9 @@ void GdbEngine::setEnvironmentVariables() && str.compare("path", Qt::CaseInsensitive) == 0; }; - Environment sysEnv = Environment::systemEnvironment(); + Environment baseEnv = runParameters().debugger.environment; Environment runEnv = runParameters().inferior.environment; - const NameValueItems items = sysEnv.diff(runEnv); + const NameValueItems items = baseEnv.diff(runEnv); for (const EnvironmentItem &item : items) { // imitate the weird windows gdb behavior of setting the case of the path environment // variable name to an all uppercase PATH diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index 10758d451e..f867cc8bdd 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -47,6 +47,8 @@ #include <coreplugin/icore.h> #include <coreplugin/idocument.h> +#include <projectexplorer/devicesupport/idevice.h> + #include <utils/algorithm.h> #include <utils/detailswidget.h> #include <utils/layoutbuilder.h> @@ -486,8 +488,10 @@ void BuildConfiguration::setBuildDirectorySettingsKey(const QString &key) Environment BuildConfiguration::baseEnvironment() const { Environment result; - if (useSystemEnvironment()) - result = Environment::systemEnvironment(); + if (useSystemEnvironment()) { + ProjectExplorer::IDevice::ConstPtr devicePtr = BuildDeviceKitAspect::device(kit()); + result = devicePtr ? devicePtr->systemEnvironment() : Environment::systemEnvironment(); + } addToEnvironment(result); kit()->addToBuildEnvironment(result); result.modify(project()->additionalEnvironment()); diff --git a/src/plugins/projectexplorer/kit.cpp b/src/plugins/projectexplorer/kit.cpp index 41941b9d20..42f74c77f9 100644 --- a/src/plugins/projectexplorer/kit.cpp +++ b/src/plugins/projectexplorer/kit.cpp @@ -25,6 +25,7 @@ #include "kit.h" +#include "devicesupport/idevice.h" #include "devicesupport/idevicefactory.h" #include "kitinformation.h" #include "kitmanager.h" @@ -575,14 +576,16 @@ void Kit::addToRunEnvironment(Environment &env) const Environment Kit::buildEnvironment() const { - Environment env = Environment::systemEnvironment(); // FIXME: Use build device + IDevice::ConstPtr device = BuildDeviceKitAspect::device(this); + Environment env = device ? device->systemEnvironment() : Environment::systemEnvironment(); addToBuildEnvironment(env); return env; } Environment Kit::runEnvironment() const { - Environment env = Environment::systemEnvironment(); // FIXME: Use run device + IDevice::ConstPtr device = DeviceKitAspect::device(this); + Environment env = device ? device->systemEnvironment() : Environment::systemEnvironment(); addToRunEnvironment(env); return env; } |