2013-05-07 11:05:22 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-05-07 11:05:22 +02:00
|
|
|
**
|
|
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2013-05-07 11:05:22 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2013-05-07 11:05:22 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qnxanalyzesupport.h"
|
|
|
|
|
|
2016-05-19 08:56:05 +02:00
|
|
|
#include "qnxdevice.h"
|
2014-02-11 10:55:24 +01:00
|
|
|
#include "qnxrunconfiguration.h"
|
|
|
|
|
#include "slog2inforunner.h"
|
|
|
|
|
|
2016-02-24 14:42:52 +01:00
|
|
|
#include <debugger/analyzer/analyzerruncontrol.h>
|
2014-02-11 10:55:24 +01:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
2013-05-07 11:05:22 +02:00
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
2013-08-08 14:05:11 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2015-08-10 17:43:58 +02:00
|
|
|
#include <qmldebug/qmldebugcommandlinearguments.h>
|
2013-05-07 11:05:22 +02:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
2016-01-23 10:37:02 +01:00
|
|
|
using namespace Utils;
|
2013-05-07 11:05:22 +02:00
|
|
|
|
2016-01-23 10:37:02 +01:00
|
|
|
namespace Qnx {
|
|
|
|
|
namespace Internal {
|
2013-05-07 11:05:22 +02:00
|
|
|
|
|
|
|
|
QnxAnalyzeSupport::QnxAnalyzeSupport(QnxRunConfiguration *runConfig,
|
2016-03-02 13:57:37 +01:00
|
|
|
Debugger::AnalyzerRunControl *runControl)
|
2013-07-30 14:08:01 +02:00
|
|
|
: QnxAbstractRunSupport(runConfig, runControl)
|
2016-01-26 15:53:26 +01:00
|
|
|
, m_runnable(runConfig->runnable().as<StandardRunnable>())
|
2013-07-30 14:08:01 +02:00
|
|
|
, m_runControl(runControl)
|
2013-05-07 11:05:22 +02:00
|
|
|
, m_qmlPort(-1)
|
|
|
|
|
{
|
2017-03-09 14:13:13 +01:00
|
|
|
const ApplicationLauncher *runner = appRunner();
|
|
|
|
|
connect(runner, &ApplicationLauncher::reportError,
|
2016-01-23 10:37:02 +01:00
|
|
|
this, &QnxAnalyzeSupport::handleError);
|
2017-03-09 14:13:13 +01:00
|
|
|
connect(runner, &ApplicationLauncher::remoteProcessStarted,
|
2016-01-23 10:37:02 +01:00
|
|
|
this, &QnxAbstractRunSupport::handleRemoteProcessStarted);
|
2017-03-09 14:13:13 +01:00
|
|
|
connect(runner, &ApplicationLauncher::finished,
|
2016-01-23 10:37:02 +01:00
|
|
|
this, &QnxAnalyzeSupport::handleRemoteProcessFinished);
|
2017-03-09 14:13:13 +01:00
|
|
|
connect(runner, &ApplicationLauncher::reportProgress,
|
2016-01-23 10:37:02 +01:00
|
|
|
this, &QnxAnalyzeSupport::handleProgressReport);
|
2017-03-09 14:13:13 +01:00
|
|
|
connect(runner, &ApplicationLauncher::remoteStdout,
|
2016-01-23 10:37:02 +01:00
|
|
|
this, &QnxAnalyzeSupport::handleRemoteOutput);
|
2017-03-09 14:13:13 +01:00
|
|
|
connect(runner, &ApplicationLauncher::remoteStderr,
|
2016-01-23 10:37:02 +01:00
|
|
|
this, &QnxAnalyzeSupport::handleRemoteOutput);
|
|
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
connect(m_runControl, &Debugger::AnalyzerRunControl::starting,
|
2016-01-23 10:37:02 +01:00
|
|
|
this, &QnxAnalyzeSupport::handleAdapterSetupRequested);
|
|
|
|
|
connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,
|
|
|
|
|
this, &QnxAnalyzeSupport::remoteIsRunning);
|
2014-02-11 10:55:24 +01:00
|
|
|
|
2015-02-03 23:51:12 +02:00
|
|
|
IDevice::ConstPtr dev = DeviceKitInformation::device(runConfig->target()->kit());
|
2016-05-19 08:56:05 +02:00
|
|
|
QnxDevice::ConstPtr qnxDevice = dev.dynamicCast<const QnxDevice>();
|
2014-02-11 10:55:24 +01:00
|
|
|
|
2016-01-23 10:37:02 +01:00
|
|
|
const QString applicationId = FileName::fromString(runConfig->remoteExecutableFilePath()).fileName();
|
2014-02-11 10:55:24 +01:00
|
|
|
m_slog2Info = new Slog2InfoRunner(applicationId, qnxDevice, this);
|
2016-01-23 10:37:02 +01:00
|
|
|
connect(m_slog2Info, &Slog2InfoRunner::output,
|
|
|
|
|
this, &QnxAnalyzeSupport::showMessage);
|
2017-03-09 14:13:13 +01:00
|
|
|
connect(runner, &ApplicationLauncher::remoteProcessStarted,
|
2016-01-23 10:37:02 +01:00
|
|
|
m_slog2Info, &Slog2InfoRunner::start);
|
2014-02-11 10:55:24 +01:00
|
|
|
if (qnxDevice->qnxVersion() > 0x060500)
|
2016-01-23 10:37:02 +01:00
|
|
|
connect(m_slog2Info, &Slog2InfoRunner::commandMissing,
|
|
|
|
|
this, &QnxAnalyzeSupport::printMissingWarning);
|
2013-05-07 11:05:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxAnalyzeSupport::handleAdapterSetupRequested()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(state() == Inactive, return);
|
|
|
|
|
|
2016-01-23 10:37:02 +01:00
|
|
|
showMessage(tr("Preparing remote side...") + QLatin1Char('\n'), NormalMessageFormat);
|
2013-05-07 11:05:22 +02:00
|
|
|
QnxAbstractRunSupport::handleAdapterSetupRequested();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxAnalyzeSupport::startExecution()
|
|
|
|
|
{
|
|
|
|
|
if (state() == Inactive)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-04-19 16:43:30 +02:00
|
|
|
if (!setPort(m_qmlPort) && !m_qmlPort.isValid())
|
2013-05-07 11:05:22 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
setState(StartingRemoteProcess);
|
|
|
|
|
|
2016-01-27 18:25:13 +01:00
|
|
|
StandardRunnable r = m_runnable;
|
|
|
|
|
if (!r.commandLineArguments.isEmpty())
|
|
|
|
|
r.commandLineArguments += QLatin1Char(' ');
|
2016-04-19 16:43:30 +02:00
|
|
|
r.commandLineArguments += QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices,
|
|
|
|
|
m_qmlPort);
|
2017-03-01 18:31:33 +01:00
|
|
|
appRunner()->start(r, device());
|
2013-05-07 11:05:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxAnalyzeSupport::handleRemoteProcessFinished(bool success)
|
|
|
|
|
{
|
2014-02-11 10:55:24 +01:00
|
|
|
if (!m_runControl)
|
2013-05-07 11:05:22 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!success)
|
2016-01-26 15:53:26 +01:00
|
|
|
showMessage(tr("The %1 process closed unexpectedly.").arg(m_runnable.executable),
|
2016-01-23 10:37:02 +01:00
|
|
|
NormalMessageFormat);
|
2014-03-18 13:00:21 +01:00
|
|
|
m_runControl->notifyRemoteFinished();
|
2014-02-11 10:55:24 +01:00
|
|
|
|
|
|
|
|
m_slog2Info->stop();
|
2013-05-07 11:05:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxAnalyzeSupport::handleProfilingFinished()
|
|
|
|
|
{
|
|
|
|
|
setFinished();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxAnalyzeSupport::handleProgressReport(const QString &progressOutput)
|
|
|
|
|
{
|
2016-01-23 10:37:02 +01:00
|
|
|
showMessage(progressOutput + QLatin1Char('\n'), NormalMessageFormat);
|
2013-05-07 11:05:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxAnalyzeSupport::handleRemoteOutput(const QByteArray &output)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(state() == Inactive || state() == Running, return);
|
|
|
|
|
|
2016-01-23 10:37:02 +01:00
|
|
|
showMessage(QString::fromUtf8(output), StdOutFormat);
|
2013-05-07 11:05:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxAnalyzeSupport::handleError(const QString &error)
|
|
|
|
|
{
|
|
|
|
|
if (state() == Running) {
|
2016-01-23 10:37:02 +01:00
|
|
|
showMessage(error, ErrorMessageFormat);
|
2013-05-07 11:05:22 +02:00
|
|
|
} else if (state() != Inactive) {
|
2016-01-23 10:37:02 +01:00
|
|
|
showMessage(tr("Initial setup failed: %1").arg(error), NormalMessageFormat);
|
2013-05-07 11:05:22 +02:00
|
|
|
setFinished();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-22 16:11:23 +02:00
|
|
|
void QnxAnalyzeSupport::remoteIsRunning()
|
|
|
|
|
{
|
2013-07-30 14:08:01 +02:00
|
|
|
if (m_runControl)
|
|
|
|
|
m_runControl->notifyRemoteSetupDone(m_qmlPort);
|
2013-07-22 16:11:23 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-23 10:37:02 +01:00
|
|
|
void QnxAnalyzeSupport::showMessage(const QString &msg, OutputFormat format)
|
2013-05-07 11:05:22 +02:00
|
|
|
{
|
2013-07-30 14:08:01 +02:00
|
|
|
if (state() != Inactive && m_runControl)
|
2016-05-13 11:27:51 +02:00
|
|
|
m_runControl->appendMessage(msg, format);
|
2013-07-22 16:11:23 +02:00
|
|
|
m_outputParser.processOutput(msg);
|
2013-05-07 11:05:22 +02:00
|
|
|
}
|
2014-02-11 10:55:24 +01:00
|
|
|
|
|
|
|
|
void QnxAnalyzeSupport::printMissingWarning()
|
|
|
|
|
{
|
2016-01-23 10:37:02 +01:00
|
|
|
showMessage(tr("Warning: \"slog2info\" is not found on the device, debug output not available."),
|
|
|
|
|
ErrorMessageFormat);
|
2014-02-11 10:55:24 +01:00
|
|
|
}
|
2016-01-23 10:37:02 +01:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Qnx
|