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
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
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
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
#include "remotelinuxqmlprofilerrunner.h"
|
2012-07-26 09:02:34 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/devicesupport/deviceapplicationrunner.h>
|
|
|
|
|
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
|
|
|
|
|
#include <projectexplorer/profileinformation.h>
|
2011-06-27 17:18:55 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2012-07-26 09:02:34 +02:00
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
#include <remotelinux/remotelinuxrunconfiguration.h>
|
|
|
|
|
#include <remotelinux/remotelinuxutils.h>
|
2012-02-28 10:34:50 +01:00
|
|
|
#include <utils/portlist.h>
|
2011-06-27 17:18:55 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace QmlProfiler::Internal;
|
|
|
|
|
using namespace RemoteLinux;
|
|
|
|
|
|
|
|
|
|
RemoteLinuxQmlProfilerRunner::RemoteLinuxQmlProfilerRunner(
|
|
|
|
|
RemoteLinuxRunConfiguration *runConfiguration, QObject *parent)
|
|
|
|
|
: AbstractQmlProfilerRunner(parent)
|
2012-07-26 09:02:34 +02:00
|
|
|
, m_portsGatherer(new DeviceUsedPortsGatherer(this))
|
|
|
|
|
, m_runner(new DeviceApplicationRunner(this))
|
|
|
|
|
, m_device(DeviceProfileInformation::device(runConfiguration->target()->profile()))
|
|
|
|
|
, m_remoteExecutable(runConfiguration->remoteExecutableFilePath())
|
|
|
|
|
, m_arguments(runConfiguration->arguments())
|
|
|
|
|
, m_commandPrefix(runConfiguration->commandPrefix())
|
2012-02-28 11:15:51 +01:00
|
|
|
, m_port(0)
|
2011-06-27 17:18:55 +02:00
|
|
|
{
|
2012-07-26 09:02:34 +02:00
|
|
|
connect(m_runner, SIGNAL(reportError(QString)), this, SLOT(handleError(QString)));
|
|
|
|
|
connect(m_runner, SIGNAL(remoteStderr(QByteArray)), this, SLOT(handleStdErr(QByteArray)));
|
|
|
|
|
connect(m_runner, SIGNAL(remoteStdout(QByteArray)), this, SLOT(handleStdOut(QByteArray)));
|
|
|
|
|
connect(m_runner, SIGNAL(finished(bool)), SLOT(handleRemoteProcessFinished(bool)));
|
|
|
|
|
connect(m_runner, SIGNAL(reportProgress(QString)), this, SLOT(handleProgressReport(QString)));
|
|
|
|
|
connect(m_portsGatherer, SIGNAL(error(QString)), SLOT(handlePortsGathererError(QString)));
|
|
|
|
|
connect(m_portsGatherer, SIGNAL(portListReady()), SLOT(handlePortListReady()));
|
2011-06-27 17:18:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RemoteLinuxQmlProfilerRunner::~RemoteLinuxQmlProfilerRunner()
|
|
|
|
|
{
|
2012-07-26 09:02:34 +02:00
|
|
|
stop();
|
2011-06-27 17:18:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RemoteLinuxQmlProfilerRunner::start()
|
|
|
|
|
{
|
2012-07-26 09:02:34 +02:00
|
|
|
QTC_ASSERT(m_port == 0, return);
|
|
|
|
|
|
|
|
|
|
m_portsGatherer->start(m_device);
|
|
|
|
|
emit started();
|
2011-06-27 17:18:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RemoteLinuxQmlProfilerRunner::stop()
|
|
|
|
|
{
|
2012-07-26 09:02:34 +02:00
|
|
|
if (m_port == 0)
|
|
|
|
|
m_portsGatherer->stop();
|
|
|
|
|
else
|
|
|
|
|
m_runner->stop(RemoteLinuxUtils::killApplicationCommandLine(m_remoteExecutable).toUtf8());
|
|
|
|
|
m_port = 0;
|
2011-06-27 17:18:55 +02:00
|
|
|
}
|
|
|
|
|
|
2012-02-28 11:15:51 +01:00
|
|
|
quint16 RemoteLinuxQmlProfilerRunner::debugPort() const
|
2011-06-27 17:18:55 +02:00
|
|
|
{
|
|
|
|
|
return m_port;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-26 09:02:34 +02:00
|
|
|
void RemoteLinuxQmlProfilerRunner::handlePortsGathererError(const QString &message)
|
|
|
|
|
{
|
|
|
|
|
emit appendMessage(tr("Gathering ports failed: %1").arg(message), Utils::ErrorMessageFormat);
|
|
|
|
|
m_port = 0;
|
|
|
|
|
emit stopped();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RemoteLinuxQmlProfilerRunner::handlePortListReady()
|
|
|
|
|
{
|
|
|
|
|
getPorts();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-27 17:18:55 +02:00
|
|
|
void RemoteLinuxQmlProfilerRunner::getPorts()
|
|
|
|
|
{
|
2012-07-26 09:02:34 +02:00
|
|
|
Utils::PortList portList = m_device->freePorts();
|
|
|
|
|
m_port = m_portsGatherer->getNextFreePort(&portList);
|
|
|
|
|
|
|
|
|
|
if (m_port == -1) {
|
2011-06-27 17:18:55 +02:00
|
|
|
emit appendMessage(tr("Not enough free ports on device for analyzing.\n"),
|
|
|
|
|
Utils::ErrorMessageFormat);
|
2012-07-26 09:02:34 +02:00
|
|
|
m_port = 0;
|
|
|
|
|
emit stopped();
|
2011-06-27 17:18:55 +02:00
|
|
|
} else {
|
|
|
|
|
emit appendMessage(tr("Starting remote process ...\n"), Utils::NormalMessageFormat);
|
2012-07-26 09:02:34 +02:00
|
|
|
QString arguments = m_arguments;
|
2011-06-27 17:18:55 +02:00
|
|
|
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));
|
2012-07-26 09:02:34 +02:00
|
|
|
const QString commandLine = QString::fromLatin1("%1 %2 %3")
|
|
|
|
|
.arg(m_commandPrefix, m_remoteExecutable, arguments);
|
|
|
|
|
m_runner->start(m_device, commandLine.toUtf8());
|
2011-06-27 17:18:55 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-26 09:02:34 +02:00
|
|
|
void RemoteLinuxQmlProfilerRunner::handleRemoteProcessFinished(bool success)
|
2011-06-27 17:18:55 +02:00
|
|
|
{
|
2012-07-26 09:02:34 +02:00
|
|
|
if (!success)
|
|
|
|
|
appendMessage(tr("Failure running remote process."), Utils::NormalMessageFormat);
|
|
|
|
|
m_port = 0;
|
2011-06-27 17:18:55 +02:00
|
|
|
emit stopped();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RemoteLinuxQmlProfilerRunner::handleProgressReport(const QString &progressString)
|
|
|
|
|
{
|
|
|
|
|
appendMessage(progressString + QLatin1Char('\n'), Utils::NormalMessageFormat);
|
|
|
|
|
}
|