2013-04-25 16:02:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-04-25 16:02:17 +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-04-25 16:02:17 +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-04-25 16:02:17 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "iosbuildstep.h"
|
|
|
|
|
#include "iosconfigurations.h"
|
|
|
|
|
#include "iosdevice.h"
|
|
|
|
|
#include "iosmanager.h"
|
|
|
|
|
#include "iosrunconfiguration.h"
|
|
|
|
|
#include "iosrunner.h"
|
|
|
|
|
#include "iossimulator.h"
|
2014-03-28 19:05:35 +01:00
|
|
|
#include "iosconstants.h"
|
2013-04-25 16:02:17 +02:00
|
|
|
|
2017-05-19 16:59:02 +02:00
|
|
|
#include <debugger/debuggerplugin.h>
|
|
|
|
|
#include <debugger/debuggerkitinformation.h>
|
|
|
|
|
#include <debugger/debuggerruncontrol.h>
|
|
|
|
|
|
2013-04-25 16:02:17 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2017-05-19 16:59:02 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2013-04-25 16:02:17 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2013-11-04 22:45:52 +01:00
|
|
|
#include <projectexplorer/taskhub.h>
|
2017-05-19 16:59:02 +02:00
|
|
|
#include <projectexplorer/toolchain.h>
|
|
|
|
|
|
2015-08-10 17:43:58 +02:00
|
|
|
#include <qmldebug/qmldebugcommandlinearguments.h>
|
2013-04-25 16:02:17 +02:00
|
|
|
|
2017-05-19 16:59:02 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/fileutils.h>
|
|
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
|
#include <utils/utilsicons.h>
|
|
|
|
|
|
|
|
|
|
#include <QDateTime>
|
2013-04-25 16:02:17 +02:00
|
|
|
#include <QDir>
|
|
|
|
|
#include <QMessageBox>
|
2014-02-25 22:48:19 +01:00
|
|
|
#include <QRegExp>
|
2017-05-19 16:59:02 +02:00
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QTcpServer>
|
|
|
|
|
#include <QTime>
|
2013-04-25 16:02:17 +02:00
|
|
|
|
2017-05-19 16:59:02 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <io.h>
|
|
|
|
|
#endif
|
2013-10-28 08:16:05 +01:00
|
|
|
#include <signal.h>
|
|
|
|
|
|
2017-05-19 16:59:02 +02:00
|
|
|
using namespace Debugger;
|
2013-11-04 22:45:52 +01:00
|
|
|
using namespace ProjectExplorer;
|
2017-05-19 16:59:02 +02:00
|
|
|
using namespace Utils;
|
2013-11-04 22:45:52 +01:00
|
|
|
|
2013-04-25 16:02:17 +02:00
|
|
|
namespace Ios {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2017-07-14 10:12:37 +02:00
|
|
|
static void stopRunningRunControl(RunControl *runControl)
|
|
|
|
|
{
|
|
|
|
|
static QMap<Core::Id, QPointer<RunControl>> activeRunControls;
|
|
|
|
|
|
|
|
|
|
RunConfiguration *runConfig = runControl->runConfiguration();
|
|
|
|
|
Target *target = runConfig->target();
|
|
|
|
|
Core::Id devId = DeviceKitInformation::deviceId(target->kit());
|
|
|
|
|
|
|
|
|
|
// The device can only run an application at a time, if an app is running stop it.
|
|
|
|
|
if (activeRunControls.contains(devId)) {
|
|
|
|
|
if (QPointer<RunControl> activeRunControl = activeRunControls[devId])
|
|
|
|
|
activeRunControl->initiateStop();
|
|
|
|
|
activeRunControls.remove(devId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (devId.isValid())
|
|
|
|
|
activeRunControls[devId] = runControl;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-19 16:59:02 +02:00
|
|
|
IosRunner::IosRunner(RunControl *runControl)
|
|
|
|
|
: RunWorker(runControl)
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2017-07-14 10:12:37 +02:00
|
|
|
stopRunningRunControl(runControl);
|
2017-03-28 18:51:29 +02:00
|
|
|
auto runConfig = qobject_cast<IosRunConfiguration *>(runControl->runConfiguration());
|
|
|
|
|
m_bundleDir = runConfig->bundleDirectory().toString();
|
|
|
|
|
m_arguments = QStringList(runConfig->commandLineArguments());
|
|
|
|
|
m_device = DeviceKitInformation::device(runConfig->target()->kit());
|
2014-03-28 19:05:35 +01:00
|
|
|
m_deviceType = runConfig->deviceType();
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IosRunner::~IosRunner()
|
|
|
|
|
{
|
|
|
|
|
stop();
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-19 16:59:02 +02:00
|
|
|
void IosRunner::setCppDebugging(bool cppDebug)
|
|
|
|
|
{
|
|
|
|
|
m_cppDebug = cppDebug;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosRunner::setQmlDebugging(QmlDebug::QmlDebugServicesPreset qmlDebugServices)
|
|
|
|
|
{
|
|
|
|
|
m_qmlDebugServices = qmlDebugServices;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-25 16:02:17 +02:00
|
|
|
QString IosRunner::bundlePath()
|
|
|
|
|
{
|
|
|
|
|
return m_bundleDir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList IosRunner::extraArgs()
|
|
|
|
|
{
|
2014-02-25 22:48:19 +01:00
|
|
|
QStringList res = m_arguments;
|
2017-05-19 16:59:02 +02:00
|
|
|
if (m_qmlServerPort.isValid())
|
|
|
|
|
res << QmlDebug::qmlDebugTcpArguments(m_qmlDebugServices, m_qmlServerPort);
|
2014-02-25 22:48:19 +01:00
|
|
|
return res;
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IosRunner::deviceId()
|
|
|
|
|
{
|
|
|
|
|
IosDevice::ConstPtr dev = m_device.dynamicCast<const IosDevice>();
|
|
|
|
|
if (!dev)
|
|
|
|
|
return QString();
|
|
|
|
|
return dev->uniqueDeviceID();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IosToolHandler::RunKind IosRunner::runType()
|
|
|
|
|
{
|
2014-02-25 22:48:19 +01:00
|
|
|
if (m_cppDebug)
|
2013-04-25 16:02:17 +02:00
|
|
|
return IosToolHandler::DebugRun;
|
|
|
|
|
return IosToolHandler::NormalRun;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 22:48:19 +01:00
|
|
|
bool IosRunner::cppDebug() const
|
|
|
|
|
{
|
|
|
|
|
return m_cppDebug;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-26 14:15:44 +02:00
|
|
|
bool IosRunner::qmlDebug() const
|
|
|
|
|
{
|
|
|
|
|
return m_qmlDebugServices != QmlDebug::NoQmlDebugServices;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-10 17:43:58 +02:00
|
|
|
QmlDebug::QmlDebugServicesPreset IosRunner::qmlDebugServices() const
|
2014-02-25 22:48:19 +01:00
|
|
|
{
|
2015-08-10 17:43:58 +02:00
|
|
|
return m_qmlDebugServices;
|
2014-02-25 22:48:19 +01:00
|
|
|
}
|
|
|
|
|
|
2013-04-25 16:02:17 +02:00
|
|
|
void IosRunner::start()
|
|
|
|
|
{
|
2017-05-19 16:59:02 +02:00
|
|
|
if (m_toolHandler && isAppRunning())
|
2013-04-25 16:02:17 +02:00
|
|
|
m_toolHandler->stop();
|
2017-05-19 16:59:02 +02:00
|
|
|
|
2013-04-25 16:02:17 +02:00
|
|
|
m_cleanExit = false;
|
2017-05-19 16:59:02 +02:00
|
|
|
m_qmlServerPort = Port();
|
2014-10-24 10:28:28 +02:00
|
|
|
if (!QFileInfo::exists(m_bundleDir)) {
|
2014-03-11 11:15:37 +01:00
|
|
|
TaskHub::addTask(Task::Warning,
|
|
|
|
|
tr("Could not find %1.").arg(m_bundleDir),
|
|
|
|
|
ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
|
2017-05-19 16:59:02 +02:00
|
|
|
reportFailure();
|
2014-03-11 11:15:37 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2014-02-25 22:48:19 +01:00
|
|
|
if (m_device->type() == Ios::Constants::IOS_DEVICE_TYPE) {
|
|
|
|
|
IosDevice::ConstPtr iosDevice = m_device.dynamicCast<const IosDevice>();
|
|
|
|
|
if (m_device.isNull()) {
|
2017-05-19 16:59:02 +02:00
|
|
|
reportFailure();
|
2014-02-25 22:48:19 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2015-08-10 17:43:58 +02:00
|
|
|
if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices)
|
2017-05-19 16:59:02 +02:00
|
|
|
m_qmlServerPort = iosDevice->nextPort();
|
2014-02-25 22:48:19 +01:00
|
|
|
} else {
|
2013-04-25 16:02:17 +02:00
|
|
|
IosSimulator::ConstPtr sim = m_device.dynamicCast<const IosSimulator>();
|
|
|
|
|
if (sim.isNull()) {
|
2017-05-19 16:59:02 +02:00
|
|
|
reportFailure();
|
2013-04-25 16:02:17 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2015-08-10 17:43:58 +02:00
|
|
|
if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices)
|
2017-05-19 16:59:02 +02:00
|
|
|
m_qmlServerPort = sim->nextPort();
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
2014-02-25 22:48:19 +01:00
|
|
|
|
2014-03-28 19:05:35 +01:00
|
|
|
m_toolHandler = new IosToolHandler(m_deviceType, this);
|
2015-09-11 13:32:45 +02:00
|
|
|
connect(m_toolHandler, &IosToolHandler::appOutput,
|
|
|
|
|
this, &IosRunner::handleAppOutput);
|
|
|
|
|
connect(m_toolHandler, &IosToolHandler::errorMsg,
|
|
|
|
|
this, &IosRunner::handleErrorMsg);
|
|
|
|
|
connect(m_toolHandler, &IosToolHandler::gotServerPorts,
|
|
|
|
|
this, &IosRunner::handleGotServerPorts);
|
|
|
|
|
connect(m_toolHandler, &IosToolHandler::gotInferiorPid,
|
|
|
|
|
this, &IosRunner::handleGotInferiorPid);
|
|
|
|
|
connect(m_toolHandler, &IosToolHandler::toolExited,
|
|
|
|
|
this, &IosRunner::handleToolExited);
|
|
|
|
|
connect(m_toolHandler, &IosToolHandler::finished,
|
|
|
|
|
this, &IosRunner::handleFinished);
|
2013-04-25 16:02:17 +02:00
|
|
|
m_toolHandler->requestRunApp(bundlePath(), extraArgs(), runType(), deviceId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosRunner::stop()
|
|
|
|
|
{
|
2017-05-19 16:59:02 +02:00
|
|
|
if (isAppRunning())
|
2013-04-25 16:02:17 +02:00
|
|
|
m_toolHandler->stop();
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 22:48:19 +01:00
|
|
|
void IosRunner::handleGotServerPorts(IosToolHandler *handler, const QString &bundlePath,
|
2017-05-19 16:59:02 +02:00
|
|
|
const QString &deviceId, Port gdbPort,
|
|
|
|
|
Port qmlPort)
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2017-05-19 16:59:02 +02:00
|
|
|
// Called when debugging on Device.
|
2013-04-25 16:02:17 +02:00
|
|
|
Q_UNUSED(bundlePath); Q_UNUSED(deviceId);
|
2017-06-26 14:15:44 +02:00
|
|
|
|
|
|
|
|
if (m_toolHandler != handler)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_gdbServerPort = gdbPort;
|
|
|
|
|
m_qmlServerPort = qmlPort;
|
|
|
|
|
|
|
|
|
|
bool prerequisiteOk = false;
|
|
|
|
|
if (cppDebug() && qmlDebug())
|
|
|
|
|
prerequisiteOk = m_gdbServerPort.isValid() && m_qmlServerPort.isValid();
|
|
|
|
|
else if (cppDebug())
|
|
|
|
|
prerequisiteOk = m_gdbServerPort.isValid();
|
|
|
|
|
else if (qmlDebug())
|
|
|
|
|
prerequisiteOk = m_qmlServerPort.isValid();
|
|
|
|
|
else
|
|
|
|
|
prerequisiteOk = true; // Not debugging. Ports not required.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (prerequisiteOk)
|
|
|
|
|
reportStarted();
|
|
|
|
|
else
|
|
|
|
|
reportFailure(tr("Could not get necessary ports for the debugger connection."));
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosRunner::handleGotInferiorPid(IosToolHandler *handler, const QString &bundlePath,
|
2015-09-11 13:13:04 +02:00
|
|
|
const QString &deviceId, qint64 pid)
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2017-05-19 16:59:02 +02:00
|
|
|
// Called when debugging on Simulator.
|
2013-04-25 16:02:17 +02:00
|
|
|
Q_UNUSED(bundlePath); Q_UNUSED(deviceId);
|
2017-06-26 14:15:44 +02:00
|
|
|
|
|
|
|
|
if (m_toolHandler != handler)
|
|
|
|
|
return;
|
|
|
|
|
|
2013-10-28 08:16:05 +01:00
|
|
|
m_pid = pid;
|
2017-06-26 14:15:44 +02:00
|
|
|
bool prerequisiteOk = false;
|
|
|
|
|
if (m_pid > 0) {
|
|
|
|
|
prerequisiteOk = true;
|
|
|
|
|
} else {
|
2017-05-19 16:59:02 +02:00
|
|
|
reportFailure(tr("Could not get inferior PID."));
|
2017-06-26 14:15:44 +02:00
|
|
|
return;
|
2017-05-19 16:59:02 +02:00
|
|
|
}
|
2017-06-26 14:15:44 +02:00
|
|
|
|
|
|
|
|
if (qmlDebug())
|
|
|
|
|
prerequisiteOk = m_qmlServerPort.isValid();
|
|
|
|
|
|
|
|
|
|
if (prerequisiteOk)
|
|
|
|
|
reportStarted();
|
|
|
|
|
else
|
|
|
|
|
reportFailure(tr("Could not get necessary ports the debugger connection."));
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosRunner::handleAppOutput(IosToolHandler *handler, const QString &output)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(handler);
|
2017-05-19 16:59:02 +02:00
|
|
|
QRegExp qmlPortRe("QML Debugger: Waiting for connection on port ([0-9]+)...");
|
2014-02-25 22:48:19 +01:00
|
|
|
int index = qmlPortRe.indexIn(output);
|
|
|
|
|
QString res(output);
|
2017-05-19 16:59:02 +02:00
|
|
|
if (index != -1 && m_qmlServerPort.isValid())
|
|
|
|
|
res.replace(qmlPortRe.cap(1), QString::number(m_qmlServerPort.number()));
|
|
|
|
|
appendMessage(output, StdOutFormat);
|
|
|
|
|
appOutput(res);
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosRunner::handleErrorMsg(IosToolHandler *handler, const QString &msg)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(handler);
|
2014-03-24 10:53:26 +01:00
|
|
|
QString res(msg);
|
2017-05-19 16:59:02 +02:00
|
|
|
QString lockedErr ="Unexpected reply: ELocked (454c6f636b6564) vs OK (4f4b)";
|
|
|
|
|
if (msg.contains("AMDeviceStartService returned -402653150")) {
|
2013-11-04 22:45:52 +01:00
|
|
|
TaskHub::addTask(Task::Warning,
|
|
|
|
|
tr("Run failed. The settings in the Organizer window of Xcode might be incorrect."),
|
|
|
|
|
ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
|
2014-06-24 14:16:30 +02:00
|
|
|
} else if (res.contains(lockedErr)) {
|
2014-03-24 10:53:26 +01:00
|
|
|
QString message = tr("The device is locked, please unlock.");
|
|
|
|
|
TaskHub::addTask(Task::Error, message,
|
2013-11-04 22:45:52 +01:00
|
|
|
ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
|
2014-06-24 14:16:30 +02:00
|
|
|
res.replace(lockedErr, message);
|
2014-03-24 10:53:26 +01:00
|
|
|
}
|
2017-05-19 16:59:02 +02:00
|
|
|
QRegExp qmlPortRe("QML Debugger: Waiting for connection on port ([0-9]+)...");
|
2014-02-25 22:48:19 +01:00
|
|
|
int index = qmlPortRe.indexIn(msg);
|
2017-05-19 16:59:02 +02:00
|
|
|
if (index != -1 && m_qmlServerPort.isValid())
|
|
|
|
|
res.replace(qmlPortRe.cap(1), QString::number(m_qmlServerPort.number()));
|
|
|
|
|
|
|
|
|
|
appendMessage(res, StdErrFormat);
|
|
|
|
|
errorMsg(res);
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosRunner::handleToolExited(IosToolHandler *handler, int code)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(handler);
|
|
|
|
|
m_cleanExit = (code == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosRunner::handleFinished(IosToolHandler *handler)
|
|
|
|
|
{
|
|
|
|
|
if (m_toolHandler == handler) {
|
2017-05-19 16:59:02 +02:00
|
|
|
if (m_cleanExit)
|
|
|
|
|
appendMessage(tr("Run ended."), NormalMessageFormat);
|
|
|
|
|
else
|
|
|
|
|
appendMessage(tr("Run ended with error."), ErrorMessageFormat);
|
|
|
|
|
m_toolHandler = nullptr;
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
handler->deleteLater();
|
2017-05-19 16:59:02 +02:00
|
|
|
reportStopped();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qint64 IosRunner::pid() const
|
|
|
|
|
{
|
|
|
|
|
return m_pid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IosRunner::isAppRunning() const
|
|
|
|
|
{
|
|
|
|
|
return m_toolHandler && m_toolHandler->isRunning();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::Port IosRunner::gdbServerPort() const
|
|
|
|
|
{
|
|
|
|
|
return m_gdbServerPort;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::Port IosRunner::qmlServerPort() const
|
|
|
|
|
{
|
|
|
|
|
return m_qmlServerPort;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// IosRunner
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
IosRunSupport::IosRunSupport(RunControl *runControl)
|
|
|
|
|
: IosRunner(runControl)
|
|
|
|
|
{
|
|
|
|
|
runControl->setIcon(Icons::RUN_SMALL_TOOLBAR);
|
|
|
|
|
QString displayName = QString("Run on %1").arg(device().isNull() ? QString() : device()->displayName());
|
|
|
|
|
runControl->setDisplayName(displayName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IosRunSupport::~IosRunSupport()
|
|
|
|
|
{
|
|
|
|
|
stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosRunSupport::start()
|
|
|
|
|
{
|
|
|
|
|
appendMessage(tr("Starting remote process."), NormalMessageFormat);
|
|
|
|
|
IosRunner::start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosRunSupport::stop()
|
|
|
|
|
{
|
|
|
|
|
IosRunner::stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
2017-06-14 14:01:16 +02:00
|
|
|
// IosQmlProfilerSupport
|
2017-05-19 16:59:02 +02:00
|
|
|
//
|
|
|
|
|
|
2017-06-14 14:01:16 +02:00
|
|
|
IosQmlProfilerSupport::IosQmlProfilerSupport(RunControl *runControl)
|
|
|
|
|
: RunWorker(runControl)
|
2017-05-19 16:59:02 +02:00
|
|
|
{
|
|
|
|
|
setDisplayName("IosAnalyzeSupport");
|
|
|
|
|
|
|
|
|
|
auto iosRunConfig = qobject_cast<IosRunConfiguration *>(runControl->runConfiguration());
|
|
|
|
|
StandardRunnable runnable;
|
|
|
|
|
runnable.executable = iosRunConfig->localExecutable().toUserOutput();
|
|
|
|
|
runnable.commandLineArguments = iosRunConfig->commandLineArguments();
|
|
|
|
|
runControl->setDisplayName(iosRunConfig->applicationName());
|
2017-06-14 14:01:16 +02:00
|
|
|
runControl->setRunnable(runnable);
|
2017-05-19 16:59:02 +02:00
|
|
|
|
2017-06-14 14:01:16 +02:00
|
|
|
m_runner = new IosRunner(runControl);
|
|
|
|
|
m_runner->setQmlDebugging(QmlDebug::QmlProfilerServices);
|
2017-08-08 14:09:50 +02:00
|
|
|
addStartDependency(m_runner);
|
2017-05-19 16:59:02 +02:00
|
|
|
|
2017-06-14 14:01:16 +02:00
|
|
|
m_profiler = runControl->createWorker(runControl->runMode());
|
2017-08-08 14:09:50 +02:00
|
|
|
m_profiler->addStartDependency(this);
|
2017-05-19 16:59:02 +02:00
|
|
|
}
|
|
|
|
|
|
2017-06-14 14:01:16 +02:00
|
|
|
void IosQmlProfilerSupport::start()
|
2017-05-19 16:59:02 +02:00
|
|
|
{
|
2017-06-29 18:32:01 +02:00
|
|
|
QUrl serverUrl;
|
2017-06-14 14:01:16 +02:00
|
|
|
QTcpServer server;
|
|
|
|
|
QTC_ASSERT(server.listen(QHostAddress::LocalHost)
|
|
|
|
|
|| server.listen(QHostAddress::LocalHostIPv6), return);
|
|
|
|
|
serverUrl.setHost(server.serverAddress().toString());
|
2017-05-19 16:59:02 +02:00
|
|
|
|
2017-06-14 14:01:16 +02:00
|
|
|
Port qmlPort = m_runner->qmlServerPort();
|
|
|
|
|
serverUrl.setPort(qmlPort.number());
|
|
|
|
|
m_profiler->recordData("QmlServerUrl", serverUrl);
|
|
|
|
|
if (qmlPort.isValid())
|
|
|
|
|
reportStarted();
|
|
|
|
|
else
|
|
|
|
|
reportFailure(tr("Could not get necessary ports for the profiler connection."));
|
2017-05-19 16:59:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// IosDebugSupport
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
IosDebugSupport::IosDebugSupport(RunControl *runControl)
|
|
|
|
|
: Debugger::DebuggerRunTool(runControl)
|
|
|
|
|
{
|
|
|
|
|
m_runner = new IosRunner(runControl);
|
|
|
|
|
m_runner->setCppDebugging(isCppDebugging());
|
|
|
|
|
m_runner->setQmlDebugging(isQmlDebugging() ? QmlDebug::QmlDebuggerServices : QmlDebug::NoQmlDebugServices);
|
|
|
|
|
|
2017-08-08 14:09:50 +02:00
|
|
|
addStartDependency(m_runner);
|
2017-05-19 16:59:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IosDebugSupport::start()
|
|
|
|
|
{
|
2017-06-13 08:49:18 +02:00
|
|
|
if (!m_runner->isAppRunning()) {
|
|
|
|
|
reportFailure(tr("Application not running."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-19 16:59:02 +02:00
|
|
|
RunConfiguration *runConfig = runControl()->runConfiguration();
|
|
|
|
|
|
|
|
|
|
if (device()->type() == Ios::Constants::IOS_DEVICE_TYPE) {
|
|
|
|
|
IosDevice::ConstPtr dev = device().dynamicCast<const IosDevice>();
|
2017-08-24 17:38:06 +02:00
|
|
|
setStartMode(AttachToRemoteProcess);
|
|
|
|
|
setIosPlatform("remote-ios");
|
2017-05-19 16:59:02 +02:00
|
|
|
QString osVersion = dev->osVersion();
|
|
|
|
|
FileName deviceSdk1 = FileName::fromString(QDir::homePath()
|
|
|
|
|
+ "/Library/Developer/Xcode/iOS DeviceSupport/"
|
|
|
|
|
+ osVersion + "/Symbols");
|
|
|
|
|
QString deviceSdk;
|
|
|
|
|
if (deviceSdk1.toFileInfo().isDir()) {
|
|
|
|
|
deviceSdk = deviceSdk1.toString();
|
|
|
|
|
} else {
|
|
|
|
|
FileName deviceSdk2 = IosConfigurations::developerPath()
|
|
|
|
|
.appendPath("Platforms/iPhoneOS.platform/DeviceSupport/")
|
|
|
|
|
.appendPath(osVersion).appendPath("Symbols");
|
|
|
|
|
if (deviceSdk2.toFileInfo().isDir()) {
|
|
|
|
|
deviceSdk = deviceSdk2.toString();
|
|
|
|
|
} else {
|
|
|
|
|
TaskHub::addTask(Task::Warning, tr(
|
|
|
|
|
"Could not find device specific debug symbols at %1. "
|
|
|
|
|
"Debugging initialization will be slow until you open the Organizer window of "
|
|
|
|
|
"Xcode with the device connected to have the symbols generated.")
|
|
|
|
|
.arg(deviceSdk1.toUserOutput()),
|
|
|
|
|
ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-24 17:38:06 +02:00
|
|
|
setDeviceSymbolsRoot(deviceSdk);
|
2017-05-19 16:59:02 +02:00
|
|
|
} else {
|
2017-08-24 17:38:06 +02:00
|
|
|
setStartMode(AttachExternal);
|
|
|
|
|
setIosPlatform("ios-simulator");
|
2017-05-19 16:59:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto iosRunConfig = qobject_cast<IosRunConfiguration *>(runConfig);
|
2017-08-24 17:38:06 +02:00
|
|
|
setRunControlName(iosRunConfig->applicationName());
|
|
|
|
|
setContinueAfterAttach(true);
|
2017-05-19 16:59:02 +02:00
|
|
|
|
|
|
|
|
Utils::Port gdbServerPort = m_runner->gdbServerPort();
|
|
|
|
|
Utils::Port qmlServerPort = m_runner->qmlServerPort();
|
2017-08-24 17:38:06 +02:00
|
|
|
setAttachPid(ProcessHandle(m_runner->pid()));
|
2017-05-19 16:59:02 +02:00
|
|
|
|
|
|
|
|
const bool cppDebug = isCppDebugging();
|
|
|
|
|
const bool qmlDebug = isQmlDebugging();
|
|
|
|
|
if (cppDebug) {
|
2017-08-24 17:38:06 +02:00
|
|
|
setInferiorExecutable(iosRunConfig->localExecutable().toString());
|
|
|
|
|
setRemoteChannel("connect://localhost:" + gdbServerPort.toString());
|
2017-05-19 16:59:02 +02:00
|
|
|
|
|
|
|
|
FileName xcodeInfo = IosConfigurations::developerPath().parentDir().appendPath("Info.plist");
|
|
|
|
|
bool buggyLldb = false;
|
|
|
|
|
if (xcodeInfo.exists()) {
|
|
|
|
|
QSettings settings(xcodeInfo.toString(), QSettings::NativeFormat);
|
|
|
|
|
QStringList version = settings.value(QLatin1String("CFBundleShortVersionString")).toString()
|
|
|
|
|
.split('.');
|
|
|
|
|
if (version.value(0).toInt() == 5 && version.value(1, QString::number(1)).toInt() == 0)
|
|
|
|
|
buggyLldb = true;
|
|
|
|
|
}
|
|
|
|
|
QString bundlePath = iosRunConfig->bundleDirectory().toString();
|
|
|
|
|
bundlePath.chop(4);
|
|
|
|
|
FileName dsymPath = FileName::fromString(bundlePath.append(".dSYM"));
|
|
|
|
|
if (!dsymPath.exists()) {
|
|
|
|
|
if (buggyLldb)
|
|
|
|
|
TaskHub::addTask(Task::Warning,
|
|
|
|
|
tr("Debugging with Xcode 5.0.x can be unreliable without a dSYM. "
|
|
|
|
|
"To create one, add a dsymutil deploystep."),
|
|
|
|
|
ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
|
|
|
|
|
} else if (dsymPath.toFileInfo().lastModified()
|
|
|
|
|
< QFileInfo(iosRunConfig->localExecutable().toUserOutput()).lastModified()) {
|
|
|
|
|
TaskHub::addTask(Task::Warning,
|
|
|
|
|
tr("The dSYM %1 seems to be outdated, it might confuse the debugger.")
|
|
|
|
|
.arg(dsymPath.toUserOutput()),
|
|
|
|
|
ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-24 17:38:06 +02:00
|
|
|
QUrl qmlServer;
|
2017-05-19 16:59:02 +02:00
|
|
|
if (qmlDebug) {
|
|
|
|
|
QTcpServer server;
|
|
|
|
|
QTC_ASSERT(server.listen(QHostAddress::LocalHost)
|
|
|
|
|
|| server.listen(QHostAddress::LocalHostIPv6), return);
|
2017-08-24 17:38:06 +02:00
|
|
|
qmlServer.setHost(server.serverAddress().toString());
|
2017-05-19 16:59:02 +02:00
|
|
|
if (!cppDebug)
|
2017-08-24 17:38:06 +02:00
|
|
|
setStartMode(AttachToRemoteServer);
|
2017-05-19 16:59:02 +02:00
|
|
|
}
|
|
|
|
|
|
2017-08-24 17:38:06 +02:00
|
|
|
if (qmlServerPort.isValid())
|
|
|
|
|
qmlServer.setPort(qmlServerPort.number());
|
2017-05-19 16:59:02 +02:00
|
|
|
|
2017-08-24 17:38:06 +02:00
|
|
|
setQmlServer(qmlServer);
|
2017-05-19 16:59:02 +02:00
|
|
|
|
|
|
|
|
DebuggerRunTool::start();
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2013-10-16 11:02:37 +02:00
|
|
|
} // namespace Ios
|