Commit 057361dc authored by hjk's avatar hjk

RemoteLinux: Re-enable QmlProfiler

Change-Id: Ifc943c785f94dcd11fae74acdd8c1bf96712ca35
Reviewed-by: Christian Kandeler's avatarChristian Kandeler <christian.kandeler@qt.io>
parent aedcccd7
......@@ -1193,14 +1193,14 @@ SimpleTargetRunner::SimpleTargetRunner(RunControl *runControl)
: RunWorker(runControl)
{
setDisplayName("SimpleTargetRunner");
m_runnable = runControl->runnable();
}
void SimpleTargetRunner::start()
{
m_launcher.disconnect(this);
Runnable r = runControl()->runnable();
QString msg = RunControl::tr("Starting %1...").arg(r.displayName());
QString msg = RunControl::tr("Starting %1...").arg(m_runnable.displayName());
appendMessage(msg, Utils::NormalMessageFormat);
if (isSynchronousLauncher(runControl())) {
......@@ -1214,15 +1214,15 @@ void SimpleTargetRunner::start()
connect(&m_launcher, &ApplicationLauncher::error,
this, &SimpleTargetRunner::onProcessError);
QTC_ASSERT(r.is<StandardRunnable>(), return);
const QString executable = r.as<StandardRunnable>().executable;
QTC_ASSERT(m_runnable.is<StandardRunnable>(), return);
const QString executable = m_runnable.as<StandardRunnable>().executable;
if (executable.isEmpty()) {
reportFailure(RunControl::tr("No executable specified."));
} else if (!QFileInfo::exists(executable)) {
reportFailure(RunControl::tr("Executable %1 does not exist.")
.arg(QDir::toNativeSeparators(executable)));
} else {
m_launcher.start(r);
m_launcher.start(m_runnable);
}
} else {
......@@ -1270,7 +1270,7 @@ void SimpleTargetRunner::start()
appendMessage(progressString, Utils::NormalMessageFormat);
});
m_launcher.start(r, runControl()->device());
m_launcher.start(m_runnable, device());
}
}
......@@ -1294,17 +1294,22 @@ void SimpleTargetRunner::onProcessFinished(int exitCode, QProcess::ExitStatus st
msg = tr("%1 crashed.");
else
msg = tr("%2 exited with code %1").arg(exitCode);
appendMessage(msg.arg(runnable().displayName()), Utils::NormalMessageFormat);
appendMessage(msg.arg(m_runnable.displayName()), Utils::NormalMessageFormat);
reportStopped();
}
void SimpleTargetRunner::onProcessError(QProcess::ProcessError)
{
QString msg = tr("%1 finished.");
appendMessage(msg.arg(runnable().displayName()), Utils::NormalMessageFormat);
appendMessage(msg.arg(m_runnable.displayName()), Utils::NormalMessageFormat);
reportStopped();
}
void SimpleTargetRunner::setRunnable(const Runnable &runnable)
{
m_runnable = runnable;
}
// RunWorkerPrivate
RunWorkerPrivate::RunWorkerPrivate(RunWorker *runWorker, RunControl *runControl)
......@@ -1456,7 +1461,7 @@ void RunWorker::recordData(const QString &channel, const QVariant &data)
d->data[channel] = data;
}
QVariant RunWorker::recordedData(const QString &channel)
QVariant RunWorker::recordedData(const QString &channel) const
{
return d->data[channel];
}
......
......@@ -375,7 +375,7 @@ public:
void reportData(int channel, const QVariant &data);
void recordData(const QString &channel, const QVariant &data);
QVariant recordedData(const QString &channel);
QVariant recordedData(const QString &channel) const;
// Part of read-only interface of RunControl for convenience.
void appendMessage(const QString &msg, Utils::OutputFormat format);
......@@ -524,6 +524,8 @@ class PROJECTEXPLORER_EXPORT SimpleTargetRunner : public RunWorker
public:
explicit SimpleTargetRunner(RunControl *runControl);
void setRunnable(const Runnable &runnable);
protected:
void start() override;
void stop() override;
......@@ -534,6 +536,7 @@ private:
void onProcessError(QProcess::ProcessError error);
ApplicationLauncher m_launcher;
Runnable m_runnable;
};
} // namespace ProjectExplorer
///****************************************************************************
//**
//** Copyright (C) 2016 The Qt Company Ltd.
//** Contact: https://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 https://www.qt.io/terms-conditions. For further
//** information use the contact form at https://www.qt.io/contact-us.
//**
//** 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.
//**
//****************************************************************************/
//#include "remotelinuxanalyzesupport.h"
//#include "remotelinuxrunconfiguration.h"
//#include <projectexplorer/buildconfiguration.h>
//#include <projectexplorer/project.h>
//#include <projectexplorer/target.h>
//#include <projectexplorer/toolchain.h>
//#include <projectexplorer/kitinformation.h>
//#include <projectexplorer/runnables.h>
//#include <utils/qtcassert.h>
//#include <utils/qtcprocess.h>
//#include <qmldebug/qmloutputparser.h>
//#include <qmldebug/qmldebugcommandlinearguments.h>
//#include <QPointer>
//using namespace QSsh;
//using namespace ProjectExplorer;
//using namespace Utils;
//namespace RemoteLinux {
//namespace Internal {
//const char RemoteLinuxAnalyzeSupportWorkerId[] = "RemoteLinux.AnalyzeSupportWorker";
//class RemoteLinuxAnalyzeSupportPrivate
//{
//public:
// RemoteLinuxAnalyzeSupportPrivate(RunControl *runControl)
// {
// bool isPerf = runControl->runMode() == ProjectExplorer::Constants::PERFPROFILER_RUN_MODE;
// needFifo = isPerf;
// if (needFifo) {
// RunConfiguration *runConfiguration = runControl->runConfiguration();
// QTC_ASSERT(runConfiguration, return);
// IRunConfigurationAspect *perfAspect =
// runConfiguration->extraAspect("Analyzer.Perf.Settings");
// QTC_ASSERT(perfAspect, return);
// perfRecordArguments =
// perfAspect->currentSettings()->property("perfRecordArguments").toStringList()
// .join(' ');
// }
// }
// Utils::Port qmlPort;
// QString remoteFifo;
// QString perfRecordArguments;
// ApplicationLauncher outputGatherer;
// QmlDebug::QmlOutputParser outputParser;
// bool needFifo = false;
// bool needPort = false;
//};
//} // namespace Internal
//using namespace Internal;
//RemoteLinuxAnalyzeSupport::RemoteLinuxAnalyzeSupport(RunControl *runControl)
// : ToolRunner(runControl),
// d(new RemoteLinuxAnalyzeSupportPrivate(runControl))
//{
// setId(RemoteLinuxAnalyzeSupportWorkerId);
// connect(&d->outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,
// this, &RemoteLinuxAnalyzeSupport::remoteIsRunning);
// if (d->needFifo)
// addDependency(FifoCreatorWorkerId);
// if (d->needPort)
// addDependency(PortsGathererWorkerId);
//}
//RemoteLinuxAnalyzeSupport::~RemoteLinuxAnalyzeSupport()
//{
// delete d;
//}
////void RemoteLinuxAnalyzeSupport::showMessage(const QString &msg, Utils::OutputFormat format)
////{
//// appendMessage(msg, format);
//// d->outputParser.processOutput(msg);
////}
//void RemoteLinuxAnalyzeSupport::start()
//{
// if (d->needPort) {
// RunWorker *worker = qobject_cast<PortsGatherer>();
// QTC_ASSERT(worker, reportFailure(); return);
// runControl()->worker(PortsGathererWorkerId)->result();
// d->qmlPort = targetRunner()->findPort();
// if (!d->qmlPort.isValid()) {
// reportFailure(tr("Not enough free ports on device for profiling."));
// return;
// }
// } else if (runMode == ProjectExplorer::Constants::PERFPROFILER_RUN_MODE) {
// d->remoteFifo = targetRunner()->fifo();
// if (d->remoteFifo.isEmpty()) {
// reportFailure(tr("FIFO for profiling data could not be created."));
// return;
// }
// }
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** 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.
**
****************************************************************************/
#include "remotelinuxanalyzesupport.h"
#include "remotelinuxrunconfiguration.h"
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/runnables.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <ssh/sshconnection.h>
#include <qmldebug/qmloutputparser.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <QPointer>
using namespace QSsh;
using namespace ProjectExplorer;
using namespace Utils;
namespace RemoteLinux {
// RemoteLinuxQmlProfilerSupport
RemoteLinuxQmlProfilerSupport::RemoteLinuxQmlProfilerSupport(RunControl *runControl)
: SimpleTargetRunner(runControl)
{
setDisplayName("RemoteLinuxQmlProfilerSupport");
m_portsGatherer = new PortsGatherer(runControl);
addDependency(m_portsGatherer);
m_profiler = runControl->createWorker(runControl->runMode());
m_profiler->addDependency(this);
}
void RemoteLinuxQmlProfilerSupport::start()
{
Port qmlPort = m_portsGatherer->findPort();
QUrl serverUrl;
serverUrl.setHost(device()->sshParameters().host);
serverUrl.setPort(qmlPort.number());
m_profiler->recordData("QmlServerUrl", serverUrl);
QString args = QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, qmlPort);
auto r = runnable().as<StandardRunnable>();
if (!r.commandLineArguments.isEmpty())
r.commandLineArguments.append(' ');
r.commandLineArguments += args;
setRunnable(r);
SimpleTargetRunner::start();
}
// RemoteLinuxPerfSupport
RemoteLinuxPerfSupport::RemoteLinuxPerfSupport(RunControl *runControl)
: RunWorker(runControl)
{
setDisplayName("RemoteLinuxPerfSupport");
RunConfiguration *runConfiguration = runControl->runConfiguration();
QTC_ASSERT(runConfiguration, return);
IRunConfigurationAspect *perfAspect =
runConfiguration->extraAspect("Analyzer.Perf.Settings");
QTC_ASSERT(perfAspect, return);
m_perfRecordArguments =
perfAspect->currentSettings()->property("perfRecordArguments").toStringList()
.join(' ');
auto toolRunner = runControl->createWorker(runControl->runMode());
toolRunner->addDependency(this);
// connect(&m_outputGatherer, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,
// this, &RemoteLinuxPerfSupport::remoteIsRunning);
// addDependency(FifoCreatorWorkerId);
}
void RemoteLinuxPerfSupport::start()
{
// m_remoteFifo = targetRunner()->fifo();
if (m_remoteFifo.isEmpty()) {
reportFailure(tr("FIFO for profiling data could not be created."));
return;
}
// ApplicationLauncher *runner = targetRunner()->applicationLauncher();
// auto r = runControl()->runnable().as<StandardRunnable>();
// if (runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
// if (!r.commandLineArguments.isEmpty())
// r.commandLineArguments.append(QLatin1Char(' '));
// r.commandLineArguments += QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices,
// d->qmlPort);
// } else if (runMode == ProjectExplorer::Constants::PERFPROFILER_RUN_MODE) {
// r.commandLineArguments = QLatin1String("-c 'perf record -o - ") + d->perfRecordArguments
// + QLatin1String(" -- ") + r.executable + QLatin1String(" ")
// + r.commandLineArguments + QLatin1String(" > ") + d->remoteFifo
// + QLatin1String("'");
// r.executable = QLatin1String("sh");
// connect(&d->outputGatherer, SIGNAL(remoteStdout(QByteArray)),
// runControl(), SIGNAL(analyzePerfOutput(QByteArray)));
// connect(&d->outputGatherer, SIGNAL(finished(bool)),
// runControl(), SIGNAL(perfFinished()));
// StandardRunnable outputRunner;
// outputRunner.executable = QLatin1String("sh");
// outputRunner.commandLineArguments =
// QString::fromLatin1("-c 'cat %1 && rm -r `dirname %1`'").arg(d->remoteFifo);
// d->outputGatherer.start(outputRunner, device());
// remoteIsRunning();
// }
// runner->start(r, device());
//}
auto r = runnable().as<StandardRunnable>();
r.commandLineArguments = "-c 'perf record -o - " + m_perfRecordArguments
+ " -- " + r.executable + " "
+ r.commandLineArguments + " > " + m_remoteFifo
+ "'";
r.executable = "sh";
//void RemoteLinuxAnalyzeSupport::remoteIsRunning()
//{
connect(&m_outputGatherer, SIGNAL(remoteStdout(QByteArray)),
runControl(), SIGNAL(analyzePerfOutput(QByteArray)));
connect(&m_outputGatherer, SIGNAL(finished(bool)),
runControl(), SIGNAL(perfFinished()));
StandardRunnable outputRunner;
outputRunner.executable = "sh";
outputRunner.commandLineArguments = QString("-c 'cat %1 && rm -r `dirname %1`'").arg(m_remoteFifo);
m_outputGatherer.start(outputRunner, device());
// remoteIsRunning();
// runControl()->notifyRemoteSetupDone(d->qmlPort);
//}
//AbstractRemoteLinuxRunSupport *RemoteLinuxAnalyzeSupport::targetRunner() const
//{
// return qobject_cast<AbstractRemoteLinuxRunSupport *>(runControl()->targetRunner());
//}
// runner->start(r, device());
}
//} // namespace RemoteLinux
} // namespace RemoteLinux
///****************************************************************************
//**
//** Copyright (C) 2016 The Qt Company Ltd.
//** Contact: https://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 https://www.qt.io/terms-conditions. For further
//** information use the contact form at https://www.qt.io/contact-us.
//**
//** 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.
//**
//****************************************************************************/
//#pragma once
//#include "abstractremotelinuxrunsupport.h"
//#include <projectexplorer/projectexplorerconstants.h>
//#include <projectexplorer/runconfiguration.h>
//#include <utils/outputformat.h>
//namespace RemoteLinux {
//namespace Internal { class RemoteLinuxAnalyzeSupportPrivate; }
//class REMOTELINUX_EXPORT RemoteLinuxAnalyzeSupport : public ProjectExplorer::RunWorker
//{
// Q_OBJECT
//public:
// RemoteLinuxAnalyzeSupport(ProjectExplorer::RunControl *runControl);
// ~RemoteLinuxAnalyzeSupport() override;
//private:
// void start() override;
// void remoteIsRunning();
// Internal::RemoteLinuxAnalyzeSupportPrivate * const d;
//};
//} // namespace RemoteLinux
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** 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.
**
****************************************************************************/
#pragma once
#include "abstractremotelinuxrunsupport.h"
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
#include <projectexplorer/runconfiguration.h>
#include <utils/outputformat.h>
#include <qmldebug/qmloutputparser.h>
namespace RemoteLinux {
class REMOTELINUX_EXPORT RemoteLinuxQmlProfilerSupport
: public ProjectExplorer::SimpleTargetRunner
{
Q_OBJECT
public:
RemoteLinuxQmlProfilerSupport(ProjectExplorer::RunControl *runControl);
private:
void start() override;
QmlDebug::QmlOutputParser m_outputParser;
ProjectExplorer::PortsGatherer *m_portsGatherer;
ProjectExplorer::RunWorker *m_profiler;
};
class REMOTELINUX_EXPORT RemoteLinuxPerfSupport : public ProjectExplorer::RunWorker
{
Q_OBJECT
public:
RemoteLinuxPerfSupport(ProjectExplorer::RunControl *runControl);
private:
void start() override;
QString m_remoteFifo;
QString m_perfRecordArguments;
ProjectExplorer::ApplicationLauncher m_outputGatherer;
};
} // namespace RemoteLinux
......@@ -31,14 +31,8 @@
#include <QStringList>
namespace Utils {
class Environment;
class PortList;
}
namespace RemoteLinux {
class RemoteLinuxRunConfigurationWidget;
class RemoteLinuxDeployConfiguration;
namespace Internal {
class RemoteLinuxRunConfigurationPrivate;
......
......@@ -85,23 +85,17 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Co
return runControl;
}
if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE
// || mode == ProjectExplorer::Constants::PERFPROFILER_RUN_MODE
) {
if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
auto runControl = new RunControl(runConfig, mode);
runControl->createWorker(mode);
// AnalyzerConnection connection;
// connection.connParams =
// DeviceKitInformation::device(runConfig->target()->kit())->sshParameters();
// connection.analyzerHost = connection.connParams.host;
// runControl->setConnection(connection);
// (void) new SimpleTargetRunner(runControl);
// (void) new PortsGatherer(runControl);
// (void) new FifoGatherer(runControl);
// (void) new RemoteLinuxAnalyzeSupport(runControl);
(void) new RemoteLinuxQmlProfilerSupport(runControl);
return runControl;
}
if ( mode == ProjectExplorer::Constants::PERFPROFILER_RUN_MODE) {
auto runControl = new RunControl(runConfig, mode);
(void) new RemoteLinuxPerfSupport(runControl);
return runControl;
}
QTC_CHECK(false);
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment