From 22a949b5c137acf2210e0fbf0dff318b45a35271 Mon Sep 17 00:00:00 2001
From: Kai Koehne <kai.koehne@nokia.com>
Date: Wed, 21 Mar 2012 16:13:01 +0100
Subject: [PATCH] Gdb: Fix shutdown of engine if app exits (gdbserver)

Sometimes the "Remote connection closed" message is the last
one we get from gdbserver. handleResultRecord might not be called
any more.

Change-Id: Ib4c1155bf21c605ac39d75582c1a26676475cb7a
Reviewed-by: hjk <qthjk@ovi.com>
---
 src/plugins/debugger/gdb/gdbengine.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 7e0a941122e..49ac5594bcb 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -607,6 +607,12 @@ void GdbEngine::handleResponse(const QByteArray &buff)
             // version and/or OS version used.
             if (data.startsWith("warning:"))
                 showMessage(_(data.mid(9)), AppStuff); // Cut "warning: "
+
+            // Messages when the target exits (gdbserver)
+            if (data.trimmed() == "Remote connection closed"
+                    || data.trimmed() == "Quit") {
+                notifyInferiorExited();
+            }
             break;
         }
 
@@ -1025,10 +1031,6 @@ void GdbEngine::handleResultRecord(GdbResponse *response)
                 QTC_CHECK(state() == InferiorRunOk);
                 notifyInferiorSpontaneousStop();
                 notifyEngineIll();
-            } else if (msg.startsWith("Remote connection closed")
-                       || msg.startsWith("Quit")) {
-                // Can happen when the target exits (gdbserver)
-                notifyInferiorExited();
             } else {
                 // Windows: Some DLL or some function not found. Report
                 // the exception now in a box.
-- 
GitLab