From db753cd83efffcc2f1c26fb62ea9ae8c30560706 Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Mon, 29 Mar 2010 16:45:34 +0200
Subject: [PATCH] debugger: avoid confusing status message when exiting
 debugging if the the binary is already gone.

---
 src/plugins/debugger/gdb/gdbengine.cpp | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 502c96e3eda..965b8385a5a 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -615,8 +615,11 @@ void GdbEngine::handleResponse(const QByteArray &buff)
 void GdbEngine::readGdbStandardError()
 {
     QByteArray err = m_gdbProc.readAllStandardError();
+    debugMessage(_("UNEXPECTED GDB STDERR: " + err));
     if (err == "Undefined command: \"bb\".  Try \"help\".\n")
         return;
+    if (err.startsWith("BFD: reopening"))
+        return;
     qWarning() << "Unexpected gdb stderr:" << err;
 }
 
@@ -1651,11 +1654,20 @@ void GdbEngine::handleInferiorShutdown(const GdbResponse &response)
         debugMessage(_("INFERIOR SUCCESSFULLY SHUT DOWN"));
         setState(InferiorShutDown);
     } else {
-        debugMessage(_("INFERIOR SHUTDOWN FAILED"));
-        setState(InferiorShutdownFailed);
-        QString msg = m_gdbAdapter->msgInferiorStopFailed(
-            QString::fromLocal8Bit(response.data.findChild("msg").data()));
-        showMessageBox(QMessageBox::Critical, tr("Failed to shut down application"), msg);
+        QByteArray ba = response.data.findChild("msg").data();
+        if (ba.contains(": No such file or directory.")) {
+            // This happens when someone removed the binary behind our back.
+            // It is not really an error from a user's point of view.
+            debugMessage(_("INFERIOR SUCCESSFULLY SHUT DOWN"));
+            debugMessage(_("NOTE: " + ba));
+            setState(InferiorShutDown);
+        } else {
+            debugMessage(_("INFERIOR SHUTDOWN FAILED"));
+            setState(InferiorShutdownFailed);
+            showMessageBox(QMessageBox::Critical,
+                tr("Failed to shut down application"),
+                m_gdbAdapter->msgInferiorStopFailed(QString::fromLocal8Bit(ba)));
+        }
     }
     shutdown(); // re-iterate...
 }
-- 
GitLab