diff options
author | Eike Ziller <eike.ziller@digia.com> | 2014-06-18 14:20:58 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2014-06-18 14:20:58 +0200 |
commit | cbf4de03153a6729db6edcf244a282d901dd1c03 (patch) | |
tree | 81792056743630c19b384fd28f4ab9b1c665d970 | |
parent | 6cee8a42ff1b56f35143e6011d70747913710091 (diff) | |
parent | e3979fe09d7dd3ef1546e97d22d76178c8e38303 (diff) | |
download | qt-creator-cbf4de03153a6729db6edcf244a282d901dd1c03.tar.gz |
Merge remote-tracking branch 'origin/3.1'
Conflicts:
tests/auto/debugger/tst_dumpers.cpp
Change-Id: I1bad0c1477d7fd6996c0f8ca82e76ba521bc0dcc
-rw-r--r-- | share/qtcreator/debugger/gdbbridge.py | 30 | ||||
-rw-r--r-- | src/libs/cplusplus/PPToken.cpp | 3 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppelementevaluator.cpp | 2 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppincludehierarchy.cpp | 2 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppsnippetprovider.cpp | 2 | ||||
-rw-r--r-- | src/plugins/cppeditor/cpptypehierarchy.cpp | 2 | ||||
-rw-r--r-- | tests/auto/debugger/tst_dumpers.cpp | 185 |
7 files changed, 128 insertions, 98 deletions
diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py index fc735cf870..655a3c99b5 100644 --- a/share/qtcreator/debugger/gdbbridge.py +++ b/share/qtcreator/debugger/gdbbridge.py @@ -634,7 +634,8 @@ class Dumper(DumperBase): def childAt(self, value, index): field = value.type.fields()[index] - if len(field.name): + # GDB 7.7 commit b5b08fb4 started to report None as field names. + if field.name: try: return value[field.name] except: @@ -1242,7 +1243,7 @@ class Dumper(DumperBase): def putFields(self, value, dumpBase = True): fields = value.type.fields() - #warn("TYPE: %s" % type) + #warn("TYPE: %s" % value.type) #warn("FIELDS: %s" % fields) baseNumber = 0 for field in fields: @@ -1250,14 +1251,23 @@ class Dumper(DumperBase): #warn(" BITSIZE: %s" % field.bitsize) #warn(" ARTIFICIAL: %s" % field.artificial) + # Since GDB commit b5b08fb4 anonymous structs get also reported + # with a 'None' name. if field.name is None: - type = stripTypedefs(value.type) - innerType = type.target() - p = value.cast(innerType.pointer()) - for i in xrange(int(type.sizeof / innerType.sizeof)): - with SubItem(self, i): - self.putItem(p.dereference()) - p = p + 1 + if value.type.code == ArrayCode: + # An array. + type = stripTypedefs(value.type) + innerType = type.target() + p = value.cast(innerType.pointer()) + for i in xrange(int(type.sizeof / innerType.sizeof)): + with SubItem(self, i): + self.putItem(p.dereference()) + p = p + 1 + else: + # Something without a name. + self.anonNumber += 1 + with SubItem(self, str(self.anonNumber)): + self.putItem(value[field]) continue # Ignore vtable pointers for virtual inheritance. @@ -1313,7 +1323,7 @@ class Dumper(DumperBase): def listAnonymous(self, value, name, type): for field in type.fields(): #warn("FIELD NAME: %s" % field.name) - if len(field.name) > 0: + if field.name: with SubItem(self, field.name): self.putItem(value[field.name]) else: diff --git a/src/libs/cplusplus/PPToken.cpp b/src/libs/cplusplus/PPToken.cpp index 793dedb9b8..cb09c05406 100644 --- a/src/libs/cplusplus/PPToken.cpp +++ b/src/libs/cplusplus/PPToken.cpp @@ -32,6 +32,7 @@ #include <cstring> using namespace CPlusPlus; +using namespace CPlusPlus::Internal; bool ByteArrayRef::startsWith(const char *s) const { @@ -52,7 +53,7 @@ int ByteArrayRef::count(char ch) const return num; } -void Internal::PPToken::squeezeSource() +void PPToken::squeezeSource() { if (hasSource()) { m_src = m_src.mid(byteOffset, f.bytes); diff --git a/src/plugins/cppeditor/cppelementevaluator.cpp b/src/plugins/cppeditor/cppelementevaluator.cpp index 3d0275992d..aa9d37735a 100644 --- a/src/plugins/cppeditor/cppelementevaluator.cpp +++ b/src/plugins/cppeditor/cppelementevaluator.cpp @@ -44,7 +44,7 @@ #include <QQueue> using namespace CppEditor; -using namespace Internal; +using namespace CppEditor::Internal; using namespace CPlusPlus; namespace { diff --git a/src/plugins/cppeditor/cppincludehierarchy.cpp b/src/plugins/cppeditor/cppincludehierarchy.cpp index c19bd009f3..be5457736b 100644 --- a/src/plugins/cppeditor/cppincludehierarchy.cpp +++ b/src/plugins/cppeditor/cppincludehierarchy.cpp @@ -51,7 +51,7 @@ #include <QVBoxLayout> using namespace CppEditor; -using namespace Internal; +using namespace CppEditor::Internal; using namespace Utils; namespace CppEditor { diff --git a/src/plugins/cppeditor/cppsnippetprovider.cpp b/src/plugins/cppeditor/cppsnippetprovider.cpp index 646de352d8..c71c126762 100644 --- a/src/plugins/cppeditor/cppsnippetprovider.cpp +++ b/src/plugins/cppeditor/cppsnippetprovider.cpp @@ -41,7 +41,7 @@ #include <QCoreApplication> using namespace CppEditor; -using namespace Internal; +using namespace CppEditor::Internal; CppSnippetProvider::CppSnippetProvider() : TextEditor::ISnippetProvider() diff --git a/src/plugins/cppeditor/cpptypehierarchy.cpp b/src/plugins/cppeditor/cpptypehierarchy.cpp index 30c4878c55..dc1ff05915 100644 --- a/src/plugins/cppeditor/cpptypehierarchy.cpp +++ b/src/plugins/cppeditor/cpptypehierarchy.cpp @@ -46,7 +46,7 @@ #include <QVBoxLayout> using namespace CppEditor; -using namespace Internal; +using namespace CppEditor::Internal; using namespace Utils; namespace { diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index c3d4cdb44e..95b0421a4a 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -173,6 +173,54 @@ static void setupCdb(QString *, QProcessEnvironment *) {} #endif // Q_CC_MSVC +struct VersionBase +{ + // Minimum and maximum are inclusive. + VersionBase(int minimum = 0, int maximum = INT_MAX) + { + isRestricted = minimum != 0 || maximum != INT_MAX; + max = maximum; + min = minimum; + } + + bool covers(int what) const + { + return !isRestricted || (min <= what && what <= max); + } + + bool isRestricted; + int min; + int max; +}; + +struct QtVersion : VersionBase +{ + QtVersion(int minimum = 0, int maximum = INT_MAX) + : VersionBase(minimum, maximum) + {} +}; + +struct GccVersion : VersionBase +{ + GccVersion(int minimum = 0, int maximum = INT_MAX) + : VersionBase(minimum, maximum) + {} +}; + +struct GdbVersion : VersionBase +{ + GdbVersion(int minimum = 0, int maximum = INT_MAX) + : VersionBase(minimum, maximum) + {} +}; + +struct LldbVersion : VersionBase +{ + LldbVersion(int minimum = 0, int maximum = INT_MAX) + : VersionBase(minimum, maximum) + {} +}; + static QByteArray noValue = "\001"; static QString toHex(const QString &str) @@ -398,6 +446,8 @@ struct CheckBase { CheckBase() : enginesForCheck(AllEngines) {} mutable int enginesForCheck; + mutable VersionBase debuggerVersionForCheck; + mutable QtVersion qtVersionForCheck; }; struct Check : CheckBase @@ -415,9 +465,11 @@ struct Check : CheckBase expectedValue(value), expectedType(type), qtVersionMajor(0) {} - bool matchesEngine(DebuggerEngine engine) const + bool matches(DebuggerEngine engine, int debuggerVersion, int qtVersion) const { - return (engine & enginesForCheck); + return (engine & enginesForCheck) + && debuggerVersionForCheck.covers(debuggerVersion) + && qtVersionForCheck.covers(qtVersion); } const Check &operator%(DebuggerEngine engine) @@ -426,6 +478,13 @@ struct Check : CheckBase return *this; } + const Check &operator%(GdbVersion version) + { + enginesForCheck = GdbEngine; + debuggerVersionForCheck = version; + return *this; + } + QByteArray iname; Name expectedName; Value expectedValue; @@ -445,22 +504,25 @@ struct CheckType : public Check {} }; +const QtVersion Qt4 = QtVersion(0, 0x4ffff); +const QtVersion Qt5 = QtVersion(0x50000); + struct Check4 : Check { Check4(const QByteArray &iname, const Value &value, const Type &type) - : Check(iname, value, type) { qtVersionMajor = 4; } + : Check(iname, value, type) { qtVersionForCheck = Qt4; } Check4(const QByteArray &iname, const Name &name, const Value &value, const Type &type) - : Check(iname, name, value, type) { qtVersionMajor = 4; } + : Check(iname, name, value, type) { qtVersionForCheck = Qt4; } }; struct Check5 : Check { Check5(const QByteArray &iname, const Value &value, const Type &type) - : Check(iname, value, type) { qtVersionMajor = 5; } + : Check(iname, value, type) { qtVersionForCheck = Qt5; } Check5(const QByteArray &iname, const Name &name, const Value &value, const Type &type) - : Check(iname, name, value, type) { qtVersionMajor = 5; } + : Check(iname, name, value, type) { qtVersionForCheck = Qt5; } }; @@ -507,49 +569,6 @@ struct MacLibCppProfile : public Profile {} }; -struct VersionBase -{ - // Minimum and maximum are inclusive. - VersionBase(int minimum = 0, int maximum = INT_MAX) - { - isRestricted = minimum != 0 || maximum != INT_MAX; - max = maximum; - min = minimum; - } - - bool isRestricted; - int min; - int max; -}; - -struct QtVersion : VersionBase -{ - QtVersion(int minimum = 0, int maximum = INT_MAX) - : VersionBase(minimum, maximum) - {} -}; - -struct GccVersion : VersionBase -{ - GccVersion(int minimum = 0, int maximum = INT_MAX) - : VersionBase(minimum, maximum) - {} -}; - -struct GdbVersion : VersionBase -{ - GdbVersion(int minimum = 0, int maximum = INT_MAX) - : VersionBase(minimum, maximum) - {} -}; - -struct LldbVersion : VersionBase -{ - LldbVersion(int minimum = 0, int maximum = INT_MAX) - : VersionBase(minimum, maximum) - {} -}; - struct ForceC {}; struct EigenProfile {}; struct UseDebugImage {}; @@ -756,9 +775,8 @@ public: t = 0; m_keepTemp = true; m_forceKeepTemp = false; - m_gdbVersion = 0; + m_debuggerVersion = 0; m_gdbBuildVersion = 0; - m_lldbVersion = 0; m_qtVersion = 0; m_gccVersion = 0; m_isMacGdb = false; @@ -784,9 +802,8 @@ private: QString m_makeBinary; bool m_keepTemp; bool m_forceKeepTemp; - int m_gdbVersion; // 7.5.1 -> 70501 + int m_debuggerVersion; // GDB: 7.5.1 -> 70501 int m_gdbBuildVersion; - int m_lldbVersion; int m_qtVersion; // 5.2.0 -> 50200 int m_gccVersion; bool m_isMacGdb; @@ -848,7 +865,7 @@ void tst_Dumpers::initTestCase() QVERIFY(pos2 != -1); pos2 -= 4; version = version.mid(pos1, pos2 - pos1); - extractGdbVersion(version, &m_gdbVersion, + extractGdbVersion(version, &m_debuggerVersion, &m_gdbBuildVersion, &m_isMacGdb, &m_isQnxGdb); m_env = QProcessEnvironment::systemEnvironment(); m_makeBinary = QString::fromLocal8Bit(qgetenv("QTC_MAKE_PATH_FOR_TEST")); @@ -866,7 +883,7 @@ void tst_Dumpers::initTestCase() m_makeBinary = QLatin1String("make"); #endif qDebug() << "Make path : " << m_makeBinary; - qDebug() << "Gdb version : " << m_gdbVersion; + qDebug() << "Gdb version : " << m_debuggerVersion; } else if (m_debuggerEngine == CdbEngine) { setupCdb(&m_makeBinary, &m_env); } else if (m_debuggerEngine == LldbEngine) { @@ -884,19 +901,19 @@ void tst_Dumpers::initTestCase() int pos = ba.indexOf('.'); if (pos >= 0) ba = ba.left(pos); - m_lldbVersion = ba.toInt(); - if (!m_lldbVersion) { + m_debuggerVersion = ba.toInt(); + if (!m_debuggerVersion) { if (output.startsWith("lldb version")) { int pos1 = output.indexOf('.', 13); int major = output.mid(13, pos1++ - 13).toInt(); int pos2 = output.indexOf(' ', pos1); int minor = output.mid(pos1, pos2++ - pos1).toInt(); - m_lldbVersion = 100 * major + 10 * minor; + m_debuggerVersion = 100 * major + 10 * minor; } } - qDebug() << "Lldb version :" << output << ba << m_lldbVersion; - QVERIFY(m_lldbVersion); + qDebug() << "Lldb version :" << output << ba << m_debuggerVersion; + QVERIFY(m_debuggerVersion); m_env = QProcessEnvironment::systemEnvironment(); m_makeBinary = QLatin1String("make"); @@ -926,19 +943,19 @@ void tst_Dumpers::dumper() MSKIP_SINGLE("The test is excluded for this debugger engine."); if (data.neededGdbVersion.isRestricted && m_debuggerEngine == GdbEngine) { - if (data.neededGdbVersion.min > m_gdbVersion) + if (data.neededGdbVersion.min > m_debuggerVersion) MSKIP_SINGLE("Need minimum GDB version " + QByteArray::number(data.neededGdbVersion.min)); - if (data.neededGdbVersion.max < m_gdbVersion) + if (data.neededGdbVersion.max < m_debuggerVersion) MSKIP_SINGLE("Need maximum GDB version " + QByteArray::number(data.neededGdbVersion.max)); } if (data.neededLldbVersion.isRestricted && m_debuggerEngine == LldbEngine) { - if (data.neededLldbVersion.min > m_lldbVersion) + if (data.neededLldbVersion.min > m_debuggerVersion) MSKIP_SINGLE("Need minimum LLDB version " + QByteArray::number(data.neededLldbVersion.min)); - if (data.neededLldbVersion.max < m_lldbVersion) + if (data.neededLldbVersion.max < m_debuggerVersion) MSKIP_SINGLE("Need maximum LLDB version " + QByteArray::number(data.neededLldbVersion.max)); } @@ -1024,7 +1041,7 @@ void tst_Dumpers::dumper() proFile.write("CONFIG -= QT\n"); if (m_useGLibCxxDebug) proFile.write("DEFINES += _GLIBCXX_DEBUG\n"); - if (m_gdbVersion < 70500) + if (m_debuggerEngine == GdbEngine && m_debuggerVersion < 70500) proFile.write("QMAKE_CXXFLAGS += -gdwarf-3\n"); proFile.write(data.profileExtra); proFile.close(); @@ -1292,13 +1309,7 @@ void tst_Dumpers::dumper() //qDebug() << "CHECKS" << i << check.iname; if ("local." + check.iname == item.iname) { data.checks.removeAt(i); - if (context.qtVersion) { - if (check.qtVersionMajor == 5 && context.qtVersion < 0x050000) - continue; - if (check.qtVersionMajor == 4 && context.qtVersion >= 0x050000) - continue; - } - if (check.matchesEngine(m_debuggerEngine)) { + if (check.matches(m_debuggerEngine, m_debuggerVersion, context.qtVersion)) { //qDebug() << "USING MATCHING TEST FOR " << item.iname; if (!check.expectedName.matches(item.name.toLatin1(), context)) { qDebug() << "INAME : " << item.iname; @@ -1329,7 +1340,7 @@ void tst_Dumpers::dumper() if (!data.checks.isEmpty()) { for (int i = data.checks.size(); --i >= 0; ) { Check check = data.checks.at(i); - if (!check.matchesEngine(m_debuggerEngine)) + if (!check.matches(m_debuggerEngine, m_debuggerVersion, context.qtVersion)) data.checks.removeAt(i); } } @@ -4361,6 +4372,7 @@ GdbEngine // } + const FloatValue ff("5.88545355e-44"); QTest::newRow("AnonymousStruct") << Data("union {\n" " struct { int i; int b; };\n" @@ -4370,13 +4382,17 @@ GdbEngine + Check("a.d", FloatValue("9.1245819032257467e-313"), "double") - + Check("a.b", "43", "int") % GdbEngine - + Check("a.i", "42", "int") % GdbEngine - + Check("a.f", FloatValue("5.88545355e-44"), "float") % GdbEngine + + Check("a.b", "43", "int") % GdbVersion(0, 70699) + + Check("a.i", "42", "int") % GdbVersion(0, 70699) + + Check("a.f", ff, "float") % GdbVersion(0, 70699) + + + Check("a.0.b", "43", "int") % GdbVersion(70700) + + Check("a.0.i", "42", "int") % GdbVersion(70700) + + Check("a.1.f", ff, "float") % GdbVersion(70700) + Check("a.#1.b", "43", "int") % LldbEngine + Check("a.#1.i", "42", "int") % LldbEngine - + Check("a.#2.f", FloatValue("5.88545355e-44"), "float") % LldbEngine; + + Check("a.#2.f", ff, "float") % LldbEngine; QTest::newRow("CharArrays") @@ -5478,29 +5494,32 @@ GdbEngine // on -var-list-children on an anonymous union. mac/MI was fixed in 2006"); // The proposed fix has been reported to crash gdb steered from eclipse"); // http://sourceware.org/ml/gdb-patches/2011-12/msg00420.html - QTest::newRow("Gdb10586mi") + QTest::newRow("Gdb10586") << Data("struct Test {\n" " struct { int a; float b; };\n" " struct { int c; float d; };\n" "} v = {{1, 2}, {3, 4}};\n" "unused(&v);\n") - + Check("v", "", "Test") - + Check("v.a", "1", "int") % GdbEngine + + Check("v.a", "1", "int") % GdbVersion(0, 70699) + + Check("v.0.a", "1", "int") % GdbVersion(70700) + Check("v.#1.a", "1", "int") % LldbEngine; QTest::newRow("Gdb10586eclipse") - << Data("struct { int x; struct { int a; }; struct { int b; }; } v = {1, {2}, {3}};\n" + << Data("struct { int x; struct { int a; }; struct { int b; }; } " + " v = {1, {2}, {3}};\n" "struct S { int x, y; } n = {10, 20};\n" "unused(&v, &n);\n") + Check("v", "", "{...}") % GdbEngine + Check("v", "", Pattern("<anonymous .*>")) % LldbEngine + Check("n", "", "S") - + Check("v.a", "2", "int") % GdbEngine + + Check("v.a", "2", "int") % GdbVersion(0, 70699) + + Check("v.0.a", "2", "int") % GdbVersion(70700) + Check("v.#1.a", "2", "int") % LldbEngine - + Check("v.b", "3", "int") % GdbEngine + + Check("v.b", "3", "int") % GdbVersion(0, 70699) + + Check("v.1.b", "3", "int") % GdbVersion(70700) + Check("v.#2.b", "3", "int") % LldbEngine + Check("v.x", "1", "int") + Check("n.x", "10", "int") |