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/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;
|
|
|
|
|
|
2016-03-15 09:26:34 +01:00
|
|
|
namespace Qnx {
|
|
|
|
|
namespace Internal {
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2017-03-28 17:19:05 +02:00
|
|
|
QnxDebugSupport::QnxDebugSupport(RunControl *runControl)
|
|
|
|
|
: QnxAbstractRunSupport(runControl)
|
2012-06-29 07:23:13 +02:00
|
|
|
{
|
2017-03-28 17:19:05 +02:00
|
|
|
auto runConfig = runControl->runConfiguration();
|
|
|
|
|
m_useCppDebugger = runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>()->useCppDebugger();
|
|
|
|
|
m_useQmlDebugger = runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>()->useQmlDebugger();
|
|
|
|
|
m_runnable = runConfig->runnable().as<StandardRunnable>();
|
|
|
|
|
|
2017-03-09 14:13:13 +01:00
|
|
|
const ApplicationLauncher *runner = appRunner();
|
|
|
|
|
connect(runner, &ApplicationLauncher::reportError, this, &QnxDebugSupport::handleError);
|
|
|
|
|
connect(runner, &ApplicationLauncher::remoteProcessStarted, this, &QnxDebugSupport::handleRemoteProcessStarted);
|
|
|
|
|
connect(runner, &ApplicationLauncher::finished, this, &QnxDebugSupport::handleRemoteProcessFinished);
|
|
|
|
|
connect(runner, &ApplicationLauncher::reportProgress, this, &QnxDebugSupport::handleProgressReport);
|
|
|
|
|
connect(runner, &ApplicationLauncher::remoteStdout, this, &QnxDebugSupport::handleRemoteOutput);
|
|
|
|
|
connect(runner, &ApplicationLauncher::remoteStderr, this, &QnxDebugSupport::handleRemoteOutput);
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2017-04-27 09:53:07 +02:00
|
|
|
connect(toolRunner(), &Debugger::DebuggerRunTool::requestRemoteSetup,
|
2014-12-12 15:33:16 +01:00
|
|
|
this, &QnxDebugSupport::handleAdapterSetupRequested);
|
2017-03-28 17:19:05 +02:00
|
|
|
connect(runControl, &RunControl::finished,
|
|
|
|
|
this, &QnxDebugSupport::handleDebuggingFinished);
|
2013-11-05 14:29:05 +01:00
|
|
|
|
2017-03-28 17:19:05 +02:00
|
|
|
auto qnxRunConfig = qobject_cast<QnxRunConfiguration *>(runControl->runConfiguration());
|
|
|
|
|
const QString applicationId = Utils::FileName::fromString(qnxRunConfig->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);
|
2017-03-09 14:13:13 +01:00
|
|
|
connect(runner, &ApplicationLauncher::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
|
|
|
|
2017-04-27 09:53:07 +02:00
|
|
|
toolRunner()->showMessage(tr("Preparing remote side...") + '\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();
|
2017-03-28 17:19:05 +02:00
|
|
|
Debugger::RemoteSetupResult result;
|
|
|
|
|
result.success = true;
|
|
|
|
|
result.gdbServerPort = m_pdebugPort;
|
|
|
|
|
result.qmlServerPort = m_qmlPort;
|
2017-04-27 09:53:07 +02:00
|
|
|
toolRunner()->notifyEngineRemoteSetupFinished(result);
|
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
|
|
|
{
|
2017-03-28 17:19:05 +02:00
|
|
|
if (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)
|
2017-04-27 09:53:07 +02:00
|
|
|
toolRunner()->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());
|
2017-04-27 09:53:07 +02:00
|
|
|
toolRunner()->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)
|
|
|
|
|
{
|
2017-04-27 09:53:07 +02:00
|
|
|
toolRunner()->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);
|
2017-04-27 09:53:07 +02:00
|
|
|
toolRunner()->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) {
|
2017-04-27 09:53:07 +02:00
|
|
|
toolRunner()->showMessage(error, Debugger::AppError);
|
|
|
|
|
toolRunner()->notifyInferiorIll();
|
2013-05-07 11:05:22 +02:00
|
|
|
} else if (state() != Inactive) {
|
2012-06-29 07:23:13 +02:00
|
|
|
setFinished();
|
2017-03-28 17:19:05 +02:00
|
|
|
Debugger::RemoteSetupResult result;
|
|
|
|
|
result.success = false;
|
|
|
|
|
result.reason = tr("Initial setup failed: %1").arg(error);
|
2017-04-27 09:53:07 +02:00
|
|
|
toolRunner()->notifyEngineRemoteSetupFinished(result);
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
}
|
2013-11-05 14:29:05 +01:00
|
|
|
|
|
|
|
|
void QnxDebugSupport::printMissingWarning()
|
|
|
|
|
{
|
2017-04-27 09:53:07 +02:00
|
|
|
toolRunner()->showMessage(tr("Warning: \"slog2info\" is not found "
|
2017-04-21 17:20:57 +02:00
|
|
|
"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);
|
2017-04-27 09:53:07 +02:00
|
|
|
toolRunner()->showMessage(msg, Debugger::AppOutput);
|
2017-03-28 17:19:05 +02:00
|
|
|
}
|
|
|
|
|
|
2017-04-27 09:53:07 +02:00
|
|
|
Debugger::DebuggerRunTool *QnxDebugSupport::toolRunner()
|
2017-03-28 17:19:05 +02:00
|
|
|
{
|
2017-04-27 09:53:07 +02:00
|
|
|
return qobject_cast<Debugger::DebuggerRunTool *>(runControl()->toolRunner());
|
2013-11-05 14:29:05 +01:00
|
|
|
}
|
2016-03-15 09:26:34 +01:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Qnx
|