diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 06f218fd334b34a8990d534524d40c85077869b0..ecb16b8caac3bfc85d8a9fa38bf2ffa911a93bef 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -1478,11 +1478,19 @@ void GdbEngine::handleShowVersion(const GdbResponse &response)
 
 void GdbEngine::handleHasPython(const GdbResponse &response)
 {
-    Q_UNUSED(response);
     if (response.resultClass == GdbResultDone) {
         m_hasPython = true;
     } else {
         m_hasPython = false;
+        if (m_gdbAdapter->dumperHandling() == AbstractGdbAdapter::DumperLoadedByGdbPreload
+                && checkDebuggingHelpersClassic()) {
+            QByteArray cmd = "set environment ";
+            cmd += Debugger::Constants::Internal::LD_PRELOAD_ENV_VAR;
+            cmd += ' ';
+            cmd += manager()->qtDumperLibraryName().toLocal8Bit();
+            postCommand(cmd);
+            m_debuggingHelperState = DebuggingHelperLoadTried;
+        }
     }
 }
 
@@ -3933,15 +3941,6 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &gdb, const QStr
 
     postCommand("show version", CB(handleShowVersion));
 
-    postCommand("-interpreter-exec console "
-            "\"python execfile('" + dumperSourcePath + "dumper.py')\"",
-        NonCriticalResponse);
-    postCommand("-interpreter-exec console "
-            "\"python execfile('" + dumperSourcePath + "gdbmacros.py')\"",
-        NonCriticalResponse);
-
-    postCommand("-interpreter-exec console \"help bb\"",
-        CB(handleHasPython));
     //postCommand("-enable-timings");
     postCommand("set print static-members off"); // Seemingly doesn't work.
     //postCommand("set debug infrun 1");
@@ -4021,15 +4020,17 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &gdb, const QStr
               ).arg(scriptFileName));
         }
     }
-    if (m_gdbAdapter->dumperHandling() == AbstractGdbAdapter::DumperLoadedByGdbPreload
-        && checkDebuggingHelpers()) {
-        QByteArray cmd = "set environment ";
-        cmd += Debugger::Constants::Internal::LD_PRELOAD_ENV_VAR;
-        cmd += ' ';
-        cmd += manager()->qtDumperLibraryName().toLocal8Bit();
-        postCommand(cmd);
-        m_debuggingHelperState = DebuggingHelperLoadTried;
-    }
+
+    postCommand("-interpreter-exec console "
+            "\"python execfile('" + dumperSourcePath + "dumper.py')\"",
+        NonCriticalResponse);
+    postCommand("-interpreter-exec console "
+            "\"python execfile('" + dumperSourcePath + "gdbmacros.py')\"",
+        NonCriticalResponse);
+
+    postCommand("-interpreter-exec console \"help bb\"",
+        CB(handleHasPython));
+
     return true;
 }