Commit ef7c633d authored by hjk's avatar hjk

Android: Re-enable QmlProfiler

Change-Id: Icd73475be421e6813b0d496020461e7020b547dd
Reviewed-by: default avatarhjk <hjk@qt.io>
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent f501c19e
......@@ -365,7 +365,7 @@ void QmlDebugConnection::connectToHost(const QString &hostName, quint16 port)
});
connect(socket, &QAbstractSocket::connected, this, &QmlDebugConnection::socketConnected);
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)
......
......@@ -24,66 +24,37 @@
****************************************************************************/
#include "androidanalyzesupport.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;
namespace Android {
namespace Internal {
AndroidAnalyzeSupport::AndroidAnalyzeSupport(RunControl *runControl)
AndroidQmlProfilerSupport::AndroidQmlProfilerSupport(RunControl *runControl)
: RunWorker(runControl)
{
setDisplayName("AndroidAnalyzeSupport");
RunConfiguration *runConfig = runControl->runConfiguration();
runControl->setDisplayName(AndroidManager::packageName(runConfig->target()));
runControl->setConnection(UrlConnection::localHostWithoutPort());
setDisplayName("AndroidQmlProfilerSupport");
auto runner = new AndroidRunner(runControl);
addDependency(runner);
connect(runControl, &RunControl::finished, runner, [runner] { runner->stop(); });
connect(runControl, &RunControl::starting, runner, [runner] { runner->start(); });
auto profiler = runControl->createWorker(runControl->runMode());
profiler->addDependency(this);
connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort, this,
[this, runControl](Utils::Port) {
runControl->notifyRemoteSetupDone(m_qmlPort);
});
// connect(runner, &AndroidRunner::handleRemoteProcessStarted, this,
// [this](Utils::Port, Utils::Port qmlPort) {
// m_qmlPort = qmlPort;
// });
// connect(runner, &AndroidRunner::handleRemoteProcessFinished, this,
// [this, runControl](const QString &errorMsg) {
// runControl->notifyRemoteFinished();
// appendMessage(errorMsg, Utils::NormalMessageFormat);
// });
connect(runner, &AndroidRunner::qmlServerReady, [this, runner, profiler](const QUrl &server) {
profiler->recordData("QmlServerUrl", server);
reportStarted();
});
}
connect(runner, &AndroidRunner::remoteErrorOutput, this,
[this, runControl](const QString &msg) {
appendMessage(msg, Utils::StdErrFormatSameLine);
m_outputParser.processOutput(msg);
});
void AndroidQmlProfilerSupport::start()
{
}
connect(runner, &AndroidRunner::remoteOutput, this,
[this, runControl](const QString &msg) {
appendMessage(msg, Utils::StdOutFormatSameLine);
m_outputParser.processOutput(msg);
});
void AndroidQmlProfilerSupport::stop()
{
reportStopped();
}
} // namespace Internal
......
......@@ -25,25 +25,21 @@
#pragma once
#include "androidrunconfiguration.h"
#include <projectexplorer/runconfiguration.h>
#include <qmldebug/qmloutputparser.h>
namespace Android {
namespace Internal {
class AndroidAnalyzeSupport : public ProjectExplorer::RunWorker
class AndroidQmlProfilerSupport : public ProjectExplorer::RunWorker
{
Q_OBJECT
public:
explicit AndroidAnalyzeSupport(ProjectExplorer::RunControl *runControl);
explicit AndroidQmlProfilerSupport(ProjectExplorer::RunControl *runControl);
private:
QmlDebug::QmlOutputParser m_outputParser;
Utils::Port m_qmlPort;
void start() override;
void stop() override;
};
} // namespace Internal
......
......@@ -71,9 +71,7 @@ RunControl *AndroidRunControlFactory::create(RunConfiguration *runConfig, Core::
}
if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
auto runControl = new RunControl(runConfig, mode);
auto profiler = runControl->createWorker(mode);
auto profilee = new AndroidAnalyzeSupport(runControl);
profiler->addDependency(profilee);
(void) new AndroidQmlProfilerSupport(runControl);
return runControl;
}
QTC_CHECK(false); // The other run modes are not supported
......
......@@ -34,6 +34,7 @@
#include "androidavdmanager.h"
#include <debugger/debuggerrunconfigurationaspect.h>
#include <coreplugin/messagemanager.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorersettings.h>
......@@ -632,7 +633,7 @@ void AndroidRunnerWorker::onProcessIdChanged(qint64 pid)
// Don't write to m_psProc from a different thread
QTC_ASSERT(QThread::currentThread() == thread(), return);
m_processPID = pid;
if (m_processPID == -1) {
if (pid == -1) {
emit remoteProcessFinished(QLatin1String("\n\n") + tr("\"%1\" died.")
.arg(m_packageName));
// App died/killed. Reset log and monitor processes.
......@@ -714,6 +715,9 @@ AndroidRunner::AndroidRunner(RunControl *runControl)
connect(m_worker.data(), &AndroidRunnerWorker::remoteErrorOutput,
this, &AndroidRunner::remoteErrorOutput);
connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,
this, &AndroidRunner::qmlServerPortReady);
m_thread.start();
}
......@@ -749,14 +753,28 @@ void AndroidRunner::stop()
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)
{
Core::MessageManager::write("LOGCAT: " + output, Core::MessageManager::Silent);
appendMessage(output, Utils::StdOutFormatSameLine);
m_outputParser.processOutput(output);
}
void AndroidRunner::remoteErrorOutput(const QString &output)
{
Core::MessageManager::write("LOGCAT: " + output, Core::MessageManager::Silent);
appendMessage(output, Utils::StdErrFormatSameLine);
m_outputParser.processOutput(output);
}
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)
{
appendMessage(errString, Utils::DebugFormat);
if (runControl()->isRunning())
runControl()->initiateStop();
reportStopped();
}
......
......@@ -30,6 +30,7 @@
#include <projectexplorer/runconfiguration.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <qmldebug/qmloutputparser.h>
#include <QFutureInterface>
#include <QObject>
......@@ -62,18 +63,20 @@ public:
void start() override;
void stop() override;
virtual void remoteOutput(const QString &output);
virtual void remoteErrorOutput(const QString &output);
signals:
void asyncStart(const AndroidRunnable &runnable);
void asyncStop(const AndroidRunnable &runnable);
void remoteDebuggerRunning();
void qmlServerReady(const QUrl &serverUrl);
void adbParametersChanged(const QString &packageName, const QStringList &selector);
void avdDetected();
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 handleRemoteProcessFinished(const QString &errString = QString());
void checkAVD();
......@@ -88,6 +91,7 @@ private:
Utils::Port m_gdbServerPort;
Utils::Port m_qmlServerPort;
Utils::ProcessHandle m_pid;
QmlDebug::QmlOutputParser m_outputParser;
};
} // namespace Internal
......
......@@ -44,6 +44,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/icontext.h>
#include <coreplugin/messagemanager.h>
#include <QDir>
#include <QPushButton>
......@@ -1178,7 +1179,7 @@ void RunControlPrivate::setState(RunControlState newState)
void RunControlPrivate::debugMessage(const QString &msg)
{
//q->appendMessage(msg + '\n', Utils::DebugFormat);
Core::MessageManager::write(msg, Core::MessageManager::Silent);
qCDebug(statesLog()) << msg;
}
......
......@@ -523,7 +523,6 @@ signals:
void appendMessageRequested(ProjectExplorer::RunControl *runControl,
const QString &msg, Utils::OutputFormat format);
void aboutToStart();
void starting();
void started();
void finished();
void applicationProcessHandleChanged(QPrivateSignal); // Use setApplicationProcessHandle
......
......@@ -114,7 +114,7 @@ void QmlProfilerRunner::start()
QUrl serverUrl = this->serverUrl();
if (serverUrl.port() != -1) {
auto clientManager = Internal::QmlProfilerTool::clientManager();
QmlProfilerClientManager *clientManager = Internal::QmlProfilerTool::clientManager();
clientManager->setServerUrl(serverUrl);
clientManager->connectToTcpServer();
}
......@@ -149,6 +149,7 @@ void QmlProfilerRunner::stop()
}
break;
}
reportStopped();
}
void QmlProfilerRunner::notifyRemoteFinished()
......@@ -232,6 +233,7 @@ void QmlProfilerRunner::notifyRemoteSetupDone(Utils::Port port)
auto clientManager = Internal::QmlProfilerTool::clientManager();
clientManager->setServerUrl(serverUrl);
clientManager->connectToTcpServer();
reportStarted();
}
}
......
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