summaryrefslogtreecommitdiff
path: root/src/plugins/debugger/gdb/gdbmi.cpp
diff options
context:
space:
mode:
authorhjk <qtc-committer@nokia.com>2010-05-27 15:41:52 +0200
committerhjk <qtc-committer@nokia.com>2010-05-27 15:55:01 +0200
commit5afeaa720dd193ea4f9f48fac11e9ae28393d372 (patch)
tree7c11f8bfdf038d53ead9aea3a5912baabf9822f8 /src/plugins/debugger/gdb/gdbmi.cpp
parentaa93d6f422970e87555968da331593f1d989a83c (diff)
downloadqt-creator-5afeaa720dd193ea4f9f48fac11e9ae28393d372.tar.gz
debugger: more robust version string parsing
Fix for QTCREATORBUG-1490 Reviewed-By: Friedemann Kleint
Diffstat (limited to 'src/plugins/debugger/gdb/gdbmi.cpp')
-rw-r--r--src/plugins/debugger/gdb/gdbmi.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/plugins/debugger/gdb/gdbmi.cpp b/src/plugins/debugger/gdb/gdbmi.cpp
index c34d81124d..158a1fc2b9 100644
--- a/src/plugins/debugger/gdb/gdbmi.cpp
+++ b/src/plugins/debugger/gdb/gdbmi.cpp
@@ -32,6 +32,7 @@
#include <utils/qtcassert.h>
#include <QtCore/QByteArray>
+#include <QtCore/QRegExp>
#include <QtCore/QTextStream>
#include <ctype.h>
@@ -400,5 +401,50 @@ QByteArray GdbResponse::toString() const
return result;
}
+
+//////////////////////////////////////////////////////////////////////////////////
+//
+// GdbResponse
+//
+//////////////////////////////////////////////////////////////////////////////////
+
+void extractGdbVersion(const QString &msg,
+ int *gdbVersion, int *gdbBuildVersion, bool *isMacGdb)
+{
+ const QChar dot(QLatin1Char('.'));
+
+ QString cleaned;
+ QString build;
+ bool inClean = true;
+ foreach (QChar c, msg) {
+ if (inClean && !cleaned.isEmpty() && c != dot && (c.isPunct() || c.isSpace()))
+ inClean = false;
+ if (inClean) {
+ if (c.isDigit())
+ cleaned.append(c);
+ else if (!cleaned.isEmpty() && !cleaned.endsWith(dot))
+ cleaned.append(dot);
+ } else {
+ if (c.isDigit())
+ build.append(c);
+ else if (!build.isEmpty() && !build.endsWith(dot))
+ build.append(dot);
+ }
+ }
+
+ *isMacGdb = msg.contains(QLatin1String("Apple version"));
+
+ *gdbVersion = 10000 * cleaned.section(dot, 0, 0).toInt()
+ + 100 * cleaned.section(dot, 1, 1).toInt()
+ + 1 * cleaned.section(dot, 2, 2).toInt();
+ if (cleaned.count(dot) >= 3)
+ *gdbBuildVersion = cleaned.section(dot, 3, 3).toInt();
+ else
+ *gdbBuildVersion = build.section(dot, 0, 0).toInt();
+
+ if (*isMacGdb)
+ *gdbBuildVersion = build.section(dot, 1, 1).toInt();
+}
+
} // namespace Internal
} // namespace Debugger