diff options
author | Tobias Hunger <tobias.hunger@digia.com> | 2013-10-22 17:23:34 +0200 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2013-10-22 19:03:47 +0200 |
commit | eb944974ac97e709f08a39e9694d2934727568c4 (patch) | |
tree | b7c632a80c30e4492c07f6603157b0427d1dca5a /src | |
parent | 04ea1898b55b8c95c924f64a827cac5a117303b2 (diff) | |
download | qt-creator-eb944974ac97e709f08a39e9694d2934727568c4.tar.gz |
Debugger: Have 64bit debuggers handle 32bit targets, too
Prefer 32bit debuggers if possible though. In the setup Robert
used there is only a 64bit CDB and thus the debugger of his
64bit Qt was unset.
Add unit tests to make sure changes will not effect currently
working setups.
Task-number: QTCREATORBUG-10463
Change-Id: I4afae314bc75d4465dbc8de5b2a4267a521a4ea1
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/debugger/debuggerkitinformation.cpp | 115 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerplugin.h | 3 |
2 files changed, 114 insertions, 4 deletions
diff --git a/src/plugins/debugger/debuggerkitinformation.cpp b/src/plugins/debugger/debuggerkitinformation.cpp index fc01bf2e6a..667e61b07d 100644 --- a/src/plugins/debugger/debuggerkitinformation.cpp +++ b/src/plugins/debugger/debuggerkitinformation.cpp @@ -199,17 +199,18 @@ static DebuggerItem::MatchLevel matchSingle(const Abi &debuggerAbi, const Abi &t && debuggerAbi.binaryFormat() != targetAbi.binaryFormat()) return DebuggerItem::DoesNotMatch; - if (debuggerAbi.wordWidth() != 0 && debuggerAbi.wordWidth() != targetAbi.wordWidth()) - return DebuggerItem::DoesNotMatch; - if (debuggerAbi.os() == Abi::WindowsOS) { if (debuggerAbi.osFlavor() == Abi::WindowsMSysFlavor && targetAbi.osFlavor() != Abi::WindowsMSysFlavor) return DebuggerItem::DoesNotMatch; if (debuggerAbi.osFlavor() != Abi::WindowsMSysFlavor && targetAbi.osFlavor() == Abi::WindowsMSysFlavor) return DebuggerItem::DoesNotMatch; - return DebuggerItem::MatchesSomewhat; } + if (debuggerAbi.wordWidth() == 64 and targetAbi.wordWidth() == 32) + return DebuggerItem::MatchesSomewhat; + if (debuggerAbi.wordWidth() != 0 && debuggerAbi.wordWidth() != targetAbi.wordWidth()) + return DebuggerItem::DoesNotMatch; + return DebuggerItem::MatchesPerfectly; } @@ -230,3 +231,109 @@ bool Debugger::DebuggerItem::isValid() const } } // namespace Debugger; + +#ifdef WITH_TESTS + +# include <QTest> +# include "debuggerplugin.h" + +void Debugger::DebuggerPlugin::testDebuggerMatching_data() +{ + QTest::addColumn<QStringList>("debugger"); + QTest::addColumn<QString>("target"); + QTest::addColumn<int>("result"); + + QTest::newRow("Invalid data") + << QStringList() + << QString() + << int(DebuggerItem::DoesNotMatch); + QTest::newRow("Invalid debugger") + << QStringList() + << QString::fromLatin1("x86-linux-generic-elf-32bit") + << int(DebuggerItem::DoesNotMatch); + QTest::newRow("Invalid target") + << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit")) + << QString() + << int(DebuggerItem::DoesNotMatch); + + QTest::newRow("Fuzzy match 1") + << (QStringList() << QLatin1String("unknown-unknown-unknown-unknown-0bit")) + << QString::fromLatin1("x86-linux-generic-elf-32bit") + << int(DebuggerItem::MatchesPerfectly); // Is this the expected behavior? + QTest::newRow("Fuzzy match 2") + << (QStringList() << QLatin1String("unknown-unknown-unknown-unknown-0bit")) + << QString::fromLatin1("arm-windows-msys-pe-64bit") + << int(DebuggerItem::MatchesPerfectly); // Is this the expected behavior? + + QTest::newRow("Architecture mismatch") + << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit")) + << QString::fromLatin1("arm-linux-generic-elf-32bit") + << int(DebuggerItem::DoesNotMatch); + QTest::newRow("OS mismatch") + << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit")) + << QString::fromLatin1("x86-macosx-generic-elf-32bit") + << int(DebuggerItem::DoesNotMatch); + QTest::newRow("Format mismatch") + << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit")) + << QString::fromLatin1("x86-linux-generic-pe-32bit") + << int(DebuggerItem::DoesNotMatch); + + QTest::newRow("Linux perfect match") + << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit")) + << QString::fromLatin1("x86-linux-generic-elf-32bit") + << int(DebuggerItem::MatchesPerfectly); + QTest::newRow("Linux match") + << (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")) + << QString::fromLatin1("x86-linux-generic-elf-32bit") + << int(DebuggerItem::MatchesSomewhat); + + QTest::newRow("Windows perfect match 1") + << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-64bit")) + << QString::fromLatin1("x86-windows-msvc2013-pe-64bit") + << int(DebuggerItem::MatchesPerfectly); + QTest::newRow("Windows perfect match 2") + << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-64bit")) + << QString::fromLatin1("x86-windows-msvc2012-pe-64bit") + << int(DebuggerItem::MatchesPerfectly); + QTest::newRow("Windows match 1") + << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-64bit")) + << QString::fromLatin1("x86-windows-msvc2013-pe-32bit") + << int(DebuggerItem::MatchesSomewhat); + QTest::newRow("Windows match 2") + << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-64bit")) + << QString::fromLatin1("x86-windows-msvc2012-pe-32bit") + << int(DebuggerItem::MatchesSomewhat); + QTest::newRow("Windows mismatch on word size") + << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-32bit")) + << QString::fromLatin1("x86-windows-msvc2013-pe-64bit") + << int(DebuggerItem::DoesNotMatch); + QTest::newRow("Windows mismatch on osflavor 1") + << (QStringList() << QLatin1String("x86-windows-msvc2013-pe-32bit")) + << QString::fromLatin1("x86-windows-msys-pe-64bit") + << int(DebuggerItem::DoesNotMatch); + QTest::newRow("Windows mismatch on osflavor 2") + << (QStringList() << QLatin1String("x86-windows-msys-pe-32bit")) + << QString::fromLatin1("x86-windows-msvc2010-pe-64bit") + << int(DebuggerItem::DoesNotMatch); +} + +void Debugger::DebuggerPlugin::testDebuggerMatching() +{ + QFETCH(QStringList, debugger); + QFETCH(QString, target); + QFETCH(int, result); + + DebuggerItem::MatchLevel expectedLevel = static_cast<DebuggerItem::MatchLevel>(result); + + QList<Abi> debuggerAbis; + foreach (const QString &abi, debugger) + debuggerAbis << Abi(abi); + + DebuggerItem item; + item.setAbis(debuggerAbis); + + DebuggerItem::MatchLevel level = item.matchTarget(Abi(target)); + + QCOMPARE(expectedLevel, level); +} +#endif diff --git a/src/plugins/debugger/debuggerplugin.h b/src/plugins/debugger/debuggerplugin.h index c0f6429742..32790efd4f 100644 --- a/src/plugins/debugger/debuggerplugin.h +++ b/src/plugins/debugger/debuggerplugin.h @@ -76,6 +76,9 @@ private: #ifdef WITH_TESTS private slots: + void testDebuggerMatching_data(); + void testDebuggerMatching(); + void testBenchmark(); // void testStateMachine(); #endif |