Commit 0664aa14 authored by Fawzi Mohamed's avatar Fawzi Mohamed
Browse files

ios: convert to new logging infrastructure



Change-Id: Ia62a585acfb55c35aa859553d24cb0e20600b46a
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 730997b2
......@@ -198,8 +198,8 @@ QStringList IosBuildStep::defaultArguments() const
case BuildConfiguration::Unknown :
break;
default:
qDebug() << "IosBuildStep had an unknown buildType "
<< target()->activeBuildConfiguration()->buildType();
qCWarning(iosLog) << "IosBuildStep had an unknown buildType "
<< target()->activeBuildConfiguration()->buildType();
}
if (tc->type() == QLatin1String("gcc") || tc->type() == QLatin1String("clang")) {
GccToolChain *gtc = static_cast<GccToolChain *>(tc);
......
......@@ -61,7 +61,9 @@ using namespace QtSupport;
using namespace Utils;
using namespace Debugger;
const bool debugProbe = false;
namespace {
Q_LOGGING_CATEGORY(kitSetupLog, "qtc.ios.kitSetup")
}
namespace Ios {
namespace Internal {
......@@ -84,9 +86,8 @@ void IosConfigurations::updateAutomaticKitList()
|| !p.compilerPath.toString().contains(QLatin1String("clang")))
iter = platforms.erase(iter);
else {
if (debugProbe)
qDebug() << "keeping" << p.name << " " << p.compilerPath.toString() << " "
<< p.backendFlags;
qCDebug(kitSetupLog) << "keeping" << p.name << " " << p.compilerPath.toString() << " "
<< p.backendFlags;
++iter;
}
}
......@@ -123,20 +124,18 @@ void IosConfigurations::updateAutomaticKitList()
found = true;
if (p.architecture == QLatin1String("i386")
&& toolchain->targetAbi().wordWidth() != 32) {
if (debugProbe)
qDebug() << "resetting api of " << toolchain->displayName();
qCDebug(kitSetupLog) << "resetting api of " << toolchain->displayName();
toolchain->setTargetAbi(Abi(Abi::X86Architecture,
Abi::MacOS, Abi::GenericMacFlavor,
Abi::MachOFormat, 32));
}
platformToolchainMap[p.name] = toolchain;
if (debugProbe)
qDebug() << p.name << " -> " << toolchain->displayName();
qCDebug(kitSetupLog) << p.name << " -> " << toolchain->displayName();
}
}
if (!found && (tc->displayName().startsWith(QLatin1String("iphone"))
|| tc->displayName().startsWith(QLatin1String("mac")))) {
qDebug() << "removing toolchain" << tc->displayName();
qCWarning(kitSetupLog) << "removing toolchain" << tc->displayName();
ToolChainManager::deregisterToolChain(tc);
}
}
......@@ -173,13 +172,11 @@ void IosConfigurations::updateAutomaticKitList()
toolchain->setPlatformLinkerFlags(p.backendFlags);
toolchain->setCompilerCommand(p.compilerPath);
if (p.architecture == QLatin1String("i386")) {
if (debugProbe)
qDebug() << "setting toolchain Abi for " << toolchain->displayName();
qCDebug(kitSetupLog) << "setting toolchain Abi for " << toolchain->displayName();
toolchain->setTargetAbi(Abi(Abi::X86Architecture,Abi::MacOS, Abi::GenericMacFlavor,
Abi::MachOFormat, 32));
}
if (debugProbe)
qDebug() << "adding toolchain " << p.name;
qCDebug(kitSetupLog) << "adding toolchain " << p.name;
ToolChainManager::registerToolChain(toolchain);
platformToolchainMap.insert(p.name, toolchain);
QMapIterator<QString, Platform> iter2(iter);
......@@ -196,8 +193,7 @@ void IosConfigurations::updateAutomaticKitList()
}
QMap<Abi::Architecture, QList<BaseQtVersion *> > qtVersionsForArch;
foreach (BaseQtVersion *qtVersion, QtVersionManager::versions()) {
if (debugProbe)
qDebug() << "qt type " << qtVersion->type();
qCDebug(kitSetupLog) << "qt type " << qtVersion->type();
if (qtVersion->type() != QLatin1String(Constants::IOSQT)) {
if (qtVersion->qmakeProperty("QMAKE_PLATFORM").contains(QLatin1String("ios"))
|| qtVersion->qmakeProperty("QMAKE_XSPEC").contains(QLatin1String("ios"))) {
......@@ -208,8 +204,7 @@ void IosConfigurations::updateAutomaticKitList()
qtVersion->isAutodetected(),
qtVersion->autodetectionSource());
if (iosVersion && iosVersion->type() == QLatin1String(Constants::IOSQT)) {
if (debugProbe)
qDebug() << "converting QT to iOS QT for " << qtVersion->qmakeCommand().toUserOutput();
qCDebug(kitSetupLog) << "converting QT to iOS QT for " << qtVersion->qmakeCommand().toUserOutput();
QtVersionManager::removeVersion(qtVersion);
QtVersionManager::addVersion(iosVersion);
qtVersion = iosVersion;
......@@ -225,8 +220,7 @@ void IosConfigurations::updateAutomaticKitList()
QList<Abi> qtAbis = qtVersion->qtAbis();
if (qtAbis.empty())
continue;
if (debugProbe)
qDebug() << "qt arch " << qtAbis.first().architecture();
qCDebug(kitSetupLog) << "qt arch " << qtAbis.first().architecture();
foreach (const Abi &abi, qtAbis)
qtVersionsForArch[abi.architecture()].append(qtVersion);
}
......@@ -240,8 +234,7 @@ void IosConfigurations::updateAutomaticKitList()
Core::Id deviceKind = DeviceTypeKitInformation::deviceTypeId(k);
if (deviceKind != Constants::IOS_DEVICE_TYPE
&& deviceKind != Constants::IOS_SIMULATOR_TYPE) {
if (debugProbe)
qDebug() << "skipping existing kit with deviceKind " << deviceKind.toString();
qCDebug(kitSetupLog) << "skipping existing kit with deviceKind " << deviceKind.toString();
continue;
}
if (!k->isAutoDetected())
......@@ -259,17 +252,14 @@ void IosConfigurations::updateAutomaticKitList()
if (!pToolchain)
continue;
Core::Id pDeviceType;
if (debugProbe)
qDebug() << "guaranteeing kit for " << p.name ;
qCDebug(kitSetupLog) << "guaranteeing kit for " << p.name ;
if (p.name.startsWith(QLatin1String("iphoneos-"))) {
pDeviceType = Constants::IOS_DEVICE_TYPE;
} else if (p.name.startsWith(QLatin1String("iphonesimulator-"))) {
pDeviceType = Constants::IOS_SIMULATOR_TYPE;
if (debugProbe)
qDebug() << "pDeviceType " << pDeviceType.toString();
qCDebug(kitSetupLog) << "pDeviceType " << pDeviceType.toString();
} else {
if (debugProbe)
qDebug() << "skipping non ios kit " << p.name;
qCDebug(kitSetupLog) << "skipping non ios kit " << p.name;
// we looked up only the ios qt build above...
continue;
//pDeviceType = Constants::DESKTOP_DEVICE_TYPE;
......@@ -292,9 +282,8 @@ void IosConfigurations::updateAutomaticKitList()
// new Xcode is used). Change?
kitExists = true;
kitAtt = k;
if (debugProbe)
qDebug() << "found existing kit " << k->displayName() << " for " << p.name
<< "," << qt->displayName();
qCDebug(kitSetupLog) << "found existing kit " << k->displayName() << " for " << p.name
<< "," << qt->displayName();
if (i<kitMatched.size())
kitMatched.replace(i, true);
break;
......@@ -303,8 +292,7 @@ void IosConfigurations::updateAutomaticKitList()
if (kitExists) {
kitAtt->blockNotification();
} else {
if (debugProbe)
qDebug() << "setting up new kit for " << p.name;
qCDebug(kitSetupLog) << "setting up new kit for " << p.name;
kitAtt = new Kit;
kitAtt->setAutoDetected(true);
QString baseDisplayName = tr("%1 %2").arg(p.name, qt->displayName());
......@@ -356,7 +344,7 @@ void IosConfigurations::updateAutomaticKitList()
for (int i = 0; i < kitMatched.size(); ++i) {
// deleting extra (old) kits
if (!kitMatched.at(i)) {
qDebug() << "deleting kit " << existingKits.at(i)->displayName();
qCWarning(kitSetupLog) << "deleting kit " << existingKits.at(i)->displayName();
KitManager::deregisterKit(existingKits.at(i));
}
}
......
......@@ -30,10 +30,11 @@
#define IOSCONSTANTS_H
#include <QtGlobal>
#include <utils/logging.h>
namespace Ios {
namespace Internal {
Q_DECLARE_LOGGING_CATEGORY(iosLog)
} // namespace Internal
namespace IosDeviceType {
......
......@@ -51,7 +51,9 @@
using namespace ProjectExplorer;
static bool debugDeviceDetection = false;
namespace {
Q_LOGGING_CATEGORY(detectLog, "qtc.ios.deviceDetect")
}
#ifdef Q_OS_MAC
static QString CFStringRef2QString(CFStringRef s)
......@@ -247,13 +249,11 @@ void IosDeviceManager::deviceConnected(const QString &uid, const QString &name)
IosDevice *newDev = new IosDevice(uid);
if (!name.isNull())
newDev->setDisplayName(name);
if (debugDeviceDetection)
qDebug() << "adding ios device " << uid;
qCDebug(detectLog) << "adding ios device " << uid;
devManager->addDevice(IDevice::ConstPtr(newDev));
} else if (dev->deviceState() != IDevice::DeviceConnected &&
dev->deviceState() != IDevice::DeviceReadyToUse) {
if (debugDeviceDetection)
qDebug() << "updating ios device " << uid;
qCDebug(detectLog) << "updating ios device " << uid;
IosDevice *newDev = 0;
if (dev->type() == devType) {
const IosDevice *iosDev = static_cast<const IosDevice *>(dev.data());
......@@ -268,23 +268,21 @@ void IosDeviceManager::deviceConnected(const QString &uid, const QString &name)
void IosDeviceManager::deviceDisconnected(const QString &uid)
{
if (debugDeviceDetection)
qDebug() << "detected disconnection of ios device " << uid;
qCDebug(detectLog) << "detected disconnection of ios device " << uid;
DeviceManager *devManager = DeviceManager::instance();
Core::Id baseDevId(Constants::IOS_DEVICE_ID);
Core::Id devType(Constants::IOS_DEVICE_TYPE);
Core::Id devId = baseDevId.withSuffix(uid);
IDevice::ConstPtr dev = devManager->find(devId);
if (dev.isNull() || dev->type() != devType) {
qDebug() << "ignoring disconnection of ios device " << uid; // should neve happen
qCWarning(detectLog) << "ignoring disconnection of ios device " << uid; // should neve happen
} else {
const IosDevice *iosDev = static_cast<const IosDevice *>(dev.data());
if (iosDev->m_extraInfo.isEmpty()
|| iosDev->m_extraInfo.value(QLatin1String("deviceName")) == QLatin1String("*unknown*")) {
devManager->removeDevice(iosDev->id());
} else if (iosDev->deviceState() != IDevice::DeviceDisconnected) {
if (debugDeviceDetection)
qDebug() << "disconnecting device " << iosDev->uniqueDeviceID();
qCDebug(detectLog) << "disconnecting device " << iosDev->uniqueDeviceID();
devManager->setDeviceState(iosDev->id(), IDevice::DeviceDisconnected);
}
}
......@@ -326,8 +324,7 @@ void IosDeviceManager::deviceInfo(IosToolHandler *, const QString &uid,
if (info.contains(devNameKey))
newDev->setDisplayName(info.value(devNameKey));
newDev->m_extraInfo = info;
if (debugDeviceDetection)
qDebug() << "updated info of ios device " << uid;
qCDebug(detectLog) << "updated info of ios device " << uid;
dev = IDevice::ConstPtr(newDev);
devManager->addDevice(dev);
}
......@@ -397,8 +394,7 @@ void deviceConnectedCallback(void *refCon, io_iterator_t iterator)
QString name;
if (KERN_SUCCESS == kr)
name = QString::fromLocal8Bit(deviceName);
if (debugDeviceDetection)
qDebug() << "ios device " << name << " in deviceAddedCallback";
qCDebug(detectLog) << "ios device " << name << " in deviceAddedCallback";
CFStringRef cfUid = static_cast<CFStringRef>(IORegistryEntryCreateCFProperty(
usbDevice,
......@@ -413,10 +409,10 @@ void deviceConnectedCallback(void *refCon, io_iterator_t iterator)
}
}
catch (std::exception &e) {
qDebug() << "Exception " << e.what() << " in iosdevice.cpp deviceConnectedCallback";
qCWarning(detectLog) << "Exception " << e.what() << " in iosdevice.cpp deviceConnectedCallback";
}
catch (...) {
qDebug() << "Exception in iosdevice.cpp deviceConnectedCallback";
qCWarning(detectLog) << "Exception in iosdevice.cpp deviceConnectedCallback";
throw;
}
}
......@@ -435,8 +431,7 @@ void deviceDisconnectedCallback(void *refCon, io_iterator_t iterator)
kr = IORegistryEntryGetName(usbDevice, deviceName);
if (KERN_SUCCESS != kr)
deviceName[0] = '\0';
if (debugDeviceDetection)
qDebug() << "ios device " << deviceName << " in deviceDisconnectedCallback";
qCDebug(detectLog) << "ios device " << deviceName << " in deviceDisconnectedCallback";
{
CFStringRef cfUid = static_cast<CFStringRef>(IORegistryEntryCreateCFProperty(
......@@ -453,10 +448,10 @@ void deviceDisconnectedCallback(void *refCon, io_iterator_t iterator)
}
}
catch (std::exception &e) {
qDebug() << "Exception " << e.what() << " in iosdevice.cpp deviceDisconnectedCallback";
qCWarning(detectLog) << "Exception " << e.what() << " in iosdevice.cpp deviceDisconnectedCallback";
}
catch (...) {
qDebug() << "Exception in iosdevice.cpp deviceDisconnectedCallback";
qCWarning(detectLog) << "Exception in iosdevice.cpp deviceDisconnectedCallback";
throw;
}
}
......@@ -557,8 +552,7 @@ void IosDeviceManager::updateAvailableDevices(const QStringList &devices)
if (devices.contains(iosDev->uniqueDeviceID()))
continue;
if (iosDev->deviceState() != IDevice::DeviceDisconnected) {
if (debugDeviceDetection)
qDebug() << "disconnecting device " << iosDev->uniqueDeviceID();
qCDebug(detectLog) << "disconnecting device " << iosDev->uniqueDeviceID();
devManager->setDeviceState(iosDev->id(), IDevice::DeviceDisconnected);
}
}
......
......@@ -52,6 +52,9 @@
#include <projectexplorer/devicesupport/devicemanager.h>
namespace Ios {
namespace Internal {
Q_LOGGING_CATEGORY(iosLog, "qtc.ios.common")
}
IosPlugin::IosPlugin()
{
......
......@@ -29,14 +29,16 @@
#include "iosprobe.h"
#include <QDebug>
#include <utils/logging.h>
#include <QFileInfo>
#include <QProcess>
#include <QDir>
#include <QFileInfoList>
static const bool debugProbe = false;
namespace {
Q_LOGGING_CATEGORY(probeLog, "qtc.ios.probe")
}
namespace Ios {
static QString qsystem(const QString &exe, const QStringList &args = QStringList())
......@@ -66,7 +68,7 @@ static int compareVersions(const QString &v1, const QString &v2)
int n1 = v1L.value(i).toInt(&n1Ok);
int n2 = v2L.value(i).toInt(&n2Ok);
if (!(n1Ok && n2Ok)) {
qDebug() << QString::fromLatin1("Failed to compare version %1 and %2").arg(v1, v2);
qCWarning(probeLog) << QString::fromLatin1("Failed to compare version %1 and %2").arg(v1, v2);
return 0;
}
if (n1 > n2)
......@@ -92,8 +94,7 @@ void IosProbe::addDeveloperPath(const QString &path)
if (m_developerPaths.contains(path))
return;
m_developerPaths.append(path);
if (debugProbe)
qDebug() << QString::fromLatin1("Added developer path %1").arg(path);
qCDebug(probeLog) << QString::fromLatin1("Added developer path %1").arg(path);
}
void IosProbe::detectDeveloperPaths()
......@@ -103,7 +104,7 @@ void IosProbe::detectDeveloperPaths()
QStringList arguments(QLatin1String("--print-path"));
selectedXcode.start(program, arguments, QProcess::ReadOnly);
if (!selectedXcode.waitForFinished() || selectedXcode.exitCode()) {
qDebug() << QString::fromLatin1("Could not detect selected xcode with /usr/bin/xcode-select");
qCWarning(probeLog) << QString::fromLatin1("Could not detect selected xcode with /usr/bin/xcode-select");
} else {
QString path = QString::fromLocal8Bit(selectedXcode.readAllStandardOutput());
path.chop(1);
......@@ -114,8 +115,7 @@ void IosProbe::detectDeveloperPaths()
void IosProbe::setupDefaultToolchains(const QString &devPath, const QString &xcodeName)
{
if (debugProbe)
qDebug() << QString::fromLatin1("Setting up platform \"%1\".").arg(xcodeName);
qCDebug(probeLog) << QString::fromLatin1("Setting up platform \"%1\".").arg(xcodeName);
QString indent = QLatin1String(" ");
// detect clang (default toolchain)
......@@ -124,20 +124,19 @@ void IosProbe::setupDefaultToolchains(const QString &devPath, const QString &xco
+ QLatin1String("/clang++"));
bool hasClang = clangFileInfo.exists();
if (!hasClang)
qDebug() << indent << QString::fromLatin1("Default toolchain %1 not found.")
.arg(clangFileInfo.canonicalFilePath());
qCWarning(probeLog) << indent << QString::fromLatin1("Default toolchain %1 not found.")
.arg(clangFileInfo.canonicalFilePath());
// Platforms
QDir platformsDir(devPath + QLatin1String("/Platforms"));
QFileInfoList platforms = platformsDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
foreach (const QFileInfo &fInfo, platforms) {
if (fInfo.isDir() && fInfo.suffix() == QLatin1String("platform")) {
if (debugProbe)
qDebug() << indent << QString::fromLatin1("Setting up %1").arg(fInfo.fileName());
qCDebug(probeLog) << indent << QString::fromLatin1("Setting up %1").arg(fInfo.fileName());
QSettingsPtr infoSettings(new QSettings(
fInfo.absoluteFilePath() + QLatin1String("/Info.plist"),
QSettings::NativeFormat));
if (!infoSettings->contains(QLatin1String("Name"))) {
qDebug() << indent << QString::fromLatin1("Missing platform name in Info.plist of %1")
qCWarning(probeLog) << indent << QString::fromLatin1("Missing platform name in Info.plist of %1")
.arg(fInfo.absoluteFilePath());
continue;
}
......@@ -145,7 +144,7 @@ void IosProbe::setupDefaultToolchains(const QString &devPath, const QString &xco
if (name != QLatin1String("macosx") && name != QLatin1String("iphoneos")
&& name != QLatin1String("iphonesimulator"))
{
qDebug() << indent << QString::fromLatin1("Skipping unknown platform %1").arg(name);
qCWarning(probeLog) << indent << QString::fromLatin1("Skipping unknown platform %1").arg(name);
continue;
}
......@@ -174,7 +173,7 @@ void IosProbe::setupDefaultToolchains(const QString &devPath, const QString &xco
if (defaultProp.contains(QLatin1String("NATIVE_ARCH"))) {
QString arch = defaultProp.value(QLatin1String("NATIVE_ARCH")).toString();
if (!arch.startsWith(QLatin1String("arm")))
qDebug() << indent << QString::fromLatin1("Expected arm architecture, not %1").arg(arch);
qCWarning(probeLog) << indent << QString::fromLatin1("Expected arm architecture, not %1").arg(arch);
extraFlags << QLatin1String("-arch") << arch;
} else if (name == QLatin1String("iphonesimulator")) {
// don't generate a toolchain for 64 bit (to fix when we support that)
......@@ -195,8 +194,7 @@ void IosProbe::setupDefaultToolchains(const QString &devPath, const QString &xco
QStringList compilerTripletl = compilerTriplet.split(QLatin1Char('-'));
clangProfile.architecture = compilerTripletl.value(0);
clangProfile.backendFlags = extraFlags;
if (debugProbe)
qDebug() << indent << QString::fromLatin1("* adding profile %1").arg(clangProfile.name);
qCDebug(probeLog) << indent << QString::fromLatin1("* adding profile %1").arg(clangProfile.name);
m_platforms[clangProfile.name] = clangProfile;
clangProfile.platformKind |= Platform::Cxx11Support;
clangProfile.backendFlags.append(QLatin1String("-std=c++11"));
......@@ -220,8 +218,7 @@ void IosProbe::setupDefaultToolchains(const QString &devPath, const QString &xco
QStringList compilerTripletl = compilerTriplet.split(QLatin1Char('-'));
gccProfile.architecture = compilerTripletl.value(0);
gccProfile.backendFlags = extraFlags;
if (debugProbe)
qDebug() << indent << QString::fromLatin1("* adding profile %1").arg(gccProfile.name);
qCDebug(probeLog) << indent << QString::fromLatin1("* adding profile %1").arg(gccProfile.name);
m_platforms[gccProfile.name] = gccProfile;
}
......@@ -246,9 +243,8 @@ void IosProbe::setupDefaultToolchains(const QString &devPath, const QString &xco
bool isBaseSdk = sdkInfo->value((QLatin1String("isBaseSDK"))).toString()
.toLower() != QLatin1String("no");
if (!isBaseSdk) {
if (debugProbe)
qDebug() << indent << QString::fromLatin1("Skipping non base Sdk %1")
.arg(currentSdkName.toString());
qCDebug(probeLog) << indent << QString::fromLatin1("Skipping non base Sdk %1")
.arg(currentSdkName.toString());
continue;
}
if (sdkName.isEmpty()) {
......@@ -265,7 +261,7 @@ void IosProbe::setupDefaultToolchains(const QString &devPath, const QString &xco
if (!sdkPath.isEmpty())
sysRoot = sdkPath;
else if (!sdkName.isEmpty())
qDebug() << indent << QString::fromLatin1("Failed to find sysroot %1").arg(sdkName);
qCDebug(probeLog) << indent << QString::fromLatin1("Failed to find sysroot %1").arg(sdkName);
}
if (hasClang && !sysRoot.isEmpty()) {
m_platforms[clangFullName].platformKind |= Platform::BasePlatform;
......
......@@ -35,7 +35,6 @@
#include <proparser/profileevaluator.h>
#include <QFileInfo>
#include <QDebug>
namespace Ios {
namespace Internal {
......
......@@ -28,6 +28,7 @@
****************************************************************************/
#include "iosrunconfiguration.h"
#include "iosconstants.h"
#include "iosmanager.h"
#include "iosdeploystep.h"
#include "ui_iosrunconfiguration.h"
......@@ -212,7 +213,7 @@ Utils::FileName IosRunConfiguration::bundleDirectory() const
Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target()->kit());
bool isDevice = (devType == Constants::IOS_DEVICE_TYPE);
if (!isDevice && devType != Constants::IOS_SIMULATOR_TYPE) {
qDebug() << "unexpected device type in bundleDirForTarget: " << devType.toString();
qCWarning(iosLog) << "unexpected device type in bundleDirForTarget: " << devType.toString();
return res;
}
QmakeBuildConfiguration *bc =
......@@ -246,7 +247,7 @@ Utils::FileName IosRunConfiguration::bundleDirectory() const
res.appendPath(QLatin1String("Release-iphonesimulator"));
break;
default:
qDebug() << "IosBuildStep had an unknown buildType "
qCWarning(iosLog) << "IosBuildStep had an unknown buildType "
<< target()->activeBuildConfiguration()->buildType();
}
}
......@@ -413,7 +414,7 @@ QStringList IosRunConfigurationWidget::stringToArgList(const QString &args) cons
res = QtcProcess::splitArgs(args + QLatin1Char('\"'), OsTypeMac, false, &err);
break;
case QtcProcess::FoundMeta:
qDebug() << "IosRunConfigurationWidget FoundMeta (should not happen)";
qCWarning(iosLog) << "IosRunConfigurationWidget FoundMeta (should not happen)";
break;
}
return res;
......
......@@ -34,11 +34,11 @@
#include <coreplugin/icore.h>
#include <utils/qtcassert.h>
#include <utils/fileutils.h>
#include <utils/logging.h>
#include <QProcess>
#include <QXmlStreamReader>
#include <QSocketNotifier>
#include <QDebug>
#include <QCoreApplication>
#include <QList>
#include <QScopedArrayPointer>
......@@ -49,7 +49,9 @@
#include <string.h>
#include <errno.h>
static const bool debugToolHandler = false;
namespace {
Q_LOGGING_CATEGORY(toolHandlerLog, "qtc.ios.toolhandler")
}
namespace Ios {
......@@ -220,8 +222,7 @@ IosToolHandlerPrivate::IosToolHandlerPrivate(IosDeviceType::Enum devType,
frameworkPaths << QLatin1String("/System/Library/Frameworks")
<< QLatin1String("/System/Library/PrivateFrameworks");
env.insert(QLatin1String("DYLD_FALLBACK_FRAMEWORK_PATH"), frameworkPaths.join(QLatin1String(":")));
if (debugToolHandler)
qDebug() << "IosToolHandler runEnv:" << env.toStringList();
qCDebug(toolHandlerLog) << "IosToolHandler runEnv:" << env.toStringList();
process.setProcessEnvironment(env);
QObject::connect(&process, SIGNAL(readyReadStandardOutput()), q, SLOT(subprocessHasData()));
QObject::connect(&process, SIGNAL(finished(int,QProcess::ExitStatus)),
......@@ -241,26 +242,24 @@ void IosToolHandlerPrivate::start(const QString &exe, const QStringList &args)
{
QTC_CHECK(state == NonStarted);
state = Starting;
if (debugToolHandler)
qDebug() << "running " << exe << args;
qCDebug(toolHandlerLog) << "running " << exe << args;
process.start(exe, args);
state = StartedInferior;
}
void IosToolHandlerPrivate::stop(int errorCode)
{
if (debugToolHandler)
qDebug() << "IosToolHandlerPrivate::stop";
qCDebug(toolHandlerLog) << "IosToolHandlerPrivate::stop";
State oldState = state;
state = Stopped;
switch (oldState) {
case NonStarted:
qDebug() << "IosToolHandler::stop() when state was NonStarted";
qCWarning(toolHandlerLog) << "IosToolHandler::stop() when state was NonStarted";
// pass
case Starting:
switch (op){
case OpNone:
qDebug() << "IosToolHandler::stop() when op was OpNone";
qCWarning(toolHandlerLog) << "IosToolHandler::stop() when op was OpNone";
break;
case OpAppTransfer:
didTransferApp(bundlePath, deviceId, IosToolHandler::Failure);
......@@ -343,8 +342,7 @@ void IosToolHandlerPrivate::subprocessError(QProcess::ProcessError error)
errorMsg(IosToolHandler::tr("iOS tool Error %1").arg(error));
stop(-1);
if (error == QProcess::FailedToStart) {
if (debugToolHandler)
qDebug() << "IosToolHandler::finished(" << this << ")";
qCDebug(toolHandlerLog) << "IosToolHandler::finished(" << this << ")";
emit q->finished(q);
}
}
......@@ -352,8 +350,7 @@ void IosToolHandlerPrivate::subprocessError(QProcess::ProcessError error)
void IosToolHandlerPrivate::subprocessFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
stop((exitStatus == QProcess::NormalExit) ? exitCode : -1 );
if (debugToolHandler)
qDebug() << "IosToolHandler::finished(" << this << ")";
qCDebug(toolHandlerLog) << "IosToolHandler::finished(" << this << ")";
killTimer.stop();
emit q->finished(q);
}
......@@ -362,7 +359,7 @@ void IosToolHandlerPrivate::processXml()
{
while (!outputParser.atEnd()) {
QXmlStreamReader::TokenType tt = outputParser.readNext();
//qDebug() << "processXml, tt=" << tt;
//qCDebug(toolHandlerLog) << "processXml, tt=" << tt;
switch (tt) {
case QXmlStreamReader::NoToken:
// The reader has not yet read anything.
......@@ -449,7 +446,7 @@ void IosToolHandlerPrivate::processXml()
int qmlServerPort = attributes.value(QLatin1String("qml_server")).toString().toInt();
gotServerPorts(bundlePath, deviceId, gdbServerPort, qmlServerPort);
} else {
qDebug() << "unexpected element " << elName;
qCWarning(toolHandlerLog) << "unexpected element " << elName;
}
break;
}
......@@ -533,19 +530,18 @@ void IosToolHandlerPrivate::processXml()
}
if (outputParser.hasError()
&& outputParser.error() != QXmlStreamReader::PrematureEndOfDocumentError) {
qDebug() << "error parsing iosTool output:" << outputParser.errorString();
qCWarning(toolHandlerLog) << "error parsing iosTool output:" << outputParser.errorString();
stop(-1);
}
}
void IosToolHandlerPrivate::subprocessHasData()
{
if (debugToolHandler)
qDebug() << "subprocessHasData, state:" << state;
qCDebug(toolHandlerLog) << "subprocessHasData, state:" << state;
while (true) {
switch (state) {
case NonStarted: