本文整理汇总了C++中ProbeABI类的典型用法代码示例。如果您正苦于以下问题:C++ ProbeABI类的具体用法?C++ ProbeABI怎么用?C++ ProbeABI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProbeABI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: abiFromMachO
static ProbeABI abiFromMachO(const uchar* data, qint64 size)
{
ProbeABI abi;
const quint32 magic = *reinterpret_cast<const quint32*>(data);
quint32 offset = 0;
qint32 ncmds = 0;
qint32 cmdsize = 0;
switch (magic) {
case MH_MAGIC:
abi.setArchitecture(readMachOHeader<mach_header>(data, size, offset, ncmds, cmdsize));
break;
case MH_MAGIC_64:
abi.setArchitecture(readMachOHeader<mach_header_64>(data, size, offset, ncmds, cmdsize));
break;
}
if (offset >= size || ncmds <= 0 || cmdsize <= 0 || size <= offset + cmdsize)
return ProbeABI();
// read load commands
for (int i = 0; i < ncmds; ++i) {
const load_command* cmd = reinterpret_cast<const load_command*>(data + offset);
if (cmd->cmd == LC_ID_DYLIB) {
const dylib_command* dlcmd = reinterpret_cast<const dylib_command*>(data + offset);
const int majorVersion = (dlcmd->dylib.current_version & 0x00ff0000) >> 16;
const int minorVersion = (dlcmd->dylib.current_version & 0x0000ff00) >> 8;
abi.setQtVersion(majorVersion, minorVersion);
}
offset += cmd->cmdsize;
}
return abi;
}
示例2: testDetectProcess
void testDetectProcess()
{
ProbeABIDetector detector;
QVERIFY(!detector.qtCoreForProcess(QCoreApplication::applicationPid()).isEmpty());
const ProbeABI abi = detector.abiForProcess(QCoreApplication::applicationPid());
QCOMPARE(abi.id(), QStringLiteral(GAMMARAY_PROBE_ABI));
}
示例3: testDisplayString
void testDisplayString()
{
QFETCH(QString, id);
QFETCH(QString, display);
const ProbeABI abi = ProbeABI::fromString(id);
QCOMPARE(abi.displayString(), display);
}
示例4: majorQtVersion
bool ProbeABI::operator==(const ProbeABI& rhs) const
{
return majorQtVersion() == rhs.majorQtVersion()
&& minorQtVersion() == rhs.minorQtVersion()
&& architecture() == rhs.architecture()
&& compiler() == rhs.compiler()
&& isDebug() == rhs.isDebug();
}
示例5: testFromString
void testFromString()
{
QFETCH(QString, id);
QFETCH(bool, valid);
QFETCH(int, majorVersion);
QFETCH(int, minorVersion);
QFETCH(bool, isDebug);
QFETCH(QString, arch);
QFETCH(QString, compiler);
#ifdef Q_OS_WIN
QFETCH(QString, compilerVersion);
#endif
const ProbeABI abi = ProbeABI::fromString(id);
QCOMPARE(abi.isValid(), valid);
if (!valid)
return;
QCOMPARE(abi.majorQtVersion(), majorVersion);
QCOMPARE(abi.minorQtVersion(), minorVersion);
QCOMPARE(abi.architecture(), arch);
if (abi.isDebugRelevant()) {
QCOMPARE(abi.isDebug(), isDebug);
}
#ifdef Q_OS_WIN
QCOMPARE(abi.compiler(), compiler);
QCOMPARE(abi.compilerVersion(), compilerVersion);
#else
Q_UNUSED(compiler);
#endif
}
示例6: qtVersionFromFileName
static ProbeABI qtVersionFromFileName(const QString &path)
{
ProbeABI abi;
const QStringList parts = path.split('.');
if (parts.size() < 4 || parts.at(parts.size() - 4) != QLatin1String("so"))
return abi;
abi.setQtVersion(parts.at(parts.size() - 3).toInt(), parts.at(parts.size() - 2).toInt());
return abi;
}
示例7: isCompatible
bool ProbeABI::isCompatible(const ProbeABI& referenceABI) const
{
return d->majorQtVersion == referenceABI.majorQtVersion()
&& d->minorQtVersion >= referenceABI.minorQtVersion() // we can work with older probes, since the target defines the Qt libraries being used
&& d->architecture == referenceABI.architecture()
#ifdef Q_OS_WIN
&& d->compiler == referenceABI.compiler()
#endif
&& (isDebugRelevant() ? d->isDebug == referenceABI.isDebug() : true)
;
}
示例8: defaultInjectorForLaunch
AbstractInjector::Ptr defaultInjectorForLaunch(const ProbeABI &abi)
{
#if defined(Q_OS_MAC)
if (abi.majorQtVersion() >= 5 && abi.minorQtVersion() >= 4)
return createInjector(QLatin1String("preload"));
return findFirstWorkingInjector(QStringList() << QLatin1String("lldb") << QLatin1String("gdb"));
#elif defined(Q_OS_UNIX)
Q_UNUSED(abi);
return createInjector(QLatin1String("preload"));
#else
Q_UNUSED(abi);
return createInjector(QLatin1String("windll"));
#endif
}
示例9: ProbeABI
ProbeABI ProbeABIDetector::detectAbiForQtCore(const QString &path) const
{
if (path.isEmpty())
return ProbeABI();
// try to find the version
ProbeABI abi = qtVersionFromFileName(path);
if (!abi.hasQtVersion())
abi = qtVersionFromExec(path);
// TODO: architecture detection fallback without elf.h?
const QString arch = archFromELF(path);
abi.setArchitecture(arch);
return abi;
}
示例10: indexOfBestMatchingABI
int ProbeABIModel::indexOfBestMatchingABI(const ProbeABI& targetABI) const
{
if (!targetABI.isValid())
return -1;
const ProbeABI bestMatchingABI = ProbeFinder::findBestMatchingABI(targetABI, m_abis);
return m_abis.indexOf(bestMatchingABI);
}
示例11: testProbeABICompat
void testProbeABICompat()
{
#ifndef Q_OS_WIN
const ProbeABI targetABI = ProbeABI::fromString(QStringLiteral("qt5_2-x86_64"));
const ProbeABI probeABI = ProbeABI::fromString(QStringLiteral("qt5_1-x86_64"));
#if defined(Q_OS_MAC)
const bool debugAbiMatters = true;
#else
const bool debugAbiMatters = false;
#endif
const bool compilerAbiMatters = false;
#else
const ProbeABI targetABI = ProbeABI::fromString(QStringLiteral("qt5_2-MSVC-140-x86_64"));
const ProbeABI probeABI = ProbeABI::fromString(QStringLiteral("qt5_1-MSVC-140-x86_64"));
const bool debugAbiMatters = true;
const bool compilerAbiMatters = true;
#endif
// full match, or same major version and older probe
QVERIFY(targetABI.isCompatible(targetABI));
QVERIFY(targetABI.isCompatible(probeABI));
// incompatible
// newer minor version probe
QVERIFY(!probeABI.isCompatible(targetABI));
// different major version
ProbeABI incompatABI(probeABI);
incompatABI.setQtVersion(4, 8);
QVERIFY(!targetABI.isCompatible(incompatABI));
QVERIFY(!incompatABI.isCompatible(targetABI));
// different architecture
incompatABI = targetABI;
incompatABI.setArchitecture(QStringLiteral("i686"));
QVERIFY(!targetABI.isCompatible(incompatABI));
// different debug/release mode
incompatABI = targetABI;
incompatABI.setIsDebug(true);
QCOMPARE(targetABI.isCompatible(incompatABI), !debugAbiMatters);
// different compiler
incompatABI = targetABI;
incompatABI.setCompiler(QStringLiteral("Clang"));
QCOMPARE(targetABI.isCompatible(incompatABI), !compilerAbiMatters);
}
示例12: qtVersionFromExec
static ProbeABI qtVersionFromExec(const QString &path)
{
ProbeABI abi;
// yep, you can actually execute QtCore.so...
QProcess proc;
proc.setReadChannelMode(QProcess::SeparateChannels);
proc.setReadChannel(QProcess::StandardOutput);
proc.start(path);
proc.waitForFinished();
const QByteArray line = proc.readLine();
const int pos = line.lastIndexOf(' ');
const QList<QByteArray> version = line.mid(pos).split('.');
if (version.size() < 3)
return abi;
abi.setQtVersion(version.at(0).toInt(), version.at(1).toInt());
return abi;
}
示例13: findBestMatchingABI
ProbeABI findBestMatchingABI(const ProbeABI &targetABI, const QVector<ProbeABI> &availableABIs)
{
QVector<ProbeABI> compatABIs;
foreach (const ProbeABI &abi, availableABIs) {
if (targetABI.isCompatible(abi))
compatABIs.push_back(abi);
}
if (compatABIs.isEmpty())
return ProbeABI();
std::sort(compatABIs.begin(), compatABIs.end());
return compatABIs.last();
}
示例14: listProbeABIs
QVector<ProbeABI> listProbeABIs()
{
QVector<ProbeABI> abis;
const QDir dir(Paths::probePath(QString()));
#if defined(GAMMARAY_INSTALL_QT_LAYOUT)
const QString filter = QStringLiteral("*gammaray_probe*");
foreach (const QFileInfo &abiId, dir.entryInfoList(QStringList(filter), QDir::Files)) {
// OSX has broken QLibrary::isLibrary() - QTBUG-50446
if (!QLibrary::isLibrary(abiId.fileName())
&& !abiId.fileName().endsWith(Paths::libraryExtension(), Qt::CaseInsensitive))
continue;
const ProbeABI abi = ProbeABI::fromString(abiId.baseName().section(QStringLiteral("-"), 1));
if (abi.isValid())
abis.push_back(abi);
}
#else
foreach (const QString &abiId, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
const ProbeABI abi = ProbeABI::fromString(abiId);
if (abi.isValid())
abis.push_back(abi);
}
#endif
return abis;
}
示例15: ProbeABI
ProbeABI ProbeABI::fromString(const QString &id)
{
QStringList idParts = id.split('-');
if (idParts.size() < 2)
return ProbeABI();
int index = 0;
ProbeABI abi;
// version
static QRegExp versionRegExp("^qt(\\d+)\\_(\\d+)$");
if (versionRegExp.indexIn(idParts.value(index++)) != 0)
return ProbeABI();
abi.setQtVersion(versionRegExp.cap(1).toInt(), versionRegExp.cap(2).toInt());
// compiler
#ifdef Q_OS_WIN
abi.setCompiler(idParts.value(index++));
if (abi.isVersionRelevant())
abi.setCompilerVersion(idParts.value(index++));
#endif
if (idParts.size() != index + 1)
return ProbeABI();
// architecture / debug/release
const QString postfix = QStringLiteral(GAMMARAY_DEBUG_POSTFIX);
QString arch = idParts.value(index);
if (!postfix.isEmpty()) {
if (arch.endsWith(postfix, Qt::CaseInsensitive)) {
arch.chop(postfix.length());
if (abi.isDebugRelevant())
abi.setIsDebug(true);
}
}
abi.setArchitecture(arch);
return abi;
}