2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-06-16 17:03:43 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-06-16 17:03:43 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-06-16 17:03:43 +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.
|
2011-06-16 17:03:43 +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.
|
2011-06-16 17:03:43 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-07-25 17:41:01 +02:00
|
|
|
|
2011-06-16 17:03:43 +02:00
|
|
|
#include "remotelinuxdebugsupport.h"
|
|
|
|
|
|
2017-05-04 12:12:27 +02:00
|
|
|
#include "remotelinuxcustomrunconfiguration.h"
|
2011-08-02 12:20:16 +02:00
|
|
|
#include "remotelinuxrunconfiguration.h"
|
2011-06-16 17:03:43 +02:00
|
|
|
|
2014-12-12 15:33:16 +01:00
|
|
|
#include <debugger/debuggerruncontrol.h>
|
|
|
|
|
|
2012-07-25 17:41:01 +02:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2011-06-27 10:11:17 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2016-01-26 15:53:26 +01:00
|
|
|
#include <projectexplorer/runnables.h>
|
2011-07-27 18:04:43 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2011-06-16 17:03:43 +02:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2016-01-06 16:50:36 +01:00
|
|
|
|
2015-08-10 17:43:58 +02:00
|
|
|
#include <qmldebug/qmldebugcommandlinearguments.h>
|
2011-06-16 17:03:43 +02:00
|
|
|
|
2016-01-26 15:53:26 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
|
|
2011-06-16 17:03:43 +02:00
|
|
|
using namespace Debugger;
|
|
|
|
|
using namespace ProjectExplorer;
|
2016-01-26 15:53:26 +01:00
|
|
|
using namespace Utils;
|
2011-06-16 17:03:43 +02:00
|
|
|
|
|
|
|
|
namespace RemoteLinux {
|
2011-08-02 12:20:16 +02:00
|
|
|
|
2017-05-04 12:12:27 +02:00
|
|
|
LinuxDeviceDebugSupport::LinuxDeviceDebugSupport(RunControl *runControl, QString *errorMessage)
|
|
|
|
|
: DebuggerRunTool(runControl)
|
2011-08-02 12:20:16 +02:00
|
|
|
{
|
2017-05-04 12:12:27 +02:00
|
|
|
RunConfiguration *runConfig = runControl->runConfiguration();
|
2011-08-02 12:20:16 +02:00
|
|
|
|
2017-05-04 12:12:27 +02:00
|
|
|
QString symbolFile;
|
|
|
|
|
if (auto rlrc = qobject_cast<RemoteLinuxRunConfiguration *>(runConfig))
|
|
|
|
|
symbolFile = rlrc->localExecutableFilePath();
|
|
|
|
|
if (auto rlrc = qobject_cast<Internal::RemoteLinuxCustomRunConfiguration *>(runConfig))
|
|
|
|
|
symbolFile = rlrc->localExecutableFilePath();
|
|
|
|
|
if (symbolFile.isEmpty()) {
|
|
|
|
|
*errorMessage = tr("Cannot debug: Local executable is not set.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-08-02 12:20:16 +02:00
|
|
|
|
2017-05-04 12:12:27 +02:00
|
|
|
DebuggerStartParameters params;
|
|
|
|
|
params.startMode = AttachToRemoteServer;
|
|
|
|
|
params.closeMode = KillAndExitMonitorAtClose;
|
|
|
|
|
params.remoteSetupNeeded = false;
|
2011-06-16 17:03:43 +02:00
|
|
|
|
2017-05-04 12:12:27 +02:00
|
|
|
if (isQmlDebugging()) {
|
|
|
|
|
params.qmlServer.host = device()->sshParameters().host;
|
|
|
|
|
params.qmlServer.port = Utils::Port(); // port is selected later on
|
|
|
|
|
}
|
|
|
|
|
if (isCppDebugging()) {
|
|
|
|
|
Runnable r = runnable();
|
|
|
|
|
QTC_ASSERT(r.is<StandardRunnable>(), return);
|
|
|
|
|
auto stdRunnable = r.as<StandardRunnable>();
|
|
|
|
|
params.useExtendedRemote = true;
|
|
|
|
|
params.inferior.executable = stdRunnable.executable;
|
|
|
|
|
params.inferior.commandLineArguments = stdRunnable.commandLineArguments;
|
|
|
|
|
if (isQmlDebugging()) {
|
|
|
|
|
params.inferior.commandLineArguments.prepend(' ');
|
|
|
|
|
params.inferior.commandLineArguments.prepend(
|
|
|
|
|
QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices));
|
|
|
|
|
}
|
|
|
|
|
params.remoteChannel = device()->sshParameters().host + ":-1";
|
|
|
|
|
params.symbolFile = symbolFile;
|
|
|
|
|
}
|
2017-04-21 11:39:01 +02:00
|
|
|
|
2017-05-04 12:12:27 +02:00
|
|
|
setStartParameters(params);
|
2011-06-16 17:03:43 +02:00
|
|
|
}
|
|
|
|
|
|
2012-07-26 09:02:34 +02:00
|
|
|
LinuxDeviceDebugSupport::~LinuxDeviceDebugSupport()
|
2011-06-16 17:03:43 +02:00
|
|
|
{
|
2017-04-21 11:39:01 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-04 12:12:27 +02:00
|
|
|
void LinuxDeviceDebugSupport::prepare()
|
2017-04-21 11:39:01 +02:00
|
|
|
{
|
2017-05-04 12:12:27 +02:00
|
|
|
auto targetRunner = qobject_cast<AbstractRemoteLinuxRunSupport *>(runControl()->targetRunner());
|
2011-06-16 17:03:43 +02:00
|
|
|
|
2017-05-03 12:35:00 +02:00
|
|
|
if (isCppDebugging()) {
|
2017-05-04 12:12:27 +02:00
|
|
|
m_gdbServerPort = targetRunner->findPort();
|
|
|
|
|
if (!m_gdbServerPort.isValid()) {
|
|
|
|
|
reportFailure(tr("Not enough free ports on device for C++ debugging."));
|
2011-06-16 17:03:43 +02:00
|
|
|
return;
|
2016-04-20 12:03:58 +02:00
|
|
|
}
|
|
|
|
|
}
|
2017-05-03 12:35:00 +02:00
|
|
|
if (isQmlDebugging()) {
|
2017-05-04 12:12:27 +02:00
|
|
|
m_qmlPort = targetRunner->findPort();
|
|
|
|
|
if (!m_qmlPort.isValid()) {
|
|
|
|
|
reportFailure(tr("Not enough free ports on device for QML debugging."));
|
2016-04-20 12:03:58 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-16 17:03:43 +02:00
|
|
|
|
2017-05-04 12:12:27 +02:00
|
|
|
runControl()->setRunnable(realRunnable());
|
2011-06-16 17:03:43 +02:00
|
|
|
|
2017-05-04 12:12:27 +02:00
|
|
|
RemoteSetupResult result;
|
|
|
|
|
result.success = true;
|
|
|
|
|
result.gdbServerPort = m_gdbServerPort;
|
|
|
|
|
result.qmlServerPort = m_qmlPort;
|
|
|
|
|
setRemoteParameters(result);
|
2013-06-28 13:56:42 +02:00
|
|
|
|
2017-05-04 12:12:27 +02:00
|
|
|
DebuggerRunTool::prepare();
|
2017-03-24 11:26:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Runnable LinuxDeviceDebugSupport::realRunnable() const
|
|
|
|
|
{
|
2017-04-06 11:26:35 +02:00
|
|
|
StandardRunnable r = runControl()->runnable().as<StandardRunnable>();
|
2016-01-27 18:25:13 +01:00
|
|
|
QStringList args = QtcProcess::splitArgs(r.commandLineArguments, OsTypeLinux);
|
2013-06-28 13:56:42 +02:00
|
|
|
QString command;
|
2014-02-27 14:03:25 +01:00
|
|
|
|
2017-05-03 12:35:00 +02:00
|
|
|
if (isQmlDebugging())
|
2017-05-04 12:12:27 +02:00
|
|
|
args.prepend(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices, m_qmlPort));
|
2014-02-27 14:03:25 +01:00
|
|
|
|
2017-05-03 12:35:00 +02:00
|
|
|
if (isQmlDebugging() && !isCppDebugging()) {
|
2016-01-27 18:25:13 +01:00
|
|
|
command = r.executable;
|
2013-08-08 14:05:11 +02:00
|
|
|
} else {
|
2013-06-28 13:56:42 +02:00
|
|
|
command = device()->debugServerPath();
|
|
|
|
|
if (command.isEmpty())
|
|
|
|
|
command = QLatin1String("gdbserver");
|
2014-07-23 17:25:41 +02:00
|
|
|
args.clear();
|
|
|
|
|
args.append(QString::fromLatin1("--multi"));
|
2017-05-04 12:12:27 +02:00
|
|
|
args.append(QString::fromLatin1(":%1").arg(m_gdbServerPort.number()));
|
2013-08-08 14:05:11 +02:00
|
|
|
}
|
2016-01-27 18:25:13 +01:00
|
|
|
r.executable = command;
|
|
|
|
|
r.commandLineArguments = QtcProcess::joinArgs(args, OsTypeLinux);
|
2017-03-24 11:26:33 +01:00
|
|
|
return r;
|
2011-06-16 17:03:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace RemoteLinux
|