forked from qt-creator/qt-creator
Debugger: Fix environment when initializing
Previously when detecting / checking debuggers the process would be started with the Host environment set. This was incorrect for remote debuggers. Change-Id: Icd210dbfc9437e9abd2e0c4248e5503129bf6d8b Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -114,7 +114,7 @@ void DebuggerItem::createId()
|
||||
m_id = QUuid::createUuid().toString();
|
||||
}
|
||||
|
||||
void DebuggerItem::reinitializeFromFile(const Environment &sysEnv, QString *error)
|
||||
void DebuggerItem::reinitializeFromFile(QString *error, Utils::Environment *customEnv)
|
||||
{
|
||||
// CDB only understands the single-dash -version, whereas GDB and LLDB are
|
||||
// happy with both -version and --version. So use the "working" -version
|
||||
@@ -137,7 +137,8 @@ void DebuggerItem::reinitializeFromFile(const Environment &sysEnv, QString *erro
|
||||
return;
|
||||
}
|
||||
|
||||
Environment env = sysEnv.isValid() ? sysEnv : Environment::systemEnvironment();
|
||||
Environment env = customEnv ? *customEnv : m_command.deviceEnvironment();
|
||||
|
||||
// Prevent calling lldb on Windows because the lldb from the llvm package is linked against
|
||||
// python but does not contain a python dll.
|
||||
const bool isAndroidNdkLldb = DebuggerItem::addAndroidLldbPythonEnv(m_command, env);
|
||||
@@ -186,18 +187,8 @@ void DebuggerItem::reinitializeFromFile(const Environment &sysEnv, QString *erro
|
||||
const bool unableToFindAVersion = (0 == version);
|
||||
const bool gdbSupportsConfigurationFlag = (version >= 70700);
|
||||
if (gdbSupportsConfigurationFlag || unableToFindAVersion) {
|
||||
|
||||
auto gdbConfiguration = [this, &output, &sysEnv]() {
|
||||
if (!output.contains("qnx"))
|
||||
return getGdbConfiguration(m_command, sysEnv);
|
||||
|
||||
Environment env = sysEnv;
|
||||
env.set("QNX_TARGET", QString());
|
||||
return getGdbConfiguration(m_command, env);
|
||||
};
|
||||
|
||||
const QString gdbTargetAbiString =
|
||||
extractGdbTargetAbiStringFromGdbOutput(gdbConfiguration());
|
||||
const QString gdbTargetAbiString = extractGdbTargetAbiStringFromGdbOutput(
|
||||
getGdbConfiguration(m_command, env));
|
||||
if (!gdbTargetAbiString.isEmpty()) {
|
||||
m_abis.append(Abi::abiFromTargetTriplet(gdbTargetAbiString));
|
||||
return;
|
||||
|
||||
@@ -76,8 +76,7 @@ public:
|
||||
bool operator==(const DebuggerItem &other) const;
|
||||
bool operator!=(const DebuggerItem &other) const { return !operator==(other); }
|
||||
|
||||
void reinitializeFromFile(const Utils::Environment &sysEnv = Utils::Environment::systemEnvironment(),
|
||||
QString *error = nullptr);
|
||||
void reinitializeFromFile(QString *error = nullptr, Utils::Environment *env = nullptr);
|
||||
|
||||
Utils::FilePath workingDirectory() const { return m_workingDirectory; }
|
||||
void setWorkingDirectory(const Utils::FilePath &workingPath) { m_workingDirectory = workingPath; }
|
||||
|
||||
@@ -296,7 +296,7 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget()
|
||||
DebuggerItem item;
|
||||
item.setCommand(m_binaryChooser->filePath());
|
||||
errorMessage->clear();
|
||||
item.reinitializeFromFile({}, errorMessage);
|
||||
item.reinitializeFromFile(errorMessage);
|
||||
return errorMessage->isEmpty();
|
||||
});
|
||||
m_binaryChooser->setAllowPathFromDevice(true);
|
||||
|
||||
@@ -236,9 +236,10 @@ QVariant QnxConfiguration::createDebugger(const Target &target)
|
||||
{
|
||||
Utils::Environment sysEnv = Utils::Environment::systemEnvironment();
|
||||
sysEnv.modify(qnxEnvironmentItems());
|
||||
|
||||
Debugger::DebuggerItem debugger;
|
||||
debugger.setCommand(target.m_debuggerPath);
|
||||
debugger.reinitializeFromFile(sysEnv);
|
||||
debugger.reinitializeFromFile(nullptr, &sysEnv);
|
||||
debugger.setAutoDetected(true);
|
||||
debugger.setUnexpandedDisplayName(Tr::tr("Debugger for %1 (%2)")
|
||||
.arg(displayName())
|
||||
@@ -416,10 +417,11 @@ void QnxConfiguration::assignDebuggersToTargets()
|
||||
{{HostOsInfo::withExecutableSuffix("nto*-gdb")}, QDir::Files});
|
||||
Environment sysEnv = Environment::systemEnvironment();
|
||||
sysEnv.modify(qnxEnvironmentItems());
|
||||
|
||||
for (const FilePath &debuggerPath : debuggerNames) {
|
||||
DebuggerItem item;
|
||||
item.setCommand(debuggerPath);
|
||||
item.reinitializeFromFile(sysEnv);
|
||||
item.reinitializeFromFile(nullptr, &sysEnv);
|
||||
bool found = false;
|
||||
for (const Abi &abi : item.abis()) {
|
||||
for (Target &target : m_targets) {
|
||||
|
||||
Reference in New Issue
Block a user