2013-05-07 11:05:22 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2013-05-07 11:05:22 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2013-05-07 11:05:22 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2013-05-07 11:05:22 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qnxanalyzesupport.h"
|
|
|
|
|
|
2014-02-11 10:55:24 +01:00
|
|
|
#include "qnxdeviceconfiguration.h"
|
|
|
|
|
#include "qnxrunconfiguration.h"
|
|
|
|
|
#include "slog2inforunner.h"
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
#include <analyzerbase/analyzerruncontrol.h>
|
2013-05-07 11:05:22 +02:00
|
|
|
#include <analyzerbase/analyzerstartparameters.h>
|
|
|
|
|
#include <projectexplorer/devicesupport/deviceapplicationrunner.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;
|
|
|
|
|
|
|
|
|
|
using namespace Qnx;
|
|
|
|
|
using namespace Qnx::Internal;
|
|
|
|
|
|
|
|
|
|
QnxAnalyzeSupport::QnxAnalyzeSupport(QnxRunConfiguration *runConfig,
|
2013-07-30 14:08:01 +02:00
|
|
|
Analyzer::AnalyzerRunControl *runControl)
|
|
|
|
|
: QnxAbstractRunSupport(runConfig, runControl)
|
|
|
|
|
, m_runControl(runControl)
|
2013-05-07 11:05:22 +02:00
|
|
|
, m_qmlPort(-1)
|
|
|
|
|
{
|
|
|
|
|
const DeviceApplicationRunner *runner = appRunner();
|
|
|
|
|
connect(runner, SIGNAL(reportError(QString)), SLOT(handleError(QString)));
|
|
|
|
|
connect(runner, SIGNAL(remoteProcessStarted()), SLOT(handleRemoteProcessStarted()));
|
|
|
|
|
connect(runner, SIGNAL(finished(bool)), SLOT(handleRemoteProcessFinished(bool)));
|
|
|
|
|
connect(runner, SIGNAL(reportProgress(QString)), SLOT(handleProgressReport(QString)));
|
|
|
|
|
connect(runner, SIGNAL(remoteStdout(QByteArray)), SLOT(handleRemoteOutput(QByteArray)));
|
|
|
|
|
connect(runner, SIGNAL(remoteStderr(QByteArray)), SLOT(handleRemoteOutput(QByteArray)));
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
connect(m_runControl, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)),
|
2013-05-07 11:05:22 +02:00
|
|
|
SLOT(handleAdapterSetupRequested()));
|
2013-07-22 16:11:23 +02:00
|
|
|
connect(&m_outputParser, SIGNAL(waitingForConnectionOnPort(quint16)),
|
|
|
|
|
SLOT(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());
|
2014-02-11 10:55:24 +01:00
|
|
|
QnxDeviceConfiguration::ConstPtr qnxDevice = dev.dynamicCast<const QnxDeviceConfiguration>();
|
|
|
|
|
|
2015-01-10 23:40:32 +02:00
|
|
|
const QString applicationId = Utils::FileName::fromString(runConfig->remoteExecutableFilePath()).fileName();
|
2014-02-11 10:55:24 +01:00
|
|
|
m_slog2Info = new Slog2InfoRunner(applicationId, qnxDevice, this);
|
|
|
|
|
connect(m_slog2Info, SIGNAL(output(QString,Utils::OutputFormat)), this, SLOT(showMessage(QString,Utils::OutputFormat)));
|
|
|
|
|
connect(runner, SIGNAL(remoteProcessStarted()), m_slog2Info, SLOT(start()));
|
|
|
|
|
if (qnxDevice->qnxVersion() > 0x060500)
|
|
|
|
|
connect(m_slog2Info, SIGNAL(commandMissing()), this, SLOT(printMissingWarning()));
|
2013-05-07 11:05:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxAnalyzeSupport::handleAdapterSetupRequested()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(state() == Inactive, return);
|
|
|
|
|
|
2013-10-17 13:48:04 +02:00
|
|
|
showMessage(tr("Preparing remote side...") + QLatin1Char('\n'), Utils::NormalMessageFormat);
|
2013-05-07 11:05:22 +02:00
|
|
|
QnxAbstractRunSupport::handleAdapterSetupRequested();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxAnalyzeSupport::startExecution()
|
|
|
|
|
{
|
|
|
|
|
if (state() == Inactive)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!setPort(m_qmlPort) && m_qmlPort == -1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
setState(StartingRemoteProcess);
|
|
|
|
|
|
2013-08-08 14:05:11 +02:00
|
|
|
const QStringList args = QStringList()
|
|
|
|
|
<< Utils::QtcProcess::splitArgs(m_runControl->startParameters().debuggeeArgs)
|
2015-11-17 16:40:27 +01:00
|
|
|
<< QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, m_qmlPort);
|
2015-08-10 17:43:58 +02:00
|
|
|
|
2013-08-08 14:05:11 +02:00
|
|
|
appRunner()->setEnvironment(environment());
|
|
|
|
|
appRunner()->setWorkingDirectory(workingDirectory());
|
|
|
|
|
appRunner()->start(device(), executable(), args);
|
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)
|
|
|
|
|
showMessage(tr("The %1 process closed unexpectedly.").arg(executable()),
|
|
|
|
|
Utils::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)
|
|
|
|
|
{
|
|
|
|
|
showMessage(progressOutput + QLatin1Char('\n'), Utils::NormalMessageFormat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxAnalyzeSupport::handleRemoteOutput(const QByteArray &output)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(state() == Inactive || state() == Running, return);
|
|
|
|
|
|
|
|
|
|
showMessage(QString::fromUtf8(output), Utils::StdOutFormat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxAnalyzeSupport::handleError(const QString &error)
|
|
|
|
|
{
|
|
|
|
|
if (state() == Running) {
|
|
|
|
|
showMessage(error, Utils::ErrorMessageFormat);
|
|
|
|
|
} else if (state() != Inactive) {
|
|
|
|
|
showMessage(tr("Initial setup failed: %1").arg(error), Utils::NormalMessageFormat);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2013-05-07 11:05:22 +02:00
|
|
|
void QnxAnalyzeSupport::showMessage(const QString &msg, Utils::OutputFormat format)
|
|
|
|
|
{
|
2013-07-30 14:08:01 +02:00
|
|
|
if (state() != Inactive && m_runControl)
|
|
|
|
|
m_runControl->logApplicationMessage(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()
|
|
|
|
|
{
|
2014-08-22 13:26:36 +02:00
|
|
|
showMessage(tr("Warning: \"slog2info\" is not found on the device, debug output not available."), Utils::ErrorMessageFormat);
|
2014-02-11 10:55:24 +01:00
|
|
|
}
|