2011-06-27 17:18:55 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2011-06-27 17:18:55 +02:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2011-06-27 17:18:55 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-07-06 15:48:52 +00:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2011-06-27 17:18:55 +02:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-07-06 15:48:52 +00:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2011-06-27 17:18:55 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-07-06 15:48:52 +00:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2011-06-27 17:18:55 +02:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2011-06-27 17:18:55 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "remotelinuxqmlprofilerrunner.h"
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2011-08-02 12:20:16 +02:00
|
|
|
#include <remotelinux/portlist.h>
|
2011-06-27 17:18:55 +02:00
|
|
|
#include <remotelinux/remotelinuxapplicationrunner.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
using namespace ExtensionSystem;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace QmlProfiler::Internal;
|
|
|
|
|
using namespace RemoteLinux;
|
|
|
|
|
|
|
|
|
|
RemoteLinuxQmlProfilerRunner::RemoteLinuxQmlProfilerRunner(
|
|
|
|
|
RemoteLinuxRunConfiguration *runConfiguration, QObject *parent)
|
|
|
|
|
: AbstractQmlProfilerRunner(parent)
|
|
|
|
|
, m_port(-1)
|
|
|
|
|
, m_runControl(0)
|
|
|
|
|
{
|
|
|
|
|
// find run control factory
|
|
|
|
|
IRunControlFactory *runControlFactory = 0;
|
|
|
|
|
QList<IRunControlFactory*> runControlFactories
|
|
|
|
|
= PluginManager::instance()->getObjects<IRunControlFactory>();
|
|
|
|
|
|
|
|
|
|
foreach (IRunControlFactory *factory, runControlFactories) {
|
2012-01-10 19:17:24 +01:00
|
|
|
if (factory->canRun(runConfiguration, NormalRunMode)) {
|
2011-06-27 17:18:55 +02:00
|
|
|
runControlFactory = factory;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QTC_ASSERT(runControlFactory, return);
|
|
|
|
|
|
|
|
|
|
// create run control
|
2012-01-10 19:17:24 +01:00
|
|
|
RunControl *runControl = runControlFactory->create(runConfiguration, NormalRunMode);
|
2011-06-27 17:18:55 +02:00
|
|
|
|
|
|
|
|
m_runControl = qobject_cast<AbstractRemoteLinuxRunControl*>(runControl);
|
|
|
|
|
QTC_ASSERT(m_runControl, return);
|
|
|
|
|
|
|
|
|
|
connect(runner(), SIGNAL(readyForExecution()), this, SLOT(getPorts()));
|
|
|
|
|
connect(runner(), SIGNAL(error(QString)), this, SLOT(handleError(QString)));
|
|
|
|
|
connect(runner(), SIGNAL(remoteErrorOutput(QByteArray)), this, SLOT(handleStdErr(QByteArray)));
|
|
|
|
|
connect(runner(), SIGNAL(remoteOutput(QByteArray)), this, SLOT(handleStdOut(QByteArray)));
|
|
|
|
|
|
|
|
|
|
connect(runner(), SIGNAL(remoteProcessStarted()), this, SLOT(handleRemoteProcessStarted()));
|
|
|
|
|
connect(runner(), SIGNAL(remoteProcessFinished(qint64)),
|
|
|
|
|
this, SLOT(handleRemoteProcessFinished(qint64)));
|
|
|
|
|
connect(runner(), SIGNAL(reportProgress(QString)), this, SLOT(handleProgressReport(QString)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RemoteLinuxQmlProfilerRunner::~RemoteLinuxQmlProfilerRunner()
|
|
|
|
|
{
|
|
|
|
|
delete m_runControl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RemoteLinuxQmlProfilerRunner::start()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(runner(), return);
|
|
|
|
|
runner()->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RemoteLinuxQmlProfilerRunner::stop()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(runner(), return);
|
|
|
|
|
runner()->stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int RemoteLinuxQmlProfilerRunner::debugPort() const
|
|
|
|
|
{
|
|
|
|
|
return m_port;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RemoteLinuxQmlProfilerRunner::getPorts()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(runner(), return);
|
|
|
|
|
m_port = runner()->freePorts()->getNext();
|
|
|
|
|
if (m_port == -1) {
|
|
|
|
|
emit appendMessage(tr("Not enough free ports on device for analyzing.\n"),
|
|
|
|
|
Utils::ErrorMessageFormat);
|
|
|
|
|
runner()->stop();
|
|
|
|
|
} else {
|
|
|
|
|
emit appendMessage(tr("Starting remote process ...\n"), Utils::NormalMessageFormat);
|
|
|
|
|
|
|
|
|
|
QString arguments = runner()->arguments();
|
|
|
|
|
if (!arguments.isEmpty())
|
|
|
|
|
arguments.append(QLatin1Char(' '));
|
2012-01-30 16:39:10 +02:00
|
|
|
arguments.append(QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(m_port));
|
2011-06-27 17:18:55 +02:00
|
|
|
|
2012-01-30 16:39:10 +02:00
|
|
|
runner()->startExecution(QString::fromLatin1("%1 %2 %3")
|
2011-06-27 17:18:55 +02:00
|
|
|
.arg(runner()->commandPrefix())
|
|
|
|
|
.arg(runner()->remoteExecutable())
|
|
|
|
|
.arg(arguments).toUtf8());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RemoteLinuxQmlProfilerRunner::handleError(const QString &msg)
|
|
|
|
|
{
|
|
|
|
|
emit appendMessage(msg + QLatin1Char('\n'), Utils::ErrorMessageFormat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RemoteLinuxQmlProfilerRunner::handleStdErr(const QByteArray &msg)
|
|
|
|
|
{
|
|
|
|
|
emit appendMessage(QString::fromUtf8(msg), Utils::StdErrFormat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RemoteLinuxQmlProfilerRunner::handleStdOut(const QByteArray &msg)
|
|
|
|
|
{
|
|
|
|
|
emit appendMessage(QString::fromUtf8(msg), Utils::StdOutFormat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RemoteLinuxQmlProfilerRunner::handleRemoteProcessStarted()
|
|
|
|
|
{
|
|
|
|
|
emit started();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RemoteLinuxQmlProfilerRunner::handleRemoteProcessFinished(qint64 exitCode)
|
|
|
|
|
{
|
2011-07-19 14:30:06 +02:00
|
|
|
if (exitCode != AbstractRemoteLinuxApplicationRunner::InvalidExitCode) {
|
2011-06-27 17:18:55 +02:00
|
|
|
appendMessage(tr("Finished running remote process. Exit code was %1.\n")
|
|
|
|
|
.arg(exitCode), Utils::NormalMessageFormat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emit stopped();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RemoteLinuxQmlProfilerRunner::handleProgressReport(const QString &progressString)
|
|
|
|
|
{
|
|
|
|
|
appendMessage(progressString + QLatin1Char('\n'), Utils::NormalMessageFormat);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-19 14:30:06 +02:00
|
|
|
AbstractRemoteLinuxApplicationRunner *RemoteLinuxQmlProfilerRunner::runner() const
|
2011-06-27 17:18:55 +02:00
|
|
|
{
|
|
|
|
|
if (!m_runControl)
|
|
|
|
|
return 0;
|
|
|
|
|
return m_runControl->runner();
|
|
|
|
|
}
|
|
|
|
|
|