aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Roquetto <rafael.roquetto@qt.io>2022-03-04 14:08:32 +1000
committerRafael Roquetto <rafael.roquetto@qt.io>2022-03-09 22:38:34 +0000
commitb2920fb76a97c27a8ff5de17c315c22e536a0256 (patch)
treef037da3fde36794af71b80ca1a5d1f9836ecbbb0
parentc667450fe2a92a60e1d2debce8c90d0652f0913e (diff)
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> (cherry picked from commit 88aec120753768959cac7977d802c04dc2c6e526) Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
-rw-r--r--src/plugins/debugger/debuggeritem.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp
index b6060046c7c..4a34596e2fe 100644
--- a/src/plugins/debugger/debuggeritem.cpp
+++ b/src/plugins/debugger/debuggeritem.cpp
@@ -180,6 +180,12 @@ void DebuggerItem::reinitializeFromFile(const Environment &sysEnv, QString *erro
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;
proc.setEnvironment(env);
proc.setCommand({m_command, {version}});
@@ -208,9 +214,18 @@ void DebuggerItem::reinitializeFromFile(const Environment &sysEnv, QString *erro
const bool unableToFindAVersion = (0 == version);
const bool gdbSupportsConfigurationFlag = (version >= 70700);
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 =
- extractGdbTargetAbiStringFromGdbOutput(gdbConfiguration);
+ extractGdbTargetAbiStringFromGdbOutput(gdbConfiguration());
if (!gdbTargetAbiString.isEmpty()) {
m_abis.append(Abi::abiFromTargetTriplet(gdbTargetAbiString));
return;