2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2012-06-29 07:23:13 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 BlackBerry Limited. All rights reserved.
|
2012-06-29 07:23:13 +02:00
|
|
|
** Contact: KDAB (info@kdab.com)
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-06-29 07:23:13 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2012-10-02 09:12:39 +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.
|
2012-06-29 07:23:13 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-06-29 07:23:13 +02:00
|
|
|
|
|
|
|
|
#include "qnxdebugsupport.h"
|
|
|
|
|
#include "qnxconstants.h"
|
2016-05-19 08:56:05 +02:00
|
|
|
#include "qnxdevice.h"
|
2012-07-26 09:02:34 +02:00
|
|
|
#include "qnxrunconfiguration.h"
|
2013-11-05 14:29:05 +01:00
|
|
|
#include "slog2inforunner.h"
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2013-03-28 08:14:09 +01:00
|
|
|
#include <debugger/debuggerrunconfigurationaspect.h>
|
2014-10-17 13:40:04 +02:00
|
|
|
#include <debugger/debuggerruncontrol.h>
|
2013-03-28 08:14:09 +01:00
|
|
|
#include <debugger/debuggerstartparameters.h>
|
2012-07-26 09:02:34 +02:00
|
|
|
#include <projectexplorer/devicesupport/deviceapplicationrunner.h>
|
|
|
|
|
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2016-01-26 15:53:26 +01:00
|
|
|
#include <projectexplorer/runnables.h>
|
2012-07-26 09:02:34 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2012-06-29 07:23:13 +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>
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2012-07-26 09:02:34 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace RemoteLinux;
|
|
|
|
|
|
2016-03-15 09:26:34 +01:00
|
|
|
namespace Qnx {
|
|
|
|
|
namespace Internal {
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2014-12-12 15:33:16 +01:00
|
|
|
QnxDebugSupport::QnxDebugSupport(QnxRunConfiguration *runConfig, Debugger::DebuggerRunControl *runControl)
|
|
|
|
|
: QnxAbstractRunSupport(runConfig, runControl)
|
2016-01-26 15:53:26 +01:00
|
|
|
, m_runnable(runConfig->runnable().as<StandardRunnable>())
|
2014-12-12 15:33:16 +01:00
|
|
|
, m_runControl(runControl)
|
2013-03-28 08:14:09 +01:00
|
|
|
, m_pdebugPort(-1)
|
|
|
|
|
, m_qmlPort(-1)
|
|
|
|
|
, m_useCppDebugger(runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>()->useCppDebugger())
|
|
|
|
|
, m_useQmlDebugger(runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>()->useQmlDebugger())
|
2012-06-29 07:23:13 +02:00
|
|
|
{
|
2013-05-07 11:05:22 +02:00
|
|
|
const DeviceApplicationRunner *runner = appRunner();
|
2016-03-15 09:26:34 +01:00
|
|
|
connect(runner, &DeviceApplicationRunner::reportError, this, &QnxDebugSupport::handleError);
|
|
|
|
|
connect(runner, &DeviceApplicationRunner::remoteProcessStarted, this, &QnxDebugSupport::handleRemoteProcessStarted);
|
|
|
|
|
connect(runner, &DeviceApplicationRunner::finished, this, &QnxDebugSupport::handleRemoteProcessFinished);
|
|
|
|
|
connect(runner, &DeviceApplicationRunner::reportProgress, this, &QnxDebugSupport::handleProgressReport);
|
|
|
|
|
connect(runner, &DeviceApplicationRunner::remoteStdout, this, &QnxDebugSupport::handleRemoteOutput);
|
|
|
|
|
connect(runner, &DeviceApplicationRunner::remoteStderr, this, &QnxDebugSupport::handleRemoteOutput);
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2014-12-12 15:33:16 +01:00
|
|
|
connect(m_runControl, &Debugger::DebuggerRunControl::requestRemoteSetup,
|
|
|
|
|
this, &QnxDebugSupport::handleAdapterSetupRequested);
|
2013-11-05 14:29:05 +01:00
|
|
|
|
2015-01-10 23:40:32 +02:00
|
|
|
const QString applicationId = Utils::FileName::fromString(runConfig->remoteExecutableFilePath()).fileName();
|
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>();
|
2013-11-05 14:29:05 +01:00
|
|
|
|
|
|
|
|
m_slog2Info = new Slog2InfoRunner(applicationId, qnxDevice, this);
|
2016-03-15 09:26:34 +01:00
|
|
|
connect(m_slog2Info, &Slog2InfoRunner::output, this, &QnxDebugSupport::handleApplicationOutput);
|
|
|
|
|
connect(runner, &DeviceApplicationRunner::remoteProcessStarted, m_slog2Info, &Slog2InfoRunner::start);
|
2013-11-05 14:29:05 +01:00
|
|
|
if (qnxDevice->qnxVersion() > 0x060500)
|
2016-03-15 09:26:34 +01:00
|
|
|
connect(m_slog2Info, &Slog2InfoRunner::commandMissing, this, &QnxDebugSupport::printMissingWarning);
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxDebugSupport::handleAdapterSetupRequested()
|
|
|
|
|
{
|
2013-05-07 11:05:22 +02:00
|
|
|
QTC_ASSERT(state() == Inactive, return);
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2014-12-12 15:33:16 +01:00
|
|
|
if (m_runControl)
|
|
|
|
|
m_runControl->showMessage(tr("Preparing remote side...") + QLatin1Char('\n'), Debugger::AppStuff);
|
2013-05-07 11:05:22 +02:00
|
|
|
QnxAbstractRunSupport::handleAdapterSetupRequested();
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxDebugSupport::startExecution()
|
|
|
|
|
{
|
2013-05-07 11:05:22 +02:00
|
|
|
if (state() == Inactive)
|
2012-06-29 07:23:13 +02:00
|
|
|
return;
|
|
|
|
|
|
2013-05-07 11:05:22 +02:00
|
|
|
if (m_useCppDebugger && !setPort(m_pdebugPort))
|
|
|
|
|
return;
|
|
|
|
|
if (m_useQmlDebugger && !setPort(m_qmlPort))
|
2013-03-28 08:14:09 +01:00
|
|
|
return;
|
|
|
|
|
|
2013-05-07 11:05:22 +02:00
|
|
|
setState(StartingRemoteProcess);
|
2013-03-28 08:14:09 +01:00
|
|
|
|
2016-11-03 11:18:35 +01:00
|
|
|
StandardRunnable r = m_runnable;
|
2013-08-08 14:05:11 +02:00
|
|
|
QStringList arguments;
|
2013-03-28 08:14:09 +01:00
|
|
|
if (m_useCppDebugger)
|
2016-04-19 16:43:30 +02:00
|
|
|
arguments << QString::number(m_pdebugPort.number());
|
2016-11-03 11:18:35 +01:00
|
|
|
else {
|
|
|
|
|
if (m_useQmlDebugger) {
|
|
|
|
|
arguments.append(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices,
|
|
|
|
|
m_qmlPort));
|
|
|
|
|
}
|
|
|
|
|
arguments.append(Utils::QtcProcess::splitArgs(r.commandLineArguments));
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-27 18:25:13 +01:00
|
|
|
r.executable = processExecutable();
|
|
|
|
|
r.commandLineArguments = Utils::QtcProcess::joinArgs(arguments);
|
|
|
|
|
r.environment = m_runnable.environment;
|
|
|
|
|
r.workingDirectory = m_runnable.workingDirectory;
|
2017-03-01 18:31:33 +01:00
|
|
|
appRunner()->start(r, device());
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxDebugSupport::handleRemoteProcessStarted()
|
|
|
|
|
{
|
2013-05-07 11:05:22 +02:00
|
|
|
QnxAbstractRunSupport::handleRemoteProcessStarted();
|
2014-12-12 15:33:16 +01:00
|
|
|
if (m_runControl) {
|
2014-09-18 19:21:27 +02:00
|
|
|
Debugger::RemoteSetupResult result;
|
|
|
|
|
result.success = true;
|
|
|
|
|
result.gdbServerPort = m_pdebugPort;
|
|
|
|
|
result.qmlServerPort = m_qmlPort;
|
2014-12-12 15:33:16 +01:00
|
|
|
m_runControl->notifyEngineRemoteSetupFinished(result);
|
2014-09-18 19:21:27 +02:00
|
|
|
}
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
2012-07-26 09:02:34 +02:00
|
|
|
void QnxDebugSupport::handleRemoteProcessFinished(bool success)
|
2012-06-29 07:23:13 +02:00
|
|
|
{
|
2016-12-05 15:49:50 +01:00
|
|
|
if (!m_runControl || state() == Inactive)
|
2012-06-29 07:23:13 +02:00
|
|
|
return;
|
|
|
|
|
|
2013-05-07 11:05:22 +02:00
|
|
|
if (state() == Running) {
|
2012-07-26 09:02:34 +02:00
|
|
|
if (!success)
|
2014-12-12 15:33:16 +01:00
|
|
|
m_runControl->notifyInferiorIll();
|
2012-06-29 07:23:13 +02:00
|
|
|
|
|
|
|
|
} else {
|
2014-09-18 19:21:27 +02:00
|
|
|
Debugger::RemoteSetupResult result;
|
|
|
|
|
result.success = false;
|
2016-01-26 15:53:26 +01:00
|
|
|
result.reason = tr("The %1 process closed unexpectedly.").arg(processExecutable());
|
2014-12-12 15:33:16 +01:00
|
|
|
m_runControl->notifyEngineRemoteSetupFinished(result);
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxDebugSupport::handleDebuggingFinished()
|
|
|
|
|
{
|
2013-11-01 15:39:59 +01:00
|
|
|
// setFinished() will kill "pdebug", but we also have to kill
|
|
|
|
|
// the inferior process, as invoking "kill" in gdb doesn't work
|
|
|
|
|
// on QNX gdb
|
2012-06-29 07:23:13 +02:00
|
|
|
setFinished();
|
2013-11-05 14:29:05 +01:00
|
|
|
m_slog2Info->stop();
|
2013-11-01 15:39:59 +01:00
|
|
|
killInferiorProcess();
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-26 15:53:26 +01:00
|
|
|
QString QnxDebugSupport::processExecutable() const
|
2013-03-28 08:14:09 +01:00
|
|
|
{
|
2016-01-26 15:53:26 +01:00
|
|
|
return m_useCppDebugger? QLatin1String(Constants::QNX_DEBUG_EXECUTABLE) : m_runnable.executable;
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
2013-11-01 15:39:59 +01:00
|
|
|
void QnxDebugSupport::killInferiorProcess()
|
|
|
|
|
{
|
2016-01-26 15:53:26 +01:00
|
|
|
device()->signalOperation()->killProcess(m_runnable.executable);
|
2013-11-01 15:39:59 +01:00
|
|
|
}
|
|
|
|
|
|
2012-06-29 07:23:13 +02:00
|
|
|
void QnxDebugSupport::handleProgressReport(const QString &progressOutput)
|
|
|
|
|
{
|
2014-12-12 15:33:16 +01:00
|
|
|
if (m_runControl)
|
|
|
|
|
m_runControl->showMessage(progressOutput + QLatin1Char('\n'), Debugger::AppStuff);
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxDebugSupport::handleRemoteOutput(const QByteArray &output)
|
|
|
|
|
{
|
2013-05-07 11:05:22 +02:00
|
|
|
QTC_ASSERT(state() == Inactive || state() == Running, return);
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2014-12-12 15:33:16 +01:00
|
|
|
if (m_runControl)
|
|
|
|
|
m_runControl->showMessage(QString::fromUtf8(output), Debugger::AppOutput);
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
2012-07-26 09:02:34 +02:00
|
|
|
void QnxDebugSupport::handleError(const QString &error)
|
2012-06-29 07:23:13 +02:00
|
|
|
{
|
2013-05-07 11:05:22 +02:00
|
|
|
if (state() == Running) {
|
2014-12-12 15:33:16 +01:00
|
|
|
if (m_runControl) {
|
|
|
|
|
m_runControl->showMessage(error, Debugger::AppError);
|
|
|
|
|
m_runControl->notifyInferiorIll();
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
2013-05-07 11:05:22 +02:00
|
|
|
} else if (state() != Inactive) {
|
2012-06-29 07:23:13 +02:00
|
|
|
setFinished();
|
2014-12-12 15:33:16 +01:00
|
|
|
if (m_runControl) {
|
2014-09-18 19:21:27 +02:00
|
|
|
Debugger::RemoteSetupResult result;
|
|
|
|
|
result.success = false;
|
|
|
|
|
result.reason = tr("Initial setup failed: %1").arg(error);
|
2014-12-12 15:33:16 +01:00
|
|
|
m_runControl->notifyEngineRemoteSetupFinished(result);
|
2014-09-18 19:21:27 +02:00
|
|
|
}
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
}
|
2013-11-05 14:29:05 +01:00
|
|
|
|
|
|
|
|
void QnxDebugSupport::printMissingWarning()
|
|
|
|
|
{
|
2014-12-12 15:33:16 +01:00
|
|
|
if (m_runControl)
|
|
|
|
|
m_runControl->showMessage(tr("Warning: \"slog2info\" is not found on the device, debug output not available."), Debugger::AppError);
|
2013-11-05 14:29:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxDebugSupport::handleApplicationOutput(const QString &msg, Utils::OutputFormat outputFormat)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(outputFormat);
|
2014-12-12 15:33:16 +01:00
|
|
|
if (m_runControl)
|
|
|
|
|
m_runControl->showMessage(msg, Debugger::AppOutput);
|
2013-11-05 14:29:05 +01:00
|
|
|
}
|
2016-03-15 09:26:34 +01:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Qnx
|