From 9d86ad7990559823ddf4421f26154c5091d916be Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 7 May 2012 14:29:22 +0200 Subject: [PATCH] Debugger: Catch 'Remote connection closed' in response 'Remote connection closed' messages sometimes also arrive camuflaged as a response to a command (with the response of the original command already there). Change-Id: I8fa75f561fb341463fc4c0ed0a35aa6fd8300694 Reviewed-by: hjk --- src/plugins/debugger/gdb/gdbengine.cpp | 29 +++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 8ef024d6127..627fceb4aa5 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -386,6 +386,26 @@ static bool isNameChar(char c) return (c >= 'a' && c <= 'z') || c == '-'; } +static bool isGdbConnectionError(const QByteArray &message) +{ + // + // Handle messages gdb client produces when the target exits (gdbserver) + // + // we get this as response either to a specific command, e.g. + // 31^error,msg="Remote connection closed" + // or as informative output: + // &Remote connection closed + // + const QByteArray trimmed = message.trimmed(); + if (trimmed == "Remote connection closed" + || trimmed == "Remote communication error. " + "Target disconnected.: No error." + || trimmed == "Quit") { + return true; + } + return false; +} + void GdbEngine::handleResponse(const QByteArray &buff) { showMessage(QString::fromLocal8Bit(buff, buff.length()), LogOutput); @@ -668,12 +688,9 @@ void GdbEngine::handleResponse(const QByteArray &buff) 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() == "Remote communication error. " - "Target disconnected.: No error." - || data.trimmed() == "Quit") { + if (isGdbConnectionError(data)) { notifyInferiorExited(); + break; } // From SuSE's gdb: >&"Missing separate debuginfo for ...\n" @@ -1113,6 +1130,8 @@ void GdbEngine::handleResultRecord(GdbResponse *response) QTC_CHECK(state() == InferiorRunOk); notifyInferiorSpontaneousStop(); notifyEngineIll(); + } else if (isGdbConnectionError(msg)) { + notifyInferiorExited(); } else { // Windows: Some DLL or some function not found. Report // the exception now in a box.