From 715e72117d1d9389720a60fb6196d3fbcea474e4 Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Mon, 6 Sep 2010 14:26:19 +0200
Subject: [PATCH] debugger: remove one of the three failure notification if a
 gdb binary is not found with the remote adapter

---
 src/plugins/debugger/gdb/gdbengine.cpp        | 17 ++++----
 .../debugger/gdb/remotegdbserveradapter.cpp   | 39 +++++++++++++------
 .../debugger/gdb/remotegdbserveradapter.h     |  1 +
 3 files changed, 38 insertions(+), 19 deletions(-)

diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 47f0810a9db..b9863631e52 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -4015,8 +4015,7 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &gdb, const QStr
     gdbProc()->start(m_gdb, gdbArgs);
 
     if (!gdbProc()->waitForStarted()) {
-        const QString msg = tr("Unable to start gdb '%1': %2")
-            .arg(m_gdb, gdbProc()->errorString());
+        const QString msg = errorMessage(QProcess::FailedToStart);
         handleAdapterStartFailed(msg, settingsIdHint);
         return false;
     }
@@ -4129,19 +4128,23 @@ bool GdbEngine::checkDebuggingHelpers()
 
 void GdbEngine::handleGdbError(QProcess::ProcessError error)
 {
-    showMessage(_("HANDLE GDB ERROR: ") + errorMessage(error));
+    const QString msg = errorMessage(error);
+    showMessage(_("HANDLE GDB ERROR: ") + msg);
+    // Show a message box for asynchroneously reported issues.
     switch (error) {
+    case QProcess::FailedToStart:
+        // This should be handled by the code trying to start the process.
+        break;
     case QProcess::Crashed:
-        break; // will get a processExited() as well
-    // impossible case QProcess::FailedToStart:
+        // This will get a processExited() as well.
+        break;
     case QProcess::ReadError:
     case QProcess::WriteError:
     case QProcess::Timedout:
     default:
         //gdbProc()->kill();
         //setState(EngineShutdownRequested, true);
-        showMessageBox(QMessageBox::Critical, tr("Gdb I/O Error"),
-                       errorMessage(error));
+        showMessageBox(QMessageBox::Critical, tr("Gdb I/O Error"), msg);
         break;
     }
 }
diff --git a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp
index ef2c26e2345..824b5e78db8 100644
--- a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp
+++ b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp
@@ -164,6 +164,11 @@ void RemoteGdbServerAdapter::setupInferior()
 {
     QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
 
+    QString fileName;
+    if (!startParameters().executable.isEmpty()) {
+        QFileInfo fi(startParameters().executable);
+        fileName = fi.absoluteFilePath();
+    }
     m_engine->postCommand("set architecture "
         + startParameters().remoteArchitecture.toLatin1());
     m_engine->postCommand("set sysroot "
@@ -177,8 +182,13 @@ void RemoteGdbServerAdapter::setupInferior()
     }
 
     m_engine->postCommand("set target-async on", CB(handleSetTargetAsync));
-    QFileInfo fi(startParameters().executable);
-    QString fileName = fi.absoluteFilePath();
+
+    if (fileName.isEmpty()) {
+        showMessage(tr("No symbol file given."), StatusBar);
+        callTargetRemote();
+        return;
+    }
+
     m_engine->postCommand("-file-exec-and-symbols \""
         + fileName.toLocal8Bit() + '"',
         CB(handleFileExecAndSymbols));
@@ -195,22 +205,27 @@ void RemoteGdbServerAdapter::handleFileExecAndSymbols(const GdbResponse &respons
 {
     QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
     if (response.resultClass == GdbResultDone) {
-        //m_breakHandler->clearBreakMarkers();
-
-        // "target remote" does three things:
-        //     (1) connects to the gdb server
-        //     (2) starts the remote application
-        //     (3) stops the remote application (early, e.g. in the dynamic linker)
-        QString channel = startParameters().remoteChannel;
-        m_engine->postCommand("target remote " + channel.toLatin1(),
-            CB(handleTargetRemote));
+        callTargetRemote();
     } else {
-        QString msg = tr("Starting remote executable failed:\n");
+        QString msg = tr("Reading debug information failed:\n");
         msg += QString::fromLocal8Bit(response.data.findChild("msg").data());
         m_engine->notifyInferiorSetupFailed(msg);
     }
 }
 
+void RemoteGdbServerAdapter::callTargetRemote()
+{
+    //m_breakHandler->clearBreakMarkers();
+
+    // "target remote" does three things:
+    //     (1) connects to the gdb server
+    //     (2) starts the remote application
+    //     (3) stops the remote application (early, e.g. in the dynamic linker)
+    QString channel = startParameters().remoteChannel;
+    m_engine->postCommand("target remote " + channel.toLatin1(),
+        CB(handleTargetRemote));
+}
+
 void RemoteGdbServerAdapter::handleTargetRemote(const GdbResponse &record)
 {
     QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
diff --git a/src/plugins/debugger/gdb/remotegdbserveradapter.h b/src/plugins/debugger/gdb/remotegdbserveradapter.h
index fa4f8c6d2de..7eb89200c79 100644
--- a/src/plugins/debugger/gdb/remotegdbserveradapter.h
+++ b/src/plugins/debugger/gdb/remotegdbserveradapter.h
@@ -75,6 +75,7 @@ private:
 
     void handleSetTargetAsync(const GdbResponse &response);
     void handleFileExecAndSymbols(const GdbResponse &response);
+    void callTargetRemote();
     void handleTargetRemote(const GdbResponse &response);
 
     const int m_toolChainType;
-- 
GitLab