2012-06-29 07:23:13 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2012 - 2014 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
|
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.
|
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
|
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.
|
2012-10-02 09:12:39 +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
|
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 "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>
|
2013-05-07 11:05:22 +02:00
|
|
|
#include <analyzerbase/analyzerstartparameters.h>
|
|
|
|
|
#include <analyzerbase/analyzermanager.h>
|
|
|
|
|
#include <analyzerbase/analyzerruncontrol.h>
|
2013-07-30 14:08:01 +02:00
|
|
|
#include <analyzerbase/ianalyzertool.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;
|
2013-11-01 15:39:59 +01:00
|
|
|
params.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-06 16:50:36 +01:00
|
|
|
params.processArgs = 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
|
|
|
}
|
|
|
|
|
|
2016-01-06 11:40:52 +01:00
|
|
|
static AnalyzerStartParameters createAnalyzerStartParameters(const QnxRunConfiguration *runConfig)
|
2013-05-07 11:05:22 +02:00
|
|
|
{
|
|
|
|
|
AnalyzerStartParameters params;
|
|
|
|
|
Target *target = runConfig->target();
|
|
|
|
|
Kit *k = target->kit();
|
|
|
|
|
|
|
|
|
|
const IDevice::ConstPtr device = DeviceKitInformation::device(k);
|
|
|
|
|
if (device.isNull())
|
|
|
|
|
return params;
|
|
|
|
|
|
|
|
|
|
params.debuggee = runConfig->remoteExecutableFilePath();
|
2016-01-06 16:50:36 +01:00
|
|
|
params.debuggeeArgs = runConfig->arguments();
|
2013-05-07 11:05:22 +02:00
|
|
|
params.connParams = DeviceKitInformation::device(runConfig->target()->kit())->sshParameters();
|
|
|
|
|
params.analyzerHost = params.connParams.host;
|
|
|
|
|
params.analyzerPort = params.connParams.port;
|
|
|
|
|
|
|
|
|
|
return params;
|
|
|
|
|
}
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QnxRunConfiguration * const rc = qobject_cast<QnxRunConfiguration *>(runConfiguration);
|
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;
|
|
|
|
|
|
2015-06-29 10:36:29 +03:00
|
|
|
if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE || mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE)
|
2012-06-29 07:23:13 +02:00
|
|
|
return rc->portsUsedByDebuggers() <= 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
|
|
|
{
|
|
|
|
|
Q_ASSERT(canRun(runConfig, mode));
|
|
|
|
|
|
|
|
|
|
QnxRunConfiguration *rc = qobject_cast<QnxRunConfiguration *>(runConfig);
|
|
|
|
|
Q_ASSERT(rc);
|
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);
|
2013-05-07 11:05:22 +02:00
|
|
|
if (!runControl)
|
|
|
|
|
return 0;
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2014-12-12 15:33:16 +01:00
|
|
|
QnxDebugSupport *debugSupport = new QnxDebugSupport(rc, runControl);
|
2013-05-07 11:05:22 +02:00
|
|
|
connect(runControl, SIGNAL(finished()), debugSupport, SLOT(handleDebuggingFinished()));
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2013-05-07 11:05:22 +02:00
|
|
|
return runControl;
|
|
|
|
|
}
|
2015-06-29 10:36:29 +03:00
|
|
|
if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
|
2016-01-06 11:40:52 +01:00
|
|
|
const AnalyzerStartParameters params = createAnalyzerStartParameters(rc);
|
|
|
|
|
AnalyzerRunControl *runControl = AnalyzerManager::createRunControl(params, runConfig, mode);
|
2013-07-30 14:08:01 +02:00
|
|
|
QnxAnalyzeSupport * const analyzeSupport = new QnxAnalyzeSupport(rc, runControl);
|
2013-05-07 11:05:22 +02:00
|
|
|
connect(runControl, SIGNAL(finished()), analyzeSupport, SLOT(handleProfilingFinished()));
|
|
|
|
|
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
|
|
|
}
|