2012-06-29 07:23:13 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2013-10-11 17:44:13 +02:00
|
|
|
** Copyright (C) 2012, 2013 BlackBerry Limited. All rights reserved.
|
2012-06-29 07:23:13 +02:00
|
|
|
**
|
2013-10-11 17:44:13 +02:00
|
|
|
** Contact: BlackBerry (qt@blackberry.com)
|
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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2012-06-29 07:23:13 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2012-06-29 07:23:13 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-06-29 07:23:13 +02:00
|
|
|
|
|
|
|
|
#include "qnxdebugsupport.h"
|
|
|
|
|
#include "qnxconstants.h"
|
2012-07-26 09:02:34 +02:00
|
|
|
#include "qnxrunconfiguration.h"
|
2012-06-29 07:23:13 +02:00
|
|
|
|
|
|
|
|
#include <debugger/debuggerengine.h>
|
2013-03-28 08:14:09 +01:00
|
|
|
#include <debugger/debuggerrunconfigurationaspect.h>
|
|
|
|
|
#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>
|
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>
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2012-07-26 09:02:34 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace RemoteLinux;
|
|
|
|
|
|
|
|
|
|
using namespace Qnx;
|
2012-06-29 07:23:13 +02:00
|
|
|
using namespace Qnx::Internal;
|
|
|
|
|
|
|
|
|
|
QnxDebugSupport::QnxDebugSupport(QnxRunConfiguration *runConfig, Debugger::DebuggerEngine *engine)
|
2013-05-07 11:05:22 +02:00
|
|
|
: QnxAbstractRunSupport(runConfig, engine)
|
2012-06-29 07:23:13 +02:00
|
|
|
, m_engine(engine)
|
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();
|
|
|
|
|
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)));
|
2012-06-29 07:23:13 +02:00
|
|
|
|
|
|
|
|
connect(m_engine, SIGNAL(requestRemoteSetup()), this, SLOT(handleAdapterSetupRequested()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxDebugSupport::handleAdapterSetupRequested()
|
|
|
|
|
{
|
2013-05-07 11:05:22 +02:00
|
|
|
QTC_ASSERT(state() == Inactive, return);
|
2012-06-29 07:23:13 +02:00
|
|
|
|
|
|
|
|
if (m_engine)
|
2013-10-17 13:48:04 +02:00
|
|
|
m_engine->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
|
|
|
|
|
|
|
|
if (m_useQmlDebugger)
|
|
|
|
|
m_engine->startParameters().processArgs += QString::fromLocal8Bit(" -qmljsdebugger=port:%1,block").arg(m_qmlPort);
|
|
|
|
|
|
2013-08-08 14:05:11 +02:00
|
|
|
QStringList arguments;
|
2013-03-28 08:14:09 +01:00
|
|
|
if (m_useCppDebugger)
|
2013-08-08 14:05:11 +02:00
|
|
|
arguments << QString::number(m_pdebugPort);
|
2013-03-28 08:14:09 +01:00
|
|
|
else if (m_useQmlDebugger && !m_useCppDebugger)
|
2013-08-08 14:05:11 +02:00
|
|
|
arguments = Utils::QtcProcess::splitArgs(m_engine->startParameters().processArgs);
|
|
|
|
|
appRunner()->setEnvironment(environment());
|
|
|
|
|
appRunner()->setWorkingDirectory(workingDirectory());
|
|
|
|
|
appRunner()->start(device(), executable(), arguments);
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QnxDebugSupport::handleRemoteProcessStarted()
|
|
|
|
|
{
|
2013-05-07 11:05:22 +02:00
|
|
|
QnxAbstractRunSupport::handleRemoteProcessStarted();
|
2012-06-29 07:23:13 +02:00
|
|
|
if (m_engine)
|
2013-03-28 08:14:09 +01:00
|
|
|
m_engine->notifyEngineRemoteSetupDone(m_pdebugPort, m_qmlPort);
|
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
|
|
|
{
|
2013-05-07 11:05:22 +02:00
|
|
|
if (m_engine || 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)
|
2012-06-29 07:23:13 +02:00
|
|
|
m_engine->notifyInferiorIll();
|
|
|
|
|
|
|
|
|
|
} else {
|
2013-03-28 08:14:09 +01:00
|
|
|
const QString errorMsg = tr("The %1 process closed unexpectedly.").arg(executable());
|
2012-06-29 07:23:13 +02:00
|
|
|
m_engine->notifyEngineRemoteSetupFailed(errorMsg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-01 15:39:59 +01:00
|
|
|
killInferiorProcess();
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
2013-03-28 08:14:09 +01:00
|
|
|
QString QnxDebugSupport::executable() const
|
|
|
|
|
{
|
2013-05-07 11:05:22 +02:00
|
|
|
return m_useCppDebugger? QLatin1String(Constants::QNX_DEBUG_EXECUTABLE) : QnxAbstractRunSupport::executable();
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
2013-11-01 15:39:59 +01:00
|
|
|
void QnxDebugSupport::killInferiorProcess()
|
|
|
|
|
{
|
|
|
|
|
device()->signalOperation()->killProcess(QnxAbstractRunSupport::executable());
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-29 07:23:13 +02:00
|
|
|
void QnxDebugSupport::handleProgressReport(const QString &progressOutput)
|
|
|
|
|
{
|
|
|
|
|
if (m_engine)
|
|
|
|
|
m_engine->showMessage(progressOutput + QLatin1Char('\n'), Debugger::AppStuff);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
if (m_engine)
|
|
|
|
|
m_engine->showMessage(QString::fromUtf8(output), Debugger::AppOutput);
|
|
|
|
|
}
|
|
|
|
|
|
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) {
|
2012-06-29 07:23:13 +02:00
|
|
|
if (m_engine) {
|
|
|
|
|
m_engine->showMessage(error, Debugger::AppError);
|
|
|
|
|
m_engine->notifyInferiorIll();
|
|
|
|
|
}
|
2013-05-07 11:05:22 +02:00
|
|
|
} else if (state() != Inactive) {
|
2012-06-29 07:23:13 +02:00
|
|
|
setFinished();
|
|
|
|
|
if (m_engine)
|
|
|
|
|
m_engine->notifyEngineRemoteSetupFailed(tr("Initial setup failed: %1").arg(error));
|
|
|
|
|
}
|
|
|
|
|
}
|