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 "qnxruncontrolfactory.h"
|
|
|
|
|
#include "qnxconstants.h"
|
|
|
|
|
#include "qnxrunconfiguration.h"
|
|
|
|
|
#include "qnxdebugsupport.h"
|
2013-05-07 11:05:22 +02:00
|
|
|
#include "qnxanalyzesupport.h"
|
2012-06-29 07:23:13 +02:00
|
|
|
#include "qnxqtversion.h"
|
|
|
|
|
#include "qnxruncontrol.h"
|
|
|
|
|
#include "qnxutils.h"
|
|
|
|
|
#include "qnxdeviceconfiguration.h"
|
|
|
|
|
|
2014-10-17 13:40:04 +02:00
|
|
|
#include <debugger/debuggerruncontrol.h>
|
2013-03-28 08:14:09 +01:00
|
|
|
#include <debugger/debuggerrunconfigurationaspect.h>
|
2012-06-29 07:23:13 +02:00
|
|
|
#include <debugger/debuggerstartparameters.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <debugger/debuggerkitinformation.h>
|
2016-02-24 14:42:52 +01:00
|
|
|
#include <debugger/analyzer/analyzermanager.h>
|
2016-02-26 14:14:49 +01:00
|
|
|
#include <debugger/analyzer/analyzerstartparameters.h>
|
2016-02-24 14:42:52 +01:00
|
|
|
#include <debugger/analyzer/analyzerruncontrol.h>
|
2013-05-07 11:05:22 +02:00
|
|
|
#include <projectexplorer/environmentaspect.h>
|
2013-03-28 08:14:09 +01:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
2012-06-29 07:23:13 +02:00
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
#include <projectexplorer/toolchain.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2012-06-29 07:23:13 +02:00
|
|
|
#include <utils/portlist.h>
|
|
|
|
|
|
2013-05-07 11:05:22 +02:00
|
|
|
using namespace Analyzer;
|
2012-07-25 17:41:01 +02:00
|
|
|
using namespace Debugger;
|
|
|
|
|
using namespace ProjectExplorer;
|
2012-06-29 07:23:13 +02:00
|
|
|
using namespace Qnx;
|
|
|
|
|
using namespace Qnx::Internal;
|
|
|
|
|
|
2015-02-10 13:21:22 +01:00
|
|
|
static DebuggerStartParameters createDebuggerStartParameters(QnxRunConfiguration *runConfig)
|
2012-06-29 07:23:13 +02:00
|
|
|
{
|
2012-07-25 17:41:01 +02:00
|
|
|
DebuggerStartParameters params;
|
|
|
|
|
Target *target = runConfig->target();
|
2012-09-03 18:31:44 +02:00
|
|
|
Kit *k = target->kit();
|
2012-07-25 17:41:01 +02:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
const IDevice::ConstPtr device = DeviceKitInformation::device(k);
|
2012-07-27 13:31:13 +02:00
|
|
|
if (device.isNull())
|
2012-07-25 17:41:01 +02:00
|
|
|
return params;
|
|
|
|
|
|
|
|
|
|
params.startMode = AttachToRemoteServer;
|
2013-10-31 14:25:38 +01:00
|
|
|
params.useCtrlCStub = true;
|
2016-01-28 10:31:24 +01:00
|
|
|
params.inferior.executable = runConfig->localExecutableFilePath();
|
2012-07-25 17:41:01 +02:00
|
|
|
params.remoteExecutable = runConfig->remoteExecutableFilePath();
|
2012-07-27 13:31:13 +02:00
|
|
|
params.remoteChannel = device->sshParameters().host + QLatin1String(":-1");
|
2012-07-25 17:41:01 +02:00
|
|
|
params.remoteSetupNeeded = true;
|
2013-05-03 13:52:52 +02:00
|
|
|
params.closeMode = KillAtClose;
|
2016-01-28 10:31:24 +01:00
|
|
|
params.inferior.commandLineArguments = runConfig->arguments();
|
2013-03-28 08:14:09 +01:00
|
|
|
|
2015-06-26 13:06:08 +02:00
|
|
|
auto aspect = runConfig->extraAspect<DebuggerRunConfigurationAspect>();
|
2013-03-28 08:14:09 +01:00
|
|
|
if (aspect->useQmlDebugger()) {
|
|
|
|
|
params.qmlServerAddress = device->sshParameters().host;
|
|
|
|
|
params.qmlServerPort = 0; // QML port is handed out later
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-26 13:06:08 +02:00
|
|
|
auto qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitInformation::qtVersion(k));
|
2012-07-25 17:41:01 +02:00
|
|
|
if (qtVersion)
|
|
|
|
|
params.solibSearchPath = QnxUtils::searchPaths(qtVersion);
|
|
|
|
|
|
|
|
|
|
return params;
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|
|
|
|
|
|
2012-07-25 17:41:01 +02:00
|
|
|
QnxRunControlFactory::QnxRunControlFactory(QObject *parent)
|
|
|
|
|
: IRunControlFactory(parent)
|
2012-06-29 07:23:13 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-29 10:36:29 +03:00
|
|
|
bool QnxRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const
|
2012-06-29 07:23:13 +02:00
|
|
|
{
|
2015-06-29 10:36:29 +03:00
|
|
|
if (mode != ProjectExplorer::Constants::NORMAL_RUN_MODE
|
|
|
|
|
&& mode != ProjectExplorer::Constants::DEBUG_RUN_MODE
|
|
|
|
|
&& mode != ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
|
2012-06-29 07:23:13 +02:00
|
|
|
return false;
|
2015-06-29 10:36:29 +03:00
|
|
|
}
|
2012-06-29 07:23:13 +02:00
|
|
|
|
|
|
|
|
if (!runConfiguration->isEnabled()
|
2013-03-21 16:25:09 +01:00
|
|
|
|| !runConfiguration->id().name().startsWith(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX)) {
|
2012-06-29 07:23:13 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-29 15:01:31 +02:00
|
|
|
const QnxDeviceConfiguration::ConstPtr dev = DeviceKitInformation::device(runConfiguration->target()->kit())
|
|
|
|
|
.dynamicCast<const QnxDeviceConfiguration>();
|
|
|
|
|
if (dev.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
|
2016-01-26 14:09:13 +01:00
|
|
|
if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE
|
|
|
|
|
|| mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
|
|
|
|
|
auto aspect = runConfiguration->extraAspect<DebuggerRunConfigurationAspect>();
|
|
|
|
|
int portsUsed = aspect ? aspect->portsUsedByDebugger() : 0;
|
|
|
|
|
return portsUsed <= dev->freePorts().count();
|
|
|
|
|
}
|
2014-04-29 15:01:31 +02:00
|
|
|
|
2012-06-29 07:23:13 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-29 10:36:29 +03:00
|
|
|
RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, Core::Id mode, QString *errorMessage)
|
2012-06-29 07:23:13 +02:00
|
|
|
{
|
2016-01-19 15:41:48 +01:00
|
|
|
QTC_ASSERT(canRun(runConfig, mode), return 0);
|
|
|
|
|
auto rc = qobject_cast<QnxRunConfiguration *>(runConfig);
|
|
|
|
|
QTC_ASSERT(rc, return 0);
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2015-06-29 10:36:29 +03:00
|
|
|
if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE)
|
2012-06-29 07:23:13 +02:00
|
|
|
return new QnxRunControl(rc);
|
2015-06-29 10:36:29 +03:00
|
|
|
|
|
|
|
|
if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE) {
|
2013-08-02 15:39:33 +02:00
|
|
|
const DebuggerStartParameters params = createDebuggerStartParameters(rc);
|
2015-06-26 13:06:08 +02:00
|
|
|
DebuggerRunControl *runControl = createDebuggerRunControl(params, runConfig, errorMessage);
|
2016-01-19 15:41:48 +01:00
|
|
|
QTC_ASSERT(runControl, return 0);
|
|
|
|
|
auto debugSupport = new QnxDebugSupport(rc, runControl);
|
|
|
|
|
connect(runControl, &RunControl::finished, debugSupport, &QnxDebugSupport::handleDebuggingFinished);
|
2013-05-07 11:05:22 +02:00
|
|
|
return runControl;
|
|
|
|
|
}
|
2016-01-19 15:41:48 +01:00
|
|
|
|
2015-06-29 10:36:29 +03:00
|
|
|
if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
|
2016-01-19 15:41:48 +01:00
|
|
|
Kit *kit = runConfig->target()->kit();
|
|
|
|
|
const IDevice::ConstPtr device = DeviceKitInformation::device(kit);
|
|
|
|
|
if (device.isNull())
|
|
|
|
|
return 0;
|
|
|
|
|
AnalyzerRunControl *runControl = AnalyzerManager::createRunControl(runConfig, mode);
|
|
|
|
|
QTC_ASSERT(runControl, return 0);
|
2016-01-27 13:27:06 +01:00
|
|
|
runControl->setRunnable(runConfig->runnable());
|
2016-01-19 15:41:48 +01:00
|
|
|
AnalyzerConnection connection;
|
|
|
|
|
connection.connParams = device->sshParameters();
|
|
|
|
|
connection.analyzerHost = connection.connParams.host;
|
|
|
|
|
connection.analyzerPort = connection.connParams.port;
|
|
|
|
|
runControl->setConnection(connection);
|
|
|
|
|
auto analyzeSupport = new QnxAnalyzeSupport(rc, runControl);
|
|
|
|
|
connect(runControl, &RunControl::finished, analyzeSupport, &QnxAnalyzeSupport::handleProfilingFinished);
|
2013-05-07 11:05:22 +02:00
|
|
|
return runControl;
|
|
|
|
|
}
|
2015-06-29 10:36:29 +03:00
|
|
|
|
|
|
|
|
QTC_CHECK(false);
|
2013-05-07 11:05:22 +02:00
|
|
|
return 0;
|
2012-06-29 07:23:13 +02:00
|
|
|
}
|