diff --git a/share/qtcreator/gdbmacros/dumper.py b/share/qtcreator/gdbmacros/dumper.py
index 5691cfd216fe6a0b56001c9407aeae9586ac726d..fb4526390dfb9bad76ce49396a175772deb55e10 100644
--- a/share/qtcreator/gdbmacros/dumper.py
+++ b/share/qtcreator/gdbmacros/dumper.py
@@ -173,9 +173,19 @@ def catchCliOutput(command):
     gdb.execute("set logging file %s" % filename)
     gdb.execute("set logging redirect on")
     gdb.execute("set logging on")
-    gdb.execute(command)
+    msg = ""
+    try:
+        gdb.execute(command)
+    except RuntimeError, error:
+        # For the first phase of core file loading this yield
+        # "No symbol table is loaded.  Use the \"file\" command."
+        msg = str(error)
+    except:
+        msg = "Unknown error";
     gdb.execute("set logging off")
     gdb.execute("set logging redirect off")
+    if len(msg):
+        warn("CLI ERROR: %s " % msg)
     temp = open(filename, "r")
     lines = []
     for line in temp:
@@ -860,29 +870,32 @@ class SetupCommand(gdb.Command):
         super(SetupCommand, self).__init__("bbsetup", gdb.COMMAND_OBSCURE)
 
     def invoke(self, args, from_tty):
-        module = sys.modules[__name__]
-        for key, value in module.__dict__.items():
-            if key.startswith("qdump__"):
-                name = key[7:]
-                qqDumpers[name] = value
-                qqFormats[name] = qqFormats.get(name, "");
-            elif key.startswith("qform__"):
-                name = key[7:]
-                formats = ""
-                try:
-                    formats = value()
-                except:
-                    pass
-                qqFormats[name] = formats
-        result = "dumpers=["
-        qqNs = qtNamespace()
-        for key, value in qqFormats.items():
-            result += '{type="%s",formats="%s"},' % (key, value)
-        result += '],namespace="%s"' % qqNs
-        print(result)
+        print bbsetup()
 
 SetupCommand()
 
+def bbsetup():
+    module = sys.modules[__name__]
+    for key, value in module.__dict__.items():
+        if key.startswith("qdump__"):
+            name = key[7:]
+            qqDumpers[name] = value
+            qqFormats[name] = qqFormats.get(name, "");
+        elif key.startswith("qform__"):
+            name = key[7:]
+            formats = ""
+            try:
+                formats = value()
+            except:
+                pass
+            qqFormats[name] = formats
+    result = "dumpers=["
+    qqNs = qtNamespace()
+    for key, value in qqFormats.items():
+        result += '{type="%s",formats="%s"},' % (key, value)
+    result += '],namespace="%s"' % qqNs
+    return result
+
 
 #######################################################################
 #
diff --git a/src/plugins/debugger/gdb/coregdbadapter.cpp b/src/plugins/debugger/gdb/coregdbadapter.cpp
index b656c59e537acb168cccb38248198182a9fd888b..6bbd641a6f57c9f5adb775084a518bba6cf086b1 100644
--- a/src/plugins/debugger/gdb/coregdbadapter.cpp
+++ b/src/plugins/debugger/gdb/coregdbadapter.cpp
@@ -46,6 +46,10 @@ namespace Internal {
     static_cast<GdbEngine::AdapterCallback>(&CoreGdbAdapter::callback), \
     STRINGIFY(callback)
 
+#ifdef Q_OS_LINUX
+# define EXE_FROM_CORE
+#endif
+
 ///////////////////////////////////////////////////////////////////////
 //
 // CoreGdbAdapter
@@ -53,7 +57,7 @@ namespace Internal {
 ///////////////////////////////////////////////////////////////////////
 
 CoreGdbAdapter::CoreGdbAdapter(GdbEngine *engine, QObject *parent)
-    : AbstractGdbAdapter(engine, parent)
+    : AbstractGdbAdapter(engine, parent), m_round(1)
 {
 }
 
@@ -94,6 +98,7 @@ void CoreGdbAdapter::setupInferior()
 
 void CoreGdbAdapter::loadExeAndSyms()
 {
+    QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
     // Do that first, otherwise no symbols are loaded.
     QFileInfo fi(m_executable);
     QByteArray path = fi.absoluteFilePath().toLocal8Bit();
@@ -116,6 +121,7 @@ void CoreGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
 
 void CoreGdbAdapter::loadCoreFile()
 {
+    QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
     // Quoting core name below fails in gdb 6.8-debian.
     QFileInfo fi(startParameters().coreFile);
     QByteArray coreName = fi.absoluteFilePath().toLocal8Bit();
diff --git a/src/plugins/debugger/gdb/coregdbadapter.h b/src/plugins/debugger/gdb/coregdbadapter.h
index b1df5e535f6de06fe5a9bad36599a56eabbc55ae..f2ea1d18f261ca6765720e47a9a2467bee707c07 100644
--- a/src/plugins/debugger/gdb/coregdbadapter.h
+++ b/src/plugins/debugger/gdb/coregdbadapter.h
@@ -34,9 +34,6 @@
 
 #include "abstractgdbprocess.h"
 
-#ifdef Q_OS_LINUX
-# define EXE_FROM_CORE
-#endif
 
 namespace Debugger {
 namespace Internal {
@@ -71,9 +68,7 @@ private:
     void handleFileExecAndSymbols(const GdbResponse &response);
     void handleTargetCore(const GdbResponse &response);
 
-#ifdef EXE_FROM_CORE
-    int m_round;
-#endif
+    int m_round; // Round 1: read executable name from core, Round 2: use it.
     QString m_executable;
     LocalGdbProcess m_gdbProc;
 };
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index ed8a67bf918f8ced46f451c3ca55d6e4d3aa215d..bd86a6c64ec9ebb8708ed043767bf215825ef205 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -4140,7 +4140,7 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &gdb, const QStr
     postCommand("python execfile('" + dumperSourcePath + "gdbmacros.py')",
         ConsoleCommand|NonCriticalResponse);
     postCommand("bbsetup",
-        ConsoleCommand,CB(handleHasPython));
+        ConsoleCommand, CB(handleHasPython));
 
     return true;
 }