forked from qt-creator/qt-creator
QNX: Fix debugger detection
The QNX gdb binary requires the QNX_TARGET env variable to be set even for codepaths that do not make use of it, namely, when invoking gdb with the --version or --configuration parameters to detect the ABI. Failure to set this variable causes gdb to fail with "QNX environment not set!" instead. This patch works around that by setting a phony QNX_TARGET variable in these occasions. Change-Id: I9f2638c422eb56516b87dde049186579d238de5c Reviewed-by: hjk <hjk@qt.io> Reviewed-by: James McDonnell <jmcdonnell@blackberry.com>
This commit is contained in:
@@ -180,6 +180,12 @@ void DebuggerItem::reinitializeFromFile(const Environment &sysEnv, QString *erro
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QNX gdb unconditionally checks whether the QNX_TARGET env variable is
|
||||||
|
// set and bails otherwise, even when it is not used by the specific
|
||||||
|
// codepath triggered by the --version and --configuration arguments. The
|
||||||
|
// hack below tricks it into giving us the information we want.
|
||||||
|
env.set("QNX_TARGET", QString());
|
||||||
|
|
||||||
QtcProcess proc;
|
QtcProcess proc;
|
||||||
proc.setEnvironment(env);
|
proc.setEnvironment(env);
|
||||||
proc.setCommand({m_command, {version}});
|
proc.setCommand({m_command, {version}});
|
||||||
@@ -208,9 +214,18 @@ 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 gdbConfiguration = getGdbConfiguration(m_command, sysEnv);
|
|
||||||
|
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 =
|
const QString gdbTargetAbiString =
|
||||||
extractGdbTargetAbiStringFromGdbOutput(gdbConfiguration);
|
extractGdbTargetAbiStringFromGdbOutput(gdbConfiguration());
|
||||||
if (!gdbTargetAbiString.isEmpty()) {
|
if (!gdbTargetAbiString.isEmpty()) {
|
||||||
m_abis.append(Abi::abiFromTargetTriplet(gdbTargetAbiString));
|
m_abis.append(Abi::abiFromTargetTriplet(gdbTargetAbiString));
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user