forked from qt-creator/qt-creator
Android: Re-enable QmlProfiler
Change-Id: Icd73475be421e6813b0d496020461e7020b547dd Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -365,7 +365,7 @@ void QmlDebugConnection::connectToHost(const QString &hostName, quint16 port)
|
|||||||
});
|
});
|
||||||
connect(socket, &QAbstractSocket::connected, this, &QmlDebugConnection::socketConnected);
|
connect(socket, &QAbstractSocket::connected, this, &QmlDebugConnection::socketConnected);
|
||||||
connect(socket, &QAbstractSocket::disconnected, this, &QmlDebugConnection::socketDisconnected);
|
connect(socket, &QAbstractSocket::disconnected, this, &QmlDebugConnection::socketDisconnected);
|
||||||
socket->connectToHost(hostName, port);
|
socket->connectToHost(hostName.isEmpty() ? QString("localhost") : hostName, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlDebugConnection::startLocalServer(const QString &fileName)
|
void QmlDebugConnection::startLocalServer(const QString &fileName)
|
||||||
|
|||||||
@@ -24,66 +24,37 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "androidanalyzesupport.h"
|
#include "androidanalyzesupport.h"
|
||||||
|
|
||||||
#include "androidrunner.h"
|
#include "androidrunner.h"
|
||||||
#include "androidmanager.h"
|
|
||||||
|
|
||||||
#include <debugger/analyzer/analyzermanager.h>
|
|
||||||
|
|
||||||
#include <projectexplorer/project.h>
|
|
||||||
#include <projectexplorer/runconfiguration.h>
|
|
||||||
#include <projectexplorer/target.h>
|
|
||||||
|
|
||||||
#include <qtsupport/qtkitinformation.h>
|
|
||||||
|
|
||||||
using namespace Debugger;
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
namespace Android {
|
namespace Android {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
AndroidAnalyzeSupport::AndroidAnalyzeSupport(RunControl *runControl)
|
AndroidQmlProfilerSupport::AndroidQmlProfilerSupport(RunControl *runControl)
|
||||||
: RunWorker(runControl)
|
: RunWorker(runControl)
|
||||||
{
|
{
|
||||||
setDisplayName("AndroidAnalyzeSupport");
|
setDisplayName("AndroidQmlProfilerSupport");
|
||||||
|
|
||||||
RunConfiguration *runConfig = runControl->runConfiguration();
|
|
||||||
runControl->setDisplayName(AndroidManager::packageName(runConfig->target()));
|
|
||||||
runControl->setConnection(UrlConnection::localHostWithoutPort());
|
|
||||||
|
|
||||||
auto runner = new AndroidRunner(runControl);
|
auto runner = new AndroidRunner(runControl);
|
||||||
|
addDependency(runner);
|
||||||
|
|
||||||
connect(runControl, &RunControl::finished, runner, [runner] { runner->stop(); });
|
auto profiler = runControl->createWorker(runControl->runMode());
|
||||||
|
profiler->addDependency(this);
|
||||||
|
|
||||||
connect(runControl, &RunControl::starting, runner, [runner] { runner->start(); });
|
connect(runner, &AndroidRunner::qmlServerReady, [this, runner, profiler](const QUrl &server) {
|
||||||
|
profiler->recordData("QmlServerUrl", server);
|
||||||
|
reportStarted();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort, this,
|
void AndroidQmlProfilerSupport::start()
|
||||||
[this, runControl](Utils::Port) {
|
{
|
||||||
runControl->notifyRemoteSetupDone(m_qmlPort);
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// connect(runner, &AndroidRunner::handleRemoteProcessStarted, this,
|
void AndroidQmlProfilerSupport::stop()
|
||||||
// [this](Utils::Port, Utils::Port qmlPort) {
|
{
|
||||||
// m_qmlPort = qmlPort;
|
reportStopped();
|
||||||
// });
|
|
||||||
|
|
||||||
// connect(runner, &AndroidRunner::handleRemoteProcessFinished, this,
|
|
||||||
// [this, runControl](const QString &errorMsg) {
|
|
||||||
// runControl->notifyRemoteFinished();
|
|
||||||
// appendMessage(errorMsg, Utils::NormalMessageFormat);
|
|
||||||
// });
|
|
||||||
|
|
||||||
connect(runner, &AndroidRunner::remoteErrorOutput, this,
|
|
||||||
[this, runControl](const QString &msg) {
|
|
||||||
appendMessage(msg, Utils::StdErrFormatSameLine);
|
|
||||||
m_outputParser.processOutput(msg);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(runner, &AndroidRunner::remoteOutput, this,
|
|
||||||
[this, runControl](const QString &msg) {
|
|
||||||
appendMessage(msg, Utils::StdOutFormatSameLine);
|
|
||||||
m_outputParser.processOutput(msg);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -25,25 +25,21 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "androidrunconfiguration.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
|
|
||||||
#include <qmldebug/qmloutputparser.h>
|
|
||||||
|
|
||||||
namespace Android {
|
namespace Android {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class AndroidAnalyzeSupport : public ProjectExplorer::RunWorker
|
class AndroidQmlProfilerSupport : public ProjectExplorer::RunWorker
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AndroidAnalyzeSupport(ProjectExplorer::RunControl *runControl);
|
explicit AndroidQmlProfilerSupport(ProjectExplorer::RunControl *runControl);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QmlDebug::QmlOutputParser m_outputParser;
|
void start() override;
|
||||||
Utils::Port m_qmlPort;
|
void stop() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -71,9 +71,7 @@ RunControl *AndroidRunControlFactory::create(RunConfiguration *runConfig, Core::
|
|||||||
}
|
}
|
||||||
if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
|
if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
|
||||||
auto runControl = new RunControl(runConfig, mode);
|
auto runControl = new RunControl(runConfig, mode);
|
||||||
auto profiler = runControl->createWorker(mode);
|
(void) new AndroidQmlProfilerSupport(runControl);
|
||||||
auto profilee = new AndroidAnalyzeSupport(runControl);
|
|
||||||
profiler->addDependency(profilee);
|
|
||||||
return runControl;
|
return runControl;
|
||||||
}
|
}
|
||||||
QTC_CHECK(false); // The other run modes are not supported
|
QTC_CHECK(false); // The other run modes are not supported
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "androidavdmanager.h"
|
#include "androidavdmanager.h"
|
||||||
|
|
||||||
#include <debugger/debuggerrunconfigurationaspect.h>
|
#include <debugger/debuggerrunconfigurationaspect.h>
|
||||||
|
#include <coreplugin/messagemanager.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/projectexplorersettings.h>
|
#include <projectexplorer/projectexplorersettings.h>
|
||||||
@@ -632,7 +633,7 @@ void AndroidRunnerWorker::onProcessIdChanged(qint64 pid)
|
|||||||
// Don't write to m_psProc from a different thread
|
// Don't write to m_psProc from a different thread
|
||||||
QTC_ASSERT(QThread::currentThread() == thread(), return);
|
QTC_ASSERT(QThread::currentThread() == thread(), return);
|
||||||
m_processPID = pid;
|
m_processPID = pid;
|
||||||
if (m_processPID == -1) {
|
if (pid == -1) {
|
||||||
emit remoteProcessFinished(QLatin1String("\n\n") + tr("\"%1\" died.")
|
emit remoteProcessFinished(QLatin1String("\n\n") + tr("\"%1\" died.")
|
||||||
.arg(m_packageName));
|
.arg(m_packageName));
|
||||||
// App died/killed. Reset log and monitor processes.
|
// App died/killed. Reset log and monitor processes.
|
||||||
@@ -714,6 +715,9 @@ AndroidRunner::AndroidRunner(RunControl *runControl)
|
|||||||
connect(m_worker.data(), &AndroidRunnerWorker::remoteErrorOutput,
|
connect(m_worker.data(), &AndroidRunnerWorker::remoteErrorOutput,
|
||||||
this, &AndroidRunner::remoteErrorOutput);
|
this, &AndroidRunner::remoteErrorOutput);
|
||||||
|
|
||||||
|
connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,
|
||||||
|
this, &AndroidRunner::qmlServerPortReady);
|
||||||
|
|
||||||
m_thread.start();
|
m_thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -749,14 +753,28 @@ void AndroidRunner::stop()
|
|||||||
emit asyncStop(m_androidRunnable);
|
emit asyncStop(m_androidRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AndroidRunner::qmlServerPortReady(Port port)
|
||||||
|
{
|
||||||
|
// FIXME: Note that the passed is nonsense, as the port is on the
|
||||||
|
// device side. It only happens to work since we redirect
|
||||||
|
// host port n to target port n via adb.
|
||||||
|
QUrl serverUrl;
|
||||||
|
serverUrl.setPort(port.number());
|
||||||
|
emit qmlServerReady(serverUrl);
|
||||||
|
}
|
||||||
|
|
||||||
void AndroidRunner::remoteOutput(const QString &output)
|
void AndroidRunner::remoteOutput(const QString &output)
|
||||||
{
|
{
|
||||||
|
Core::MessageManager::write("LOGCAT: " + output, Core::MessageManager::Silent);
|
||||||
appendMessage(output, Utils::StdOutFormatSameLine);
|
appendMessage(output, Utils::StdOutFormatSameLine);
|
||||||
|
m_outputParser.processOutput(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidRunner::remoteErrorOutput(const QString &output)
|
void AndroidRunner::remoteErrorOutput(const QString &output)
|
||||||
{
|
{
|
||||||
|
Core::MessageManager::write("LOGCAT: " + output, Core::MessageManager::Silent);
|
||||||
appendMessage(output, Utils::StdErrFormatSameLine);
|
appendMessage(output, Utils::StdErrFormatSameLine);
|
||||||
|
m_outputParser.processOutput(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidRunner::handleRemoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlServerPort, int pid)
|
void AndroidRunner::handleRemoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlServerPort, int pid)
|
||||||
@@ -770,6 +788,8 @@ void AndroidRunner::handleRemoteProcessStarted(Utils::Port gdbServerPort, Utils:
|
|||||||
void AndroidRunner::handleRemoteProcessFinished(const QString &errString)
|
void AndroidRunner::handleRemoteProcessFinished(const QString &errString)
|
||||||
{
|
{
|
||||||
appendMessage(errString, Utils::DebugFormat);
|
appendMessage(errString, Utils::DebugFormat);
|
||||||
|
if (runControl()->isRunning())
|
||||||
|
runControl()->initiateStop();
|
||||||
reportStopped();
|
reportStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
#include <qmldebug/qmldebugcommandlinearguments.h>
|
#include <qmldebug/qmldebugcommandlinearguments.h>
|
||||||
|
#include <qmldebug/qmloutputparser.h>
|
||||||
|
|
||||||
#include <QFutureInterface>
|
#include <QFutureInterface>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -62,18 +63,20 @@ public:
|
|||||||
void start() override;
|
void start() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
|
|
||||||
virtual void remoteOutput(const QString &output);
|
|
||||||
virtual void remoteErrorOutput(const QString &output);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void asyncStart(const AndroidRunnable &runnable);
|
void asyncStart(const AndroidRunnable &runnable);
|
||||||
void asyncStop(const AndroidRunnable &runnable);
|
void asyncStop(const AndroidRunnable &runnable);
|
||||||
void remoteDebuggerRunning();
|
void remoteDebuggerRunning();
|
||||||
|
void qmlServerReady(const QUrl &serverUrl);
|
||||||
|
|
||||||
void adbParametersChanged(const QString &packageName, const QStringList &selector);
|
void adbParametersChanged(const QString &packageName, const QStringList &selector);
|
||||||
void avdDetected();
|
void avdDetected();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void qmlServerPortReady(Utils::Port port);
|
||||||
|
void remoteOutput(const QString &output);
|
||||||
|
void remoteErrorOutput(const QString &output);
|
||||||
|
void gotRemoteOutput(const QString &output);
|
||||||
void handleRemoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlServerPort, int pid);
|
void handleRemoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlServerPort, int pid);
|
||||||
void handleRemoteProcessFinished(const QString &errString = QString());
|
void handleRemoteProcessFinished(const QString &errString = QString());
|
||||||
void checkAVD();
|
void checkAVD();
|
||||||
@@ -88,6 +91,7 @@ private:
|
|||||||
Utils::Port m_gdbServerPort;
|
Utils::Port m_gdbServerPort;
|
||||||
Utils::Port m_qmlServerPort;
|
Utils::Port m_qmlServerPort;
|
||||||
Utils::ProcessHandle m_pid;
|
Utils::ProcessHandle m_pid;
|
||||||
|
QmlDebug::QmlOutputParser m_outputParser;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/icontext.h>
|
#include <coreplugin/icontext.h>
|
||||||
|
#include <coreplugin/messagemanager.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
@@ -1178,7 +1179,7 @@ void RunControlPrivate::setState(RunControlState newState)
|
|||||||
|
|
||||||
void RunControlPrivate::debugMessage(const QString &msg)
|
void RunControlPrivate::debugMessage(const QString &msg)
|
||||||
{
|
{
|
||||||
//q->appendMessage(msg + '\n', Utils::DebugFormat);
|
Core::MessageManager::write(msg, Core::MessageManager::Silent);
|
||||||
qCDebug(statesLog()) << msg;
|
qCDebug(statesLog()) << msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -523,7 +523,6 @@ signals:
|
|||||||
void appendMessageRequested(ProjectExplorer::RunControl *runControl,
|
void appendMessageRequested(ProjectExplorer::RunControl *runControl,
|
||||||
const QString &msg, Utils::OutputFormat format);
|
const QString &msg, Utils::OutputFormat format);
|
||||||
void aboutToStart();
|
void aboutToStart();
|
||||||
void starting();
|
|
||||||
void started();
|
void started();
|
||||||
void finished();
|
void finished();
|
||||||
void applicationProcessHandleChanged(QPrivateSignal); // Use setApplicationProcessHandle
|
void applicationProcessHandleChanged(QPrivateSignal); // Use setApplicationProcessHandle
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ void QmlProfilerRunner::start()
|
|||||||
QUrl serverUrl = this->serverUrl();
|
QUrl serverUrl = this->serverUrl();
|
||||||
|
|
||||||
if (serverUrl.port() != -1) {
|
if (serverUrl.port() != -1) {
|
||||||
auto clientManager = Internal::QmlProfilerTool::clientManager();
|
QmlProfilerClientManager *clientManager = Internal::QmlProfilerTool::clientManager();
|
||||||
clientManager->setServerUrl(serverUrl);
|
clientManager->setServerUrl(serverUrl);
|
||||||
clientManager->connectToTcpServer();
|
clientManager->connectToTcpServer();
|
||||||
}
|
}
|
||||||
@@ -149,6 +149,7 @@ void QmlProfilerRunner::stop()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
reportStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerRunner::notifyRemoteFinished()
|
void QmlProfilerRunner::notifyRemoteFinished()
|
||||||
@@ -232,6 +233,7 @@ void QmlProfilerRunner::notifyRemoteSetupDone(Utils::Port port)
|
|||||||
auto clientManager = Internal::QmlProfilerTool::clientManager();
|
auto clientManager = Internal::QmlProfilerTool::clientManager();
|
||||||
clientManager->setServerUrl(serverUrl);
|
clientManager->setServerUrl(serverUrl);
|
||||||
clientManager->connectToTcpServer();
|
clientManager->connectToTcpServer();
|
||||||
|
reportStarted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user