/**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing ** ** 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 ** a written agreement between you and The Qt Company. For licensing terms and ** conditions see http://www.qt.io/terms-conditions. For further information ** use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** 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. ** ** In addition, as a special exception, The Qt Company gives you certain additional ** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "iosanalyzesupport.h" #include "iosrunner.h" #include "iosmanager.h" #include "iosdevice.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef Q_OS_UNIX #include #else #include #endif using namespace Analyzer; using namespace ProjectExplorer; namespace Ios { namespace Internal { RunControl *IosAnalyzeSupport::createAnalyzeRunControl(IosRunConfiguration *runConfig, QString *errorMessage) { Q_UNUSED(errorMessage); Target *target = runConfig->target(); if (!target) return 0; IDevice::ConstPtr device = DeviceKitInformation::device(target->kit()); if (device.isNull()) return 0; AnalyzerStartParameters params; params.debuggee = runConfig->localExecutable().toUserOutput(); params.debuggeeArgs = Utils::QtcProcess::joinArgs(runConfig->commandLineArguments()); params.analyzerHost = QLatin1String("localhost"); if (device->type() == Core::Id(Ios::Constants::IOS_DEVICE_TYPE)) { IosDevice::ConstPtr iosDevice = device.dynamicCast(); if (iosDevice.isNull()) return 0; } AnalyzerRunControl *analyzerRunControl = AnalyzerManager::createRunControl(params, runConfig, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); if (analyzerRunControl) analyzerRunControl->setDisplayName(runConfig->applicationName()); (void) new IosAnalyzeSupport(runConfig, analyzerRunControl, false, true); return analyzerRunControl; } IosAnalyzeSupport::IosAnalyzeSupport(IosRunConfiguration *runConfig, AnalyzerRunControl *runControl, bool cppDebug, bool qmlDebug) : QObject(runControl), m_runControl(runControl), m_runner(new IosRunner(this, runConfig, cppDebug, qmlDebug ? QmlDebug::QmlProfilerServices : QmlDebug::NoQmlDebugServices)) { connect(m_runControl, &AnalyzerRunControl::starting, m_runner, &IosRunner::start); connect(m_runControl, &RunControl::finished, m_runner, &IosRunner::stop); connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort, this, &IosAnalyzeSupport::qmlServerReady); connect(m_runner, &IosRunner::gotServerPorts, this, &IosAnalyzeSupport::handleServerPorts); connect(m_runner, &IosRunner::gotInferiorPid, this, &IosAnalyzeSupport::handleGotInferiorPid); connect(m_runner, &IosRunner::finished, this, &IosAnalyzeSupport::handleRemoteProcessFinished); connect(m_runner, &IosRunner::errorMsg, this, &IosAnalyzeSupport::handleRemoteErrorOutput); connect(m_runner, &IosRunner::appOutput, this, &IosAnalyzeSupport::handleRemoteOutput); } IosAnalyzeSupport::~IosAnalyzeSupport() { } void IosAnalyzeSupport::qmlServerReady() { m_runControl->notifyRemoteSetupDone(m_qmlPort); } void IosAnalyzeSupport::handleServerPorts(int gdbServerPort, int qmlPort) { Q_UNUSED(gdbServerPort); m_qmlPort = qmlPort; } void IosAnalyzeSupport::handleGotInferiorPid(qint64 pid, int qmlPort) { Q_UNUSED(pid); m_qmlPort = qmlPort; } void IosAnalyzeSupport::handleRemoteProcessFinished(bool cleanEnd) { if (m_runControl) { if (!cleanEnd) m_runControl->logApplicationMessage(tr("Run ended with error."), Utils::ErrorMessageFormat); else m_runControl->logApplicationMessage(tr("Run ended."), Utils::NormalMessageFormat); m_runControl->notifyRemoteFinished(); } } void IosAnalyzeSupport::handleRemoteOutput(const QString &output) { if (m_runControl) { m_runControl->logApplicationMessage(output, Utils::StdOutFormat); m_outputParser.processOutput(output); } } void IosAnalyzeSupport::handleRemoteErrorOutput(const QString &output) { if (m_runControl) m_runControl->logApplicationMessage(output, Utils::StdErrFormat); } } // namespace Internal } // namespace Ios