2013-10-25 13:47:08 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2013-10-25 13:47:08 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2013-10-25 13:47:08 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2013-10-25 13:47:08 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2013-10-25 13:47:08 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2015-02-26 15:29:28 +01:00
|
|
|
#include "debuggeritem.h"
|
2013-10-25 13:47:08 +02:00
|
|
|
#include "debuggerkitinformation.h"
|
|
|
|
|
#include "debuggerkitconfigwidget.h"
|
|
|
|
|
#include "debuggeroptionspage.h"
|
2014-06-23 17:59:27 +02:00
|
|
|
#include "debuggerprotocol.h"
|
2013-10-25 13:47:08 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/abi.h>
|
|
|
|
|
#include <utils/fileutils.h>
|
2014-07-29 14:19:40 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2013-11-06 16:10:24 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2013-10-25 13:47:08 +02:00
|
|
|
|
|
|
|
|
#include <QProcess>
|
|
|
|
|
#include <QUuid>
|
|
|
|
|
|
2014-10-17 13:40:04 +02:00
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
# include <QTest>
|
|
|
|
|
# include "debuggerplugin.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-10-25 13:47:08 +02:00
|
|
|
using namespace Debugger::Internal;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
2014-10-17 13:40:04 +02:00
|
|
|
const char DEBUGGER_INFORMATION_COMMAND[] = "Binary";
|
|
|
|
|
const char DEBUGGER_INFORMATION_DISPLAYNAME[] = "DisplayName";
|
|
|
|
|
const char DEBUGGER_INFORMATION_ID[] = "Id";
|
|
|
|
|
const char DEBUGGER_INFORMATION_ENGINETYPE[] = "EngineType";
|
|
|
|
|
const char DEBUGGER_INFORMATION_AUTODETECTED[] = "AutoDetected";
|
|
|
|
|
const char DEBUGGER_INFORMATION_AUTODETECTION_SOURCE[] = "AutoDetectionSource";
|
|
|
|
|
const char DEBUGGER_INFORMATION_VERSION[] = "Version";
|
|
|
|
|
const char DEBUGGER_INFORMATION_ABIS[] = "Abis";
|
2013-10-25 13:47:08 +02:00
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// DebuggerItem
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
DebuggerItem::DebuggerItem()
|
|
|
|
|
{
|
|
|
|
|
m_engineType = NoEngineType;
|
|
|
|
|
m_isAutoDetected = false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-28 17:47:37 +01:00
|
|
|
DebuggerItem::DebuggerItem(const QVariant &id)
|
|
|
|
|
{
|
|
|
|
|
m_id = id;
|
|
|
|
|
m_engineType = NoEngineType;
|
|
|
|
|
m_isAutoDetected = false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-25 13:47:08 +02:00
|
|
|
DebuggerItem::DebuggerItem(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
m_command = FileName::fromUserInput(data.value(QLatin1String(DEBUGGER_INFORMATION_COMMAND)).toString());
|
|
|
|
|
m_id = data.value(QLatin1String(DEBUGGER_INFORMATION_ID)).toString();
|
|
|
|
|
m_displayName = data.value(QLatin1String(DEBUGGER_INFORMATION_DISPLAYNAME)).toString();
|
|
|
|
|
m_isAutoDetected = data.value(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTED), false).toBool();
|
2013-12-03 17:25:38 +01:00
|
|
|
m_autoDetectionSource = data.value(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTION_SOURCE)).toString();
|
2014-06-23 17:59:27 +02:00
|
|
|
m_version = data.value(QLatin1String(DEBUGGER_INFORMATION_VERSION)).toString();
|
2013-10-25 13:47:08 +02:00
|
|
|
m_engineType = DebuggerEngineType(data.value(QLatin1String(DEBUGGER_INFORMATION_ENGINETYPE),
|
|
|
|
|
static_cast<int>(NoEngineType)).toInt());
|
|
|
|
|
|
|
|
|
|
foreach (const QString &a, data.value(QLatin1String(DEBUGGER_INFORMATION_ABIS)).toStringList()) {
|
|
|
|
|
Abi abi(a);
|
2013-11-14 15:52:57 +01:00
|
|
|
if (!abi.isNull())
|
2013-10-25 13:47:08 +02:00
|
|
|
m_abis.append(abi);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-06 16:10:24 +01:00
|
|
|
void DebuggerItem::createId()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(!m_id.isValid(), return);
|
|
|
|
|
m_id = QUuid::createUuid().toString();
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-25 13:47:08 +02:00
|
|
|
void DebuggerItem::reinitializeFromFile()
|
|
|
|
|
{
|
|
|
|
|
QProcess proc;
|
|
|
|
|
proc.start(m_command.toString(), QStringList() << QLatin1String("--version"));
|
2013-10-25 10:44:11 +02:00
|
|
|
if (!proc.waitForStarted() || !proc.waitForFinished()) {
|
|
|
|
|
m_engineType = NoEngineType;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-11-12 16:18:31 +01:00
|
|
|
m_abis.clear();
|
2013-10-25 13:47:08 +02:00
|
|
|
QByteArray ba = proc.readAll();
|
|
|
|
|
if (ba.contains("gdb")) {
|
|
|
|
|
m_engineType = GdbEngineType;
|
|
|
|
|
const char needle[] = "This GDB was configured as \"";
|
|
|
|
|
// E.g. "--host=i686-pc-linux-gnu --target=arm-unknown-nto-qnx6.5.0".
|
|
|
|
|
// or "i686-linux-gnu"
|
|
|
|
|
int pos1 = ba.indexOf(needle);
|
|
|
|
|
if (pos1 != -1) {
|
2014-09-09 13:24:58 +02:00
|
|
|
pos1 += int(strlen(needle));
|
2013-10-25 13:47:08 +02:00
|
|
|
int pos2 = ba.indexOf('"', pos1 + 1);
|
|
|
|
|
QByteArray target = ba.mid(pos1, pos2 - pos1);
|
|
|
|
|
int pos3 = target.indexOf("--target=");
|
|
|
|
|
if (pos3 >= 0)
|
|
|
|
|
target = target.mid(pos3 + 9);
|
|
|
|
|
m_abis.append(Abi::abiFromTargetTriplet(QString::fromLatin1(target)));
|
|
|
|
|
} else {
|
|
|
|
|
// Fallback.
|
|
|
|
|
m_abis = Abi::abisOfBinary(m_command); // FIXME: Wrong.
|
|
|
|
|
}
|
2014-06-23 17:59:27 +02:00
|
|
|
|
|
|
|
|
// Version
|
|
|
|
|
QString all = QString::fromUtf8(ba);
|
|
|
|
|
bool isMacGdb, isQnxGdb;
|
|
|
|
|
int version = 0, buildVersion = 0;
|
|
|
|
|
Debugger::Internal::extractGdbVersion(all,
|
|
|
|
|
&version, &buildVersion, &isMacGdb, &isQnxGdb);
|
|
|
|
|
if (version)
|
|
|
|
|
m_version = QString::fromLatin1("%1.%2.%3")
|
|
|
|
|
.arg(version / 10000).arg((version / 100) % 100).arg(version % 100);
|
2013-10-25 13:47:08 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2015-01-15 15:02:51 +01:00
|
|
|
if (ba.startsWith("lldb") || ba.startsWith("LLDB")) {
|
2013-10-25 13:47:08 +02:00
|
|
|
m_engineType = LldbEngineType;
|
|
|
|
|
m_abis = Abi::abisOfBinary(m_command);
|
2015-01-15 15:02:51 +01:00
|
|
|
|
|
|
|
|
// Version
|
|
|
|
|
if (ba.startsWith(("lldb version "))) { // Linux typically.
|
2015-02-19 16:44:58 +01:00
|
|
|
int pos1 = int(strlen("lldb version "));
|
2015-01-15 15:02:51 +01:00
|
|
|
int pos2 = ba.indexOf(' ', pos1);
|
|
|
|
|
m_version = QString::fromLatin1(ba.mid(pos1, pos2 - pos1));
|
|
|
|
|
} else if (ba.startsWith("lldb-") || ba.startsWith("LLDB-")) { // Mac typically.
|
|
|
|
|
m_version = QString::fromLatin1(ba.mid(5));
|
|
|
|
|
}
|
2013-10-25 13:47:08 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (ba.startsWith("Python")) {
|
|
|
|
|
m_engineType = PdbEngineType;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-10-25 10:44:11 +02:00
|
|
|
if (ba.isEmpty()) {
|
|
|
|
|
proc.start(m_command.toString(), QStringList() << QLatin1String("-version"));
|
|
|
|
|
if (!proc.waitForStarted() || !proc.waitForFinished()) {
|
|
|
|
|
m_engineType = NoEngineType;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ba = proc.readAll();
|
|
|
|
|
if (ba.startsWith("cdb")) {
|
|
|
|
|
m_engineType = CdbEngineType;
|
|
|
|
|
m_abis = Abi::abisOfBinary(m_command);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-10-25 13:47:08 +02:00
|
|
|
m_engineType = NoEngineType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString DebuggerItem::engineTypeName() const
|
|
|
|
|
{
|
|
|
|
|
switch (m_engineType) {
|
2014-10-17 13:40:04 +02:00
|
|
|
case NoEngineType:
|
2013-10-25 13:47:08 +02:00
|
|
|
return DebuggerOptionsPage::tr("Not recognized");
|
2014-10-17 13:40:04 +02:00
|
|
|
case GdbEngineType:
|
2013-10-25 13:47:08 +02:00
|
|
|
return QLatin1String("GDB");
|
2014-10-17 13:40:04 +02:00
|
|
|
case CdbEngineType:
|
2013-10-25 13:47:08 +02:00
|
|
|
return QLatin1String("CDB");
|
2014-10-17 13:40:04 +02:00
|
|
|
case LldbEngineType:
|
2013-10-25 13:47:08 +02:00
|
|
|
return QLatin1String("LLDB");
|
|
|
|
|
default:
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList DebuggerItem::abiNames() const
|
|
|
|
|
{
|
|
|
|
|
QStringList list;
|
|
|
|
|
foreach (const Abi &abi, m_abis)
|
|
|
|
|
list.append(abi.toString());
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-28 12:51:35 +01:00
|
|
|
bool DebuggerItem::operator==(const DebuggerItem &other) const
|
|
|
|
|
{
|
|
|
|
|
return m_id == other.m_id
|
2013-10-28 17:47:37 +01:00
|
|
|
&& m_displayName == other.m_displayName
|
2013-10-28 12:51:35 +01:00
|
|
|
&& m_isAutoDetected == other.m_isAutoDetected
|
2013-10-28 17:47:37 +01:00
|
|
|
&& m_command == other.m_command;
|
2013-10-28 12:51:35 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-25 13:47:08 +02:00
|
|
|
QVariantMap DebuggerItem::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap data;
|
|
|
|
|
data.insert(QLatin1String(DEBUGGER_INFORMATION_DISPLAYNAME), m_displayName);
|
|
|
|
|
data.insert(QLatin1String(DEBUGGER_INFORMATION_ID), m_id);
|
2014-07-02 16:54:53 +03:00
|
|
|
data.insert(QLatin1String(DEBUGGER_INFORMATION_COMMAND), m_command.toString());
|
2013-10-25 13:47:08 +02:00
|
|
|
data.insert(QLatin1String(DEBUGGER_INFORMATION_ENGINETYPE), int(m_engineType));
|
|
|
|
|
data.insert(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTED), m_isAutoDetected);
|
2013-12-03 17:25:38 +01:00
|
|
|
data.insert(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTION_SOURCE), m_autoDetectionSource);
|
2014-06-23 17:59:27 +02:00
|
|
|
data.insert(QLatin1String(DEBUGGER_INFORMATION_VERSION), m_version);
|
2013-10-25 13:47:08 +02:00
|
|
|
data.insert(QLatin1String(DEBUGGER_INFORMATION_ABIS), abiNames());
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerItem::setDisplayName(const QString &displayName)
|
|
|
|
|
{
|
|
|
|
|
m_displayName = displayName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerItem::setEngineType(const DebuggerEngineType &engineType)
|
|
|
|
|
{
|
|
|
|
|
m_engineType = engineType;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:58:49 +02:00
|
|
|
void DebuggerItem::setCommand(const FileName &command)
|
2013-10-25 13:47:08 +02:00
|
|
|
{
|
|
|
|
|
m_command = command;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerItem::setAutoDetected(bool isAutoDetected)
|
|
|
|
|
{
|
|
|
|
|
m_isAutoDetected = isAutoDetected;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-23 17:59:27 +02:00
|
|
|
QString DebuggerItem::version() const
|
|
|
|
|
{
|
|
|
|
|
return m_version;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerItem::setVersion(const QString &version)
|
|
|
|
|
{
|
|
|
|
|
m_version = version;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-03 17:25:38 +01:00
|
|
|
void DebuggerItem::setAutoDetectionSource(const QString &autoDetectionSource)
|
|
|
|
|
{
|
|
|
|
|
m_autoDetectionSource = autoDetectionSource;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:58:49 +02:00
|
|
|
void DebuggerItem::setAbis(const QList<Abi> &abis)
|
2013-10-25 13:47:08 +02:00
|
|
|
{
|
|
|
|
|
m_abis = abis;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerItem::setAbi(const Abi &abi)
|
|
|
|
|
{
|
|
|
|
|
m_abis.clear();
|
|
|
|
|
m_abis.append(abi);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 14:19:40 +02:00
|
|
|
static DebuggerItem::MatchLevel matchSingle(const Abi &debuggerAbi, const Abi &targetAbi, DebuggerEngineType engineType)
|
2013-10-25 13:47:08 +02:00
|
|
|
{
|
|
|
|
|
if (debuggerAbi.architecture() != Abi::UnknownArchitecture
|
|
|
|
|
&& debuggerAbi.architecture() != targetAbi.architecture())
|
|
|
|
|
return DebuggerItem::DoesNotMatch;
|
|
|
|
|
|
|
|
|
|
if (debuggerAbi.os() != Abi::UnknownOS
|
|
|
|
|
&& debuggerAbi.os() != targetAbi.os())
|
|
|
|
|
return DebuggerItem::DoesNotMatch;
|
|
|
|
|
|
|
|
|
|
if (debuggerAbi.binaryFormat() != Abi::UnknownFormat
|
|
|
|
|
&& debuggerAbi.binaryFormat() != targetAbi.binaryFormat())
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (debuggerAbi.wordWidth() == 64 && targetAbi.wordWidth() == 32)
|
|
|
|
|
return DebuggerItem::MatchesSomewhat;
|
|
|
|
|
if (debuggerAbi.wordWidth() != 0 && debuggerAbi.wordWidth() != targetAbi.wordWidth())
|
|
|
|
|
return DebuggerItem::DoesNotMatch;
|
|
|
|
|
|
2014-07-29 14:19:40 +02:00
|
|
|
// We have at least 'Matches well' now. Mark the combinations we really like.
|
2014-07-30 21:55:18 +03:00
|
|
|
if (HostOsInfo::isWindowsHost() && engineType == GdbEngineType && targetAbi.osFlavor() == Abi::WindowsMSysFlavor)
|
2014-07-29 14:19:40 +02:00
|
|
|
return DebuggerItem::MatchesPerfectly;
|
|
|
|
|
if (HostOsInfo::isLinuxHost() && engineType == GdbEngineType && targetAbi.os() == Abi::LinuxOS)
|
|
|
|
|
return DebuggerItem::MatchesPerfectly;
|
|
|
|
|
if (HostOsInfo::isMacHost() && engineType == LldbEngineType && targetAbi.os() == Abi::MacOS)
|
|
|
|
|
return DebuggerItem::MatchesPerfectly;
|
|
|
|
|
|
|
|
|
|
return DebuggerItem::MatchesWell;
|
2013-10-25 13:47:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DebuggerItem::MatchLevel DebuggerItem::matchTarget(const Abi &targetAbi) const
|
|
|
|
|
{
|
|
|
|
|
MatchLevel bestMatch = DoesNotMatch;
|
|
|
|
|
foreach (const Abi &debuggerAbi, m_abis) {
|
2014-07-29 14:19:40 +02:00
|
|
|
MatchLevel currentMatch = matchSingle(debuggerAbi, targetAbi, m_engineType);
|
2013-10-25 13:47:08 +02:00
|
|
|
if (currentMatch > bestMatch)
|
|
|
|
|
bestMatch = currentMatch;
|
|
|
|
|
}
|
|
|
|
|
return bestMatch;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-17 13:40:04 +02:00
|
|
|
bool DebuggerItem::isValid() const
|
2013-10-25 13:47:08 +02:00
|
|
|
{
|
2013-10-28 17:47:37 +01:00
|
|
|
return !m_id.isNull();
|
2013-10-25 13:47:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
|
2014-10-17 13:40:04 +02:00
|
|
|
namespace Internal {
|
2013-10-25 13:47:08 +02:00
|
|
|
|
2014-10-17 13:40:04 +02:00
|
|
|
void DebuggerPlugin::testDebuggerMatching_data()
|
2013-10-25 13:47:08 +02:00
|
|
|
{
|
|
|
|
|
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")
|
2014-07-29 14:19:40 +02:00
|
|
|
<< int(DebuggerItem::MatchesWell); // Is this the expected behavior?
|
2013-10-25 13:47:08 +02:00
|
|
|
QTest::newRow("Fuzzy match 2")
|
|
|
|
|
<< (QStringList() << QLatin1String("unknown-unknown-unknown-unknown-0bit"))
|
|
|
|
|
<< QString::fromLatin1("arm-windows-msys-pe-64bit")
|
2014-07-29 14:19:40 +02:00
|
|
|
<< int(DebuggerItem::MatchesWell); // Is this the expected behavior?
|
2013-10-25 13:47:08 +02:00
|
|
|
|
|
|
|
|
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")
|
2014-07-29 14:19:40 +02:00
|
|
|
<< int(DebuggerItem::MatchesWell);
|
2013-10-25 13:47:08 +02:00
|
|
|
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")
|
2014-07-29 14:19:40 +02:00
|
|
|
<< int(DebuggerItem::MatchesWell);
|
2013-10-25 13:47:08 +02:00
|
|
|
QTest::newRow("Windows perfect match 2")
|
|
|
|
|
<< (QStringList() << QLatin1String("x86-windows-msvc2013-pe-64bit"))
|
|
|
|
|
<< QString::fromLatin1("x86-windows-msvc2012-pe-64bit")
|
2014-07-29 14:19:40 +02:00
|
|
|
<< int(DebuggerItem::MatchesWell);
|
2013-10-25 13:47:08 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-17 13:40:04 +02:00
|
|
|
void DebuggerPlugin::testDebuggerMatching()
|
2013-10-25 13:47:08 +02:00
|
|
|
{
|
|
|
|
|
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));
|
2014-07-29 14:19:40 +02:00
|
|
|
if (level == DebuggerItem::MatchesPerfectly)
|
|
|
|
|
level = DebuggerItem::MatchesWell;
|
2013-10-25 13:47:08 +02:00
|
|
|
|
|
|
|
|
QCOMPARE(expectedLevel, level);
|
|
|
|
|
}
|
2014-10-17 13:40:04 +02:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
|
2013-10-25 13:47:08 +02:00
|
|
|
#endif
|
2014-10-17 13:40:04 +02:00
|
|
|
|
|
|
|
|
} // namespace Debugger;
|