RemoteLinux: Re-enable QmlProfiler

Change-Id: Ifc943c785f94dcd11fae74acdd8c1bf96712ca35
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2017-06-14 11:13:16 +02:00
parent aedcccd78f
commit 057361dc24
6 changed files with 203 additions and 216 deletions

View File

@@ -1193,14 +1193,14 @@ SimpleTargetRunner::SimpleTargetRunner(RunControl *runControl)
: RunWorker(runControl) : RunWorker(runControl)
{ {
setDisplayName("SimpleTargetRunner"); setDisplayName("SimpleTargetRunner");
m_runnable = runControl->runnable();
} }
void SimpleTargetRunner::start() void SimpleTargetRunner::start()
{ {
m_launcher.disconnect(this); m_launcher.disconnect(this);
Runnable r = runControl()->runnable(); QString msg = RunControl::tr("Starting %1...").arg(m_runnable.displayName());
QString msg = RunControl::tr("Starting %1...").arg(r.displayName());
appendMessage(msg, Utils::NormalMessageFormat); appendMessage(msg, Utils::NormalMessageFormat);
if (isSynchronousLauncher(runControl())) { if (isSynchronousLauncher(runControl())) {
@@ -1214,15 +1214,15 @@ void SimpleTargetRunner::start()
connect(&m_launcher, &ApplicationLauncher::error, connect(&m_launcher, &ApplicationLauncher::error,
this, &SimpleTargetRunner::onProcessError); this, &SimpleTargetRunner::onProcessError);
QTC_ASSERT(r.is<StandardRunnable>(), return); QTC_ASSERT(m_runnable.is<StandardRunnable>(), return);
const QString executable = r.as<StandardRunnable>().executable; const QString executable = m_runnable.as<StandardRunnable>().executable;
if (executable.isEmpty()) { if (executable.isEmpty()) {
reportFailure(RunControl::tr("No executable specified.")); reportFailure(RunControl::tr("No executable specified."));
} else if (!QFileInfo::exists(executable)) { } else if (!QFileInfo::exists(executable)) {
reportFailure(RunControl::tr("Executable %1 does not exist.") reportFailure(RunControl::tr("Executable %1 does not exist.")
.arg(QDir::toNativeSeparators(executable))); .arg(QDir::toNativeSeparators(executable)));
} else { } else {
m_launcher.start(r); m_launcher.start(m_runnable);
} }
} else { } else {
@@ -1270,7 +1270,7 @@ void SimpleTargetRunner::start()
appendMessage(progressString, Utils::NormalMessageFormat); 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."); msg = tr("%1 crashed.");
else else
msg = tr("%2 exited with code %1").arg(exitCode); 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(); reportStopped();
} }
void SimpleTargetRunner::onProcessError(QProcess::ProcessError) void SimpleTargetRunner::onProcessError(QProcess::ProcessError)
{ {
QString msg = tr("%1 finished."); QString msg = tr("%1 finished.");
appendMessage(msg.arg(runnable().displayName()), Utils::NormalMessageFormat); appendMessage(msg.arg(m_runnable.displayName()), Utils::NormalMessageFormat);
reportStopped(); reportStopped();
} }
void SimpleTargetRunner::setRunnable(const Runnable &runnable)
{
m_runnable = runnable;
}
// RunWorkerPrivate // RunWorkerPrivate
RunWorkerPrivate::RunWorkerPrivate(RunWorker *runWorker, RunControl *runControl) RunWorkerPrivate::RunWorkerPrivate(RunWorker *runWorker, RunControl *runControl)
@@ -1456,7 +1461,7 @@ void RunWorker::recordData(const QString &channel, const QVariant &data)
d->data[channel] = data; d->data[channel] = data;
} }
QVariant RunWorker::recordedData(const QString &channel) QVariant RunWorker::recordedData(const QString &channel) const
{ {
return d->data[channel]; return d->data[channel];
} }

View File

@@ -375,7 +375,7 @@ public:
void reportData(int channel, const QVariant &data); void reportData(int channel, const QVariant &data);
void recordData(const QString &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. // Part of read-only interface of RunControl for convenience.
void appendMessage(const QString &msg, Utils::OutputFormat format); void appendMessage(const QString &msg, Utils::OutputFormat format);
@@ -524,6 +524,8 @@ class PROJECTEXPLORER_EXPORT SimpleTargetRunner : public RunWorker
public: public:
explicit SimpleTargetRunner(RunControl *runControl); explicit SimpleTargetRunner(RunControl *runControl);
void setRunnable(const Runnable &runnable);
protected: protected:
void start() override; void start() override;
void stop() override; void stop() override;
@@ -534,6 +536,7 @@ private:
void onProcessError(QProcess::ProcessError error); void onProcessError(QProcess::ProcessError error);
ApplicationLauncher m_launcher; ApplicationLauncher m_launcher;
Runnable m_runnable;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -1,172 +1,145 @@
///**************************************************************************** /****************************************************************************
//** **
//** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2016 The Qt Company Ltd.
//** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
//** **
//** This file is part of Qt Creator. ** This file is part of Qt Creator.
//** **
//** Commercial License Usage ** Commercial License Usage
//** Licensees holding valid commercial Qt licenses may use this file in ** Licensees holding valid commercial Qt licenses may use this file in
//** accordance with the commercial license agreement provided with the ** accordance with the commercial license agreement provided with the
//** Software or, alternatively, in accordance with the terms contained in ** Software or, alternatively, in accordance with the terms contained in
//** a written agreement between you and The Qt Company. For licensing terms ** a written agreement between you and The Qt Company. For licensing terms
//** and conditions see https://www.qt.io/terms-conditions. For further ** and conditions see https://www.qt.io/terms-conditions. For further
//** information use the contact form at https://www.qt.io/contact-us. ** information use the contact form at https://www.qt.io/contact-us.
//** **
//** GNU General Public License Usage ** GNU General Public License Usage
//** Alternatively, this file may be used under the terms of the GNU ** Alternatively, this file may be used under the terms of the GNU
//** General Public License version 3 as published by the Free Software ** General Public License version 3 as published by the Free Software
//** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
//** included in the packaging of this file. Please review the following ** included in the packaging of this file. Please review the following
//** information to ensure the GNU General Public License requirements will ** information to ensure the GNU General Public License requirements will
//** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
//** **
//****************************************************************************/ ****************************************************************************/
//#include "remotelinuxanalyzesupport.h" #include "remotelinuxanalyzesupport.h"
//#include "remotelinuxrunconfiguration.h" #include "remotelinuxrunconfiguration.h"
//#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildconfiguration.h>
//#include <projectexplorer/project.h> #include <projectexplorer/project.h>
//#include <projectexplorer/target.h> #include <projectexplorer/target.h>
//#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
//#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>
//#include <projectexplorer/runnables.h> #include <projectexplorer/runnables.h>
//#include <utils/qtcassert.h> #include <utils/qtcassert.h>
//#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
//#include <qmldebug/qmloutputparser.h>
//#include <qmldebug/qmldebugcommandlinearguments.h>
//#include <QPointer> #include <ssh/sshconnection.h>
//using namespace QSsh; #include <qmldebug/qmloutputparser.h>
//using namespace ProjectExplorer; #include <qmldebug/qmldebugcommandlinearguments.h>
//using namespace Utils;
//namespace RemoteLinux { #include <QPointer>
//namespace Internal {
//const char RemoteLinuxAnalyzeSupportWorkerId[] = "RemoteLinux.AnalyzeSupportWorker"; using namespace QSsh;
using namespace ProjectExplorer;
using namespace Utils;
//class RemoteLinuxAnalyzeSupportPrivate namespace RemoteLinux {
//{
//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; // RemoteLinuxQmlProfilerSupport
// QString remoteFifo;
// QString perfRecordArguments;
// ApplicationLauncher outputGatherer; RemoteLinuxQmlProfilerSupport::RemoteLinuxQmlProfilerSupport(RunControl *runControl)
// QmlDebug::QmlOutputParser outputParser; : SimpleTargetRunner(runControl)
// bool needFifo = false; {
// bool needPort = false; setDisplayName("RemoteLinuxQmlProfilerSupport");
//};
//} // namespace Internal m_portsGatherer = new PortsGatherer(runControl);
addDependency(m_portsGatherer);
//using namespace Internal; m_profiler = runControl->createWorker(runControl->runMode());
m_profiler->addDependency(this);
}
//RemoteLinuxAnalyzeSupport::RemoteLinuxAnalyzeSupport(RunControl *runControl) void RemoteLinuxQmlProfilerSupport::start()
// : ToolRunner(runControl), {
// d(new RemoteLinuxAnalyzeSupportPrivate(runControl)) Port qmlPort = m_portsGatherer->findPort();
//{
// setId(RemoteLinuxAnalyzeSupportWorkerId);
// connect(&d->outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort, QUrl serverUrl;
// this, &RemoteLinuxAnalyzeSupport::remoteIsRunning); serverUrl.setHost(device()->sshParameters().host);
serverUrl.setPort(qmlPort.number());
m_profiler->recordData("QmlServerUrl", serverUrl);
// if (d->needFifo) QString args = QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, qmlPort);
// addDependency(FifoCreatorWorkerId); auto r = runnable().as<StandardRunnable>();
// if (d->needPort) if (!r.commandLineArguments.isEmpty())
// addDependency(PortsGathererWorkerId); r.commandLineArguments.append(' ');
//} r.commandLineArguments += args;
//RemoteLinuxAnalyzeSupport::~RemoteLinuxAnalyzeSupport() setRunnable(r);
//{
// delete d;
//}
////void RemoteLinuxAnalyzeSupport::showMessage(const QString &msg, Utils::OutputFormat format) SimpleTargetRunner::start();
////{ }
//// appendMessage(msg, format);
//// d->outputParser.processOutput(msg);
////}
//void RemoteLinuxAnalyzeSupport::start()
//{ // RemoteLinuxPerfSupport
// if (d->needPort) {
// RunWorker *worker = qobject_cast<PortsGatherer>(); RemoteLinuxPerfSupport::RemoteLinuxPerfSupport(RunControl *runControl)
// QTC_ASSERT(worker, reportFailure(); return); : RunWorker(runControl)
// runControl()->worker(PortsGathererWorkerId)->result(); {
// d->qmlPort = targetRunner()->findPort(); setDisplayName("RemoteLinuxPerfSupport");
// if (!d->qmlPort.isValid()) {
// reportFailure(tr("Not enough free ports on device for profiling.")); RunConfiguration *runConfiguration = runControl->runConfiguration();
// return; QTC_ASSERT(runConfiguration, return);
// } IRunConfigurationAspect *perfAspect =
// } else if (runMode == ProjectExplorer::Constants::PERFPROFILER_RUN_MODE) { runConfiguration->extraAspect("Analyzer.Perf.Settings");
// d->remoteFifo = targetRunner()->fifo(); QTC_ASSERT(perfAspect, return);
// if (d->remoteFifo.isEmpty()) { m_perfRecordArguments =
// reportFailure(tr("FIFO for profiling data could not be created.")); perfAspect->currentSettings()->property("perfRecordArguments").toStringList()
// return; .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(); // ApplicationLauncher *runner = targetRunner()->applicationLauncher();
// auto r = runControl()->runnable().as<StandardRunnable>(); auto r = runnable().as<StandardRunnable>();
// if (runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) { r.commandLineArguments = "-c 'perf record -o - " + m_perfRecordArguments
// if (!r.commandLineArguments.isEmpty()) + " -- " + r.executable + " "
// r.commandLineArguments.append(QLatin1Char(' ')); + r.commandLineArguments + " > " + m_remoteFifo
// r.commandLineArguments += QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, + "'";
// d->qmlPort); r.executable = "sh";
// } 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)), connect(&m_outputGatherer, SIGNAL(remoteStdout(QByteArray)),
// runControl(), SIGNAL(analyzePerfOutput(QByteArray))); runControl(), SIGNAL(analyzePerfOutput(QByteArray)));
// connect(&d->outputGatherer, SIGNAL(finished(bool)), connect(&m_outputGatherer, SIGNAL(finished(bool)),
// runControl(), SIGNAL(perfFinished())); runControl(), SIGNAL(perfFinished()));
// StandardRunnable outputRunner; StandardRunnable outputRunner;
// outputRunner.executable = QLatin1String("sh"); outputRunner.executable = "sh";
// outputRunner.commandLineArguments = outputRunner.commandLineArguments = QString("-c 'cat %1 && rm -r `dirname %1`'").arg(m_remoteFifo);
// QString::fromLatin1("-c 'cat %1 && rm -r `dirname %1`'").arg(d->remoteFifo); m_outputGatherer.start(outputRunner, device());
// d->outputGatherer.start(outputRunner, device()); // remoteIsRunning();
// remoteIsRunning();
// }
// runner->start(r, device());
//}
//void RemoteLinuxAnalyzeSupport::remoteIsRunning()
//{
// runControl()->notifyRemoteSetupDone(d->qmlPort); // runControl()->notifyRemoteSetupDone(d->qmlPort);
//}
//AbstractRemoteLinuxRunSupport *RemoteLinuxAnalyzeSupport::targetRunner() const // runner->start(r, device());
//{ }
// return qobject_cast<AbstractRemoteLinuxRunSupport *>(runControl()->targetRunner());
//}
//} // namespace RemoteLinux } // namespace RemoteLinux

View File

@@ -1,54 +1,72 @@
///**************************************************************************** /****************************************************************************
//** **
//** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2016 The Qt Company Ltd.
//** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
//** **
//** This file is part of Qt Creator. ** This file is part of Qt Creator.
//** **
//** Commercial License Usage ** Commercial License Usage
//** Licensees holding valid commercial Qt licenses may use this file in ** Licensees holding valid commercial Qt licenses may use this file in
//** accordance with the commercial license agreement provided with the ** accordance with the commercial license agreement provided with the
//** Software or, alternatively, in accordance with the terms contained in ** Software or, alternatively, in accordance with the terms contained in
//** a written agreement between you and The Qt Company. For licensing terms ** a written agreement between you and The Qt Company. For licensing terms
//** and conditions see https://www.qt.io/terms-conditions. For further ** and conditions see https://www.qt.io/terms-conditions. For further
//** information use the contact form at https://www.qt.io/contact-us. ** information use the contact form at https://www.qt.io/contact-us.
//** **
//** GNU General Public License Usage ** GNU General Public License Usage
//** Alternatively, this file may be used under the terms of the GNU ** Alternatively, this file may be used under the terms of the GNU
//** General Public License version 3 as published by the Free Software ** General Public License version 3 as published by the Free Software
//** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
//** included in the packaging of this file. Please review the following ** included in the packaging of this file. Please review the following
//** information to ensure the GNU General Public License requirements will ** information to ensure the GNU General Public License requirements will
//** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
//** **
//****************************************************************************/ ****************************************************************************/
//#pragma once #pragma once
//#include "abstractremotelinuxrunsupport.h" #include "abstractremotelinuxrunsupport.h"
//#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
//#include <projectexplorer/runconfiguration.h> #include <projectexplorer/runconfiguration.h>
//#include <utils/outputformat.h> #include <utils/outputformat.h>
//namespace RemoteLinux { #include <qmldebug/qmloutputparser.h>
//namespace Internal { class RemoteLinuxAnalyzeSupportPrivate; } namespace RemoteLinux {
//class REMOTELINUX_EXPORT RemoteLinuxAnalyzeSupport : public ProjectExplorer::RunWorker class REMOTELINUX_EXPORT RemoteLinuxQmlProfilerSupport
//{ : public ProjectExplorer::SimpleTargetRunner
// Q_OBJECT {
//public: Q_OBJECT
// RemoteLinuxAnalyzeSupport(ProjectExplorer::RunControl *runControl);
// ~RemoteLinuxAnalyzeSupport() override;
//private: public:
// void start() override; RemoteLinuxQmlProfilerSupport(ProjectExplorer::RunControl *runControl);
// void remoteIsRunning(); private:
void start() override;
// Internal::RemoteLinuxAnalyzeSupportPrivate * const d; QmlDebug::QmlOutputParser m_outputParser;
//}; ProjectExplorer::PortsGatherer *m_portsGatherer;
ProjectExplorer::RunWorker *m_profiler;
};
//} // namespace RemoteLinux
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

View File

@@ -31,14 +31,8 @@
#include <QStringList> #include <QStringList>
namespace Utils {
class Environment;
class PortList;
}
namespace RemoteLinux { namespace RemoteLinux {
class RemoteLinuxRunConfigurationWidget; class RemoteLinuxRunConfigurationWidget;
class RemoteLinuxDeployConfiguration;
namespace Internal { namespace Internal {
class RemoteLinuxRunConfigurationPrivate; class RemoteLinuxRunConfigurationPrivate;

View File

@@ -85,23 +85,17 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Co
return runControl; return runControl;
} }
if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
// || mode == ProjectExplorer::Constants::PERFPROFILER_RUN_MODE
) {
auto runControl = new RunControl(runConfig, mode); auto runControl = new RunControl(runConfig, mode);
runControl->createWorker(mode); (void) new RemoteLinuxQmlProfilerSupport(runControl);
// 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);
return 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); QTC_CHECK(false);
return 0; return 0;
} }