2013-10-25 13:47:08 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2013-10-25 13:47:08 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2013-10-25 13:47:08 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2015-02-26 15:29:28 +01:00
|
|
|
#include "debuggeritem.h"
|
2016-11-28 18:47:18 +01:00
|
|
|
#include "debuggeritemmanager.h"
|
2013-10-25 13:47:08 +02:00
|
|
|
#include "debuggerkitinformation.h"
|
|
|
|
|
#include "debuggerkitconfigwidget.h"
|
2014-06-23 17:59:27 +02:00
|
|
|
#include "debuggerprotocol.h"
|
2013-10-25 13:47:08 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/abi.h>
|
2015-03-03 16:49:59 +01:00
|
|
|
|
2013-10-25 13:47:08 +02:00
|
|
|
#include <utils/fileutils.h>
|
2014-07-29 14:19:40 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2015-03-03 16:49:59 +01:00
|
|
|
#include <utils/macroexpander.h>
|
2013-11-06 16:10:24 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2016-04-29 16:52:58 +02:00
|
|
|
#include <utils/synchronousprocess.h>
|
2016-08-03 17:55:54 +02:00
|
|
|
#include <utils/utilsicons.h>
|
2013-10-25 13:47:08 +02:00
|
|
|
|
2015-09-28 09:12:07 +02:00
|
|
|
#include <QFileInfo>
|
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";
|
2016-03-06 23:26:01 +02:00
|
|
|
const char DEBUGGER_INFORMATION_LASTMODIFIED[] = "LastModified";
|
2016-07-29 15:55:15 +02:00
|
|
|
const char DEBUGGER_INFORMATION_WORKINGDIRECTORY[] = "WorkingDirectory";
|
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_id = data.value(QLatin1String(DEBUGGER_INFORMATION_ID)).toString();
|
2016-07-29 15:55:15 +02:00
|
|
|
m_command = FileName::fromUserInput(data.value(QLatin1String(DEBUGGER_INFORMATION_COMMAND)).toString());
|
|
|
|
|
m_workingDirectory = FileName::fromUserInput(data.value(DEBUGGER_INFORMATION_WORKINGDIRECTORY).toString());
|
2015-03-03 16:49:59 +01:00
|
|
|
m_unexpandedDisplayName = data.value(QLatin1String(DEBUGGER_INFORMATION_DISPLAYNAME)).toString();
|
2013-10-25 13:47:08 +02:00
|
|
|
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());
|
2016-03-06 23:26:01 +02:00
|
|
|
m_lastModified = data.value(QLatin1String(DEBUGGER_INFORMATION_LASTMODIFIED)).toDateTime();
|
2013-10-25 13:47:08 +02:00
|
|
|
|
|
|
|
|
foreach (const QString &a, data.value(QLatin1String(DEBUGGER_INFORMATION_ABIS)).toStringList()) {
|
2018-06-14 15:46:33 +02:00
|
|
|
Abi abi = Abi::fromString(a);
|
2013-11-14 15:52:57 +01:00
|
|
|
if (!abi.isNull())
|
2013-10-25 13:47:08 +02:00
|
|
|
m_abis.append(abi);
|
|
|
|
|
}
|
2015-03-03 16:49:59 +01:00
|
|
|
|
2016-12-16 14:02:26 -05:00
|
|
|
bool mightBeAPreQnxSeparateOSQnxDebugger = m_command.fileName().startsWith("nto")
|
|
|
|
|
&& m_abis.count() == 1
|
|
|
|
|
&& m_abis[0].os() == Abi::UnknownOS
|
|
|
|
|
&& m_abis[0].osFlavor() == Abi::UnknownFlavor
|
|
|
|
|
&& m_abis[0].binaryFormat() == Abi::UnknownFormat;
|
|
|
|
|
|
|
|
|
|
if (m_version.isEmpty() || mightBeAPreQnxSeparateOSQnxDebugger)
|
2015-03-03 16:49:59 +01:00
|
|
|
reinitializeFromFile();
|
2013-10-25 13:47:08 +02:00
|
|
|
}
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
2015-03-05 16:29:29 +01:00
|
|
|
// CDB only understands the single-dash -version, whereas GDB and LLDB are
|
2015-09-17 11:11:24 +02:00
|
|
|
// happy with both -version and --version. So use the "working" -version
|
|
|
|
|
// except for the experimental LLDB-MI which insists on --version.
|
|
|
|
|
const char *version = "-version";
|
2016-03-06 23:26:01 +02:00
|
|
|
const QFileInfo fileInfo = m_command.toFileInfo();
|
|
|
|
|
m_lastModified = fileInfo.lastModified();
|
|
|
|
|
if (fileInfo.baseName().toLower().contains(QLatin1String("lldb-mi")))
|
2015-09-17 11:11:24 +02:00
|
|
|
version = "--version";
|
|
|
|
|
|
2016-04-29 16:52:58 +02:00
|
|
|
SynchronousProcess proc;
|
|
|
|
|
SynchronousProcessResponse response
|
2017-02-22 15:09:35 +01:00
|
|
|
= proc.runBlocking(m_command.toString(), QStringList({QLatin1String(version)}));
|
2016-04-29 16:52:58 +02:00
|
|
|
if (response.result != SynchronousProcessResponse::Finished) {
|
2013-10-25 10:44:11 +02:00
|
|
|
m_engineType = NoEngineType;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-11-12 16:18:31 +01:00
|
|
|
m_abis.clear();
|
2016-04-29 16:52:58 +02:00
|
|
|
const QString output = response.allOutput();
|
|
|
|
|
if (output.contains("gdb")) {
|
2013-10-25 13:47:08 +02:00
|
|
|
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"
|
2016-04-29 16:52:58 +02:00
|
|
|
int pos1 = output.indexOf(needle);
|
2013-10-25 13:47:08 +02:00
|
|
|
if (pos1 != -1) {
|
2014-09-09 13:24:58 +02:00
|
|
|
pos1 += int(strlen(needle));
|
2016-04-29 16:52:58 +02:00
|
|
|
int pos2 = output.indexOf('"', pos1 + 1);
|
|
|
|
|
QString target = output.mid(pos1, pos2 - pos1);
|
2013-10-25 13:47:08 +02:00
|
|
|
int pos3 = target.indexOf("--target=");
|
|
|
|
|
if (pos3 >= 0)
|
|
|
|
|
target = target.mid(pos3 + 9);
|
2016-04-29 16:52:58 +02:00
|
|
|
m_abis.append(Abi::abiFromTargetTriplet(target));
|
2013-10-25 13:47:08 +02:00
|
|
|
} else {
|
|
|
|
|
// Fallback.
|
|
|
|
|
m_abis = Abi::abisOfBinary(m_command); // FIXME: Wrong.
|
|
|
|
|
}
|
2014-06-23 17:59:27 +02:00
|
|
|
|
|
|
|
|
// Version
|
|
|
|
|
bool isMacGdb, isQnxGdb;
|
|
|
|
|
int version = 0, buildVersion = 0;
|
2016-04-29 16:52:58 +02:00
|
|
|
Debugger::Internal::extractGdbVersion(output,
|
2014-06-23 17:59:27 +02:00
|
|
|
&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;
|
|
|
|
|
}
|
2016-04-29 16:52:58 +02:00
|
|
|
if (output.startsWith("lldb") || output.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
|
2016-04-29 16:52:58 +02:00
|
|
|
if (output.startsWith(("lldb version "))) { // Linux typically.
|
2015-02-19 16:44:58 +01:00
|
|
|
int pos1 = int(strlen("lldb version "));
|
2016-04-29 16:52:58 +02:00
|
|
|
int pos2 = output.indexOf(' ', pos1);
|
|
|
|
|
m_version = output.mid(pos1, pos2 - pos1);
|
|
|
|
|
} else if (output.startsWith("lldb-") || output.startsWith("LLDB-")) { // Mac typically.
|
|
|
|
|
m_version = output.mid(5);
|
2015-01-15 15:02:51 +01:00
|
|
|
}
|
2013-10-25 13:47:08 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2016-04-29 16:52:58 +02:00
|
|
|
if (output.startsWith("cdb")) {
|
2015-03-05 16:29:29 +01:00
|
|
|
// "cdb version 6.2.9200.16384"
|
|
|
|
|
m_engineType = CdbEngineType;
|
|
|
|
|
m_abis = Abi::abisOfBinary(m_command);
|
2016-04-29 16:52:58 +02:00
|
|
|
m_version = output.section(QLatin1Char(' '), 2);
|
2015-03-05 16:29:29 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2016-04-29 16:52:58 +02:00
|
|
|
if (output.startsWith("Python")) {
|
2013-10-25 13:47:08 +02:00
|
|
|
m_engineType = PdbEngineType;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
m_engineType = NoEngineType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString DebuggerItem::engineTypeName() const
|
|
|
|
|
{
|
|
|
|
|
switch (m_engineType) {
|
2014-10-17 13:40:04 +02:00
|
|
|
case NoEngineType:
|
2016-11-28 18:47:18 +01:00
|
|
|
return DebuggerItemManager::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;
|
2018-05-30 15:42:51 +02:00
|
|
|
for (const Abi &abi : m_abis)
|
2013-10-25 13:47:08 +02:00
|
|
|
list.append(abi.toString());
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-06 23:26:01 +02:00
|
|
|
QDateTime DebuggerItem::lastModified() const
|
|
|
|
|
{
|
|
|
|
|
return m_lastModified;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-29 15:55:15 +02:00
|
|
|
QIcon DebuggerItem::decoration() const
|
2015-09-07 12:13:03 +02:00
|
|
|
{
|
2016-07-29 15:55:15 +02:00
|
|
|
if (m_engineType == NoEngineType)
|
2017-01-02 12:37:49 +01:00
|
|
|
return Utils::Icons::CRITICAL.icon();
|
2016-07-29 15:55:15 +02:00
|
|
|
if (!m_command.toFileInfo().isExecutable())
|
2016-08-03 17:55:54 +02:00
|
|
|
return Utils::Icons::WARNING.icon();
|
2016-07-29 15:55:15 +02:00
|
|
|
if (!m_workingDirectory.isEmpty() && !m_workingDirectory.toFileInfo().isDir())
|
2016-08-03 17:55:54 +02:00
|
|
|
return Utils::Icons::WARNING.icon();
|
2016-07-29 15:55:15 +02:00
|
|
|
return QIcon();
|
2015-09-07 12:13:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString DebuggerItem::validityMessage() const
|
|
|
|
|
{
|
|
|
|
|
if (m_engineType == NoEngineType)
|
2016-11-28 18:47:18 +01:00
|
|
|
return DebuggerItemManager::tr("Could not determine debugger type");
|
2015-09-07 12:13:03 +02:00
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-28 12:51:35 +01:00
|
|
|
bool DebuggerItem::operator==(const DebuggerItem &other) const
|
|
|
|
|
{
|
|
|
|
|
return m_id == other.m_id
|
2015-03-03 16:49:59 +01:00
|
|
|
&& m_unexpandedDisplayName == other.m_unexpandedDisplayName
|
2013-10-28 12:51:35 +01:00
|
|
|
&& m_isAutoDetected == other.m_isAutoDetected
|
2016-07-29 15:55:15 +02:00
|
|
|
&& m_command == other.m_command
|
|
|
|
|
&& m_workingDirectory == other.m_workingDirectory;
|
2013-10-28 12:51:35 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-25 13:47:08 +02:00
|
|
|
QVariantMap DebuggerItem::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap data;
|
2015-03-03 16:49:59 +01:00
|
|
|
data.insert(QLatin1String(DEBUGGER_INFORMATION_DISPLAYNAME), m_unexpandedDisplayName);
|
2013-10-25 13:47:08 +02:00
|
|
|
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());
|
2016-07-29 15:55:15 +02:00
|
|
|
data.insert(QLatin1String(DEBUGGER_INFORMATION_WORKINGDIRECTORY), m_workingDirectory.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());
|
2016-03-06 23:26:01 +02:00
|
|
|
data.insert(QLatin1String(DEBUGGER_INFORMATION_LASTMODIFIED), m_lastModified);
|
2013-10-25 13:47:08 +02:00
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-03 16:49:59 +01:00
|
|
|
QString DebuggerItem::displayName() const
|
|
|
|
|
{
|
|
|
|
|
if (!m_unexpandedDisplayName.contains(QLatin1Char('%')))
|
|
|
|
|
return m_unexpandedDisplayName;
|
|
|
|
|
|
|
|
|
|
MacroExpander expander;
|
|
|
|
|
expander.registerVariable("Debugger:Type", DebuggerKitInformation::tr("Type of Debugger Backend"),
|
|
|
|
|
[this] { return engineTypeName(); });
|
|
|
|
|
expander.registerVariable("Debugger:Version", DebuggerKitInformation::tr("Debugger"),
|
|
|
|
|
[this] { return !m_version.isEmpty() ? m_version :
|
|
|
|
|
DebuggerKitInformation::tr("Unknown debugger version"); });
|
|
|
|
|
expander.registerVariable("Debugger:Abi", DebuggerKitInformation::tr("Debugger"),
|
|
|
|
|
[this] { return !m_abis.isEmpty() ? abiNames().join(QLatin1Char(' ')) :
|
|
|
|
|
DebuggerKitInformation::tr("Unknown debugger ABI"); });
|
|
|
|
|
return expander.expand(m_unexpandedDisplayName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerItem::setUnexpandedDisplayName(const QString &displayName)
|
2013-10-25 13:47:08 +02:00
|
|
|
{
|
2015-03-03 16:49:59 +01:00
|
|
|
m_unexpandedDisplayName = displayName;
|
2013-10-25 13:47:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2016-07-25 18:39:16 -07:00
|
|
|
if (HostOsInfo::isMacHost() && engineType == LldbEngineType && targetAbi.os() == Abi::DarwinOS)
|
2014-07-29 14:19:40 +02:00
|
|
|
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;
|
2018-05-30 15:42:51 +02:00
|
|
|
for (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
|
|
|
}
|
|
|
|
|
|
2014-10-17 13:40:04 +02:00
|
|
|
} // namespace Debugger;
|