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();
|
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
|
// CDB only understands the single-dash -version, whereas GDB and LLDB are
|
||||||
// happy with both -version and --version. So use the "working" -version
|
// happy with both -version and --version. So use the "working" -version
|
||||||
@@ -137,7 +137,8 @@ void DebuggerItem::reinitializeFromFile(const Environment &sysEnv, QString *erro
|
|||||||
return;
|
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
|
// Prevent calling lldb on Windows because the lldb from the llvm package is linked against
|
||||||
// python but does not contain a python dll.
|
// python but does not contain a python dll.
|
||||||
const bool isAndroidNdkLldb = DebuggerItem::addAndroidLldbPythonEnv(m_command, env);
|
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 unableToFindAVersion = (0 == version);
|
||||||
const bool gdbSupportsConfigurationFlag = (version >= 70700);
|
const bool gdbSupportsConfigurationFlag = (version >= 70700);
|
||||||
if (gdbSupportsConfigurationFlag || unableToFindAVersion) {
|
if (gdbSupportsConfigurationFlag || unableToFindAVersion) {
|
||||||
|
const QString gdbTargetAbiString = extractGdbTargetAbiStringFromGdbOutput(
|
||||||
auto gdbConfiguration = [this, &output, &sysEnv]() {
|
getGdbConfiguration(m_command, env));
|
||||||
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());
|
|
||||||
if (!gdbTargetAbiString.isEmpty()) {
|
if (!gdbTargetAbiString.isEmpty()) {
|
||||||
m_abis.append(Abi::abiFromTargetTriplet(gdbTargetAbiString));
|
m_abis.append(Abi::abiFromTargetTriplet(gdbTargetAbiString));
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -76,8 +76,7 @@ public:
|
|||||||
bool operator==(const DebuggerItem &other) const;
|
bool operator==(const DebuggerItem &other) const;
|
||||||
bool operator!=(const DebuggerItem &other) const { return !operator==(other); }
|
bool operator!=(const DebuggerItem &other) const { return !operator==(other); }
|
||||||
|
|
||||||
void reinitializeFromFile(const Utils::Environment &sysEnv = Utils::Environment::systemEnvironment(),
|
void reinitializeFromFile(QString *error = nullptr, Utils::Environment *env = nullptr);
|
||||||
QString *error = nullptr);
|
|
||||||
|
|
||||||
Utils::FilePath workingDirectory() const { return m_workingDirectory; }
|
Utils::FilePath workingDirectory() const { return m_workingDirectory; }
|
||||||
void setWorkingDirectory(const Utils::FilePath &workingPath) { m_workingDirectory = workingPath; }
|
void setWorkingDirectory(const Utils::FilePath &workingPath) { m_workingDirectory = workingPath; }
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget()
|
|||||||
DebuggerItem item;
|
DebuggerItem item;
|
||||||
item.setCommand(m_binaryChooser->filePath());
|
item.setCommand(m_binaryChooser->filePath());
|
||||||
errorMessage->clear();
|
errorMessage->clear();
|
||||||
item.reinitializeFromFile({}, errorMessage);
|
item.reinitializeFromFile(errorMessage);
|
||||||
return errorMessage->isEmpty();
|
return errorMessage->isEmpty();
|
||||||
});
|
});
|
||||||
m_binaryChooser->setAllowPathFromDevice(true);
|
m_binaryChooser->setAllowPathFromDevice(true);
|
||||||
|
|||||||
@@ -236,9 +236,10 @@ QVariant QnxConfiguration::createDebugger(const Target &target)
|
|||||||
{
|
{
|
||||||
Utils::Environment sysEnv = Utils::Environment::systemEnvironment();
|
Utils::Environment sysEnv = Utils::Environment::systemEnvironment();
|
||||||
sysEnv.modify(qnxEnvironmentItems());
|
sysEnv.modify(qnxEnvironmentItems());
|
||||||
|
|
||||||
Debugger::DebuggerItem debugger;
|
Debugger::DebuggerItem debugger;
|
||||||
debugger.setCommand(target.m_debuggerPath);
|
debugger.setCommand(target.m_debuggerPath);
|
||||||
debugger.reinitializeFromFile(sysEnv);
|
debugger.reinitializeFromFile(nullptr, &sysEnv);
|
||||||
debugger.setAutoDetected(true);
|
debugger.setAutoDetected(true);
|
||||||
debugger.setUnexpandedDisplayName(Tr::tr("Debugger for %1 (%2)")
|
debugger.setUnexpandedDisplayName(Tr::tr("Debugger for %1 (%2)")
|
||||||
.arg(displayName())
|
.arg(displayName())
|
||||||
@@ -416,10 +417,11 @@ void QnxConfiguration::assignDebuggersToTargets()
|
|||||||
{{HostOsInfo::withExecutableSuffix("nto*-gdb")}, QDir::Files});
|
{{HostOsInfo::withExecutableSuffix("nto*-gdb")}, QDir::Files});
|
||||||
Environment sysEnv = Environment::systemEnvironment();
|
Environment sysEnv = Environment::systemEnvironment();
|
||||||
sysEnv.modify(qnxEnvironmentItems());
|
sysEnv.modify(qnxEnvironmentItems());
|
||||||
|
|
||||||
for (const FilePath &debuggerPath : debuggerNames) {
|
for (const FilePath &debuggerPath : debuggerNames) {
|
||||||
DebuggerItem item;
|
DebuggerItem item;
|
||||||
item.setCommand(debuggerPath);
|
item.setCommand(debuggerPath);
|
||||||
item.reinitializeFromFile(sysEnv);
|
item.reinitializeFromFile(nullptr, &sysEnv);
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (const Abi &abi : item.abis()) {
|
for (const Abi &abi : item.abis()) {
|
||||||
for (Target &target : m_targets) {
|
for (Target &target : m_targets) {
|
||||||
|
|||||||
Reference in New Issue
Block a user