From a10a35d9eb7df8c595a0931939c5719fbc191893 Mon Sep 17 00:00:00 2001 From: Antonio Di Monaco Date: Wed, 10 Jul 2019 09:20:40 +0200 Subject: [PATCH] Filter leading GDB messages during version detection When using GDB through a script, additional messages can be printed before the line reporting the version number, and some digits of those messages could be interpreted as a version value, leading to wrong version detection. This patch searches for the "GNU gdb" tag first, so the correct line is evaluated. Change-Id: Ief64a056a20a963ad01c44941777361abcce00fc Reviewed-by: Orgad Shaneh Reviewed-by: hjk --- src/plugins/debugger/debuggerprotocol.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp index d01e82f649f..cb9302211ba 100644 --- a/src/plugins/debugger/debuggerprotocol.cpp +++ b/src/plugins/debugger/debuggerprotocol.cpp @@ -457,7 +457,13 @@ void extractGdbVersion(const QString &msg, QString build; bool inClean = true; bool inParenthesis = false; - for (QChar c : msg) { + + int gdbMsgBegin = msg.indexOf("GNU gdb"); + if (gdbMsgBegin == -1) + gdbMsgBegin = 0; + + for (int i = gdbMsgBegin, gdbMsgSize = msg.size(); i < gdbMsgSize; ++i) { + QChar c = msg.at(i); if (inClean && !cleaned.isEmpty() && c != dot && (c.isPunct() || c.isSpace())) inClean = false; if (ignoreParenthesisContent) {