2019-06-04 14:22:35 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2019 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** 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 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.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qdbdevicedebugsupport.h"
|
|
|
|
|
|
|
|
|
|
#include "qdbconstants.h"
|
|
|
|
|
#include "qdbdevice.h"
|
|
|
|
|
#include "qdbrunconfiguration.h"
|
|
|
|
|
|
|
|
|
|
#include <debugger/debuggerruncontrol.h>
|
|
|
|
|
|
|
|
|
|
#include <ssh/sshconnection.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
#include <utils/url.h>
|
|
|
|
|
|
|
|
|
|
using namespace Debugger;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
using namespace Qdb::Internal;
|
|
|
|
|
|
|
|
|
|
namespace Qdb {
|
|
|
|
|
|
|
|
|
|
class QdbDeviceInferiorRunner : public RunWorker
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QdbDeviceInferiorRunner(RunControl *runControl,
|
|
|
|
|
bool usePerf, bool useGdbServer, bool useQmlServer,
|
|
|
|
|
QmlDebug::QmlDebugServicesPreset qmlServices)
|
|
|
|
|
: RunWorker(runControl),
|
|
|
|
|
m_usePerf(usePerf), m_useGdbServer(useGdbServer), m_useQmlServer(useQmlServer),
|
|
|
|
|
m_qmlServices(qmlServices)
|
|
|
|
|
{
|
|
|
|
|
setId("QdbDebuggeeRunner");
|
|
|
|
|
|
2021-11-09 17:54:01 +01:00
|
|
|
connect(&m_launcher, &ApplicationLauncher::processStarted,
|
2019-06-04 14:22:35 +02:00
|
|
|
this, &RunWorker::reportStarted);
|
2022-02-15 14:43:18 +01:00
|
|
|
connect(&m_launcher, &ApplicationLauncher::finished,
|
2019-06-04 14:22:35 +02:00
|
|
|
this, &RunWorker::reportStopped);
|
|
|
|
|
connect(&m_launcher, &ApplicationLauncher::appendMessage,
|
|
|
|
|
this, &RunWorker::appendMessage);
|
2019-12-13 10:30:30 +01:00
|
|
|
m_portsGatherer = new DebugServerPortsGatherer(runControl);
|
2019-06-04 14:22:35 +02:00
|
|
|
m_portsGatherer->setUseGdbServer(useGdbServer || usePerf);
|
|
|
|
|
m_portsGatherer->setUseQmlServer(useQmlServer);
|
|
|
|
|
addStartDependency(m_portsGatherer);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-23 11:13:29 +02:00
|
|
|
QUrl perfServer() const { return m_portsGatherer->gdbServer(); }
|
2019-06-04 14:22:35 +02:00
|
|
|
QUrl gdbServer() const { return m_portsGatherer->gdbServer(); }
|
|
|
|
|
QUrl qmlServer() const { return m_portsGatherer->qmlServer(); }
|
|
|
|
|
|
|
|
|
|
void start() override
|
|
|
|
|
{
|
2019-08-23 11:13:29 +02:00
|
|
|
const int perfPort = m_portsGatherer->gdbServer().port();
|
|
|
|
|
const int gdbServerPort = m_portsGatherer->gdbServer().port();
|
|
|
|
|
const int qmlServerPort = m_portsGatherer->qmlServer().port();
|
2019-06-04 14:22:35 +02:00
|
|
|
|
|
|
|
|
int lowerPort = 0;
|
|
|
|
|
int upperPort = 0;
|
|
|
|
|
|
|
|
|
|
Runnable r = runnable();
|
|
|
|
|
|
|
|
|
|
QString args;
|
|
|
|
|
if (m_useGdbServer) {
|
|
|
|
|
args.append(" --debug-gdb");
|
|
|
|
|
lowerPort = upperPort = gdbServerPort;
|
|
|
|
|
}
|
|
|
|
|
if (m_useQmlServer) {
|
|
|
|
|
args.append(" --debug-qml --qml-debug-services ");
|
|
|
|
|
args.append(QmlDebug::qmlDebugServices(m_qmlServices));
|
|
|
|
|
lowerPort = upperPort = qmlServerPort;
|
|
|
|
|
}
|
|
|
|
|
if (m_useGdbServer && m_useQmlServer) {
|
|
|
|
|
if (gdbServerPort + 1 != qmlServerPort) {
|
|
|
|
|
reportFailure("Need adjacent free ports for combined C++/QML debugging");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
lowerPort = gdbServerPort;
|
|
|
|
|
upperPort = qmlServerPort;
|
|
|
|
|
}
|
|
|
|
|
if (m_usePerf) {
|
2019-08-27 16:44:42 +02:00
|
|
|
QVariantMap settingsData = runControl()->settingsData("Analyzer.Perf.Settings");
|
|
|
|
|
QVariant perfRecordArgs = settingsData.value("Analyzer.Perf.RecordArguments");
|
|
|
|
|
QString args = Utils::transform(perfRecordArgs.toStringList(), [](QString arg) {
|
2019-06-04 14:22:35 +02:00
|
|
|
return arg.replace(',', ",,");
|
2019-08-27 16:44:42 +02:00
|
|
|
}).join(',');
|
|
|
|
|
args.append(QString(" --profile-perf %1").arg(args));
|
2019-06-04 14:22:35 +02:00
|
|
|
lowerPort = upperPort = perfPort;
|
|
|
|
|
}
|
|
|
|
|
args.append(QString(" --port-range %1-%2 ").arg(lowerPort).arg(upperPort));
|
2021-08-10 09:19:30 +02:00
|
|
|
// FIXME: Breaks with spaces!
|
|
|
|
|
args.append(r.command.executable().toString());
|
2019-06-04 14:22:35 +02:00
|
|
|
args.append(" ");
|
2021-08-10 09:19:30 +02:00
|
|
|
args.append(r.command.arguments());
|
2019-06-04 14:22:35 +02:00
|
|
|
|
2021-08-10 09:19:30 +02:00
|
|
|
r.command.setArguments(args);
|
|
|
|
|
r.command.setExecutable(FilePath::fromString(Constants::AppcontrollerFilepath));
|
2019-06-04 14:22:35 +02:00
|
|
|
|
2022-02-15 12:44:04 +01:00
|
|
|
m_launcher.setRunnable(r);
|
|
|
|
|
m_launcher.start(device());
|
2019-06-04 14:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void stop() override { m_launcher.stop(); }
|
|
|
|
|
|
|
|
|
|
private:
|
2019-12-13 10:30:30 +01:00
|
|
|
Debugger::DebugServerPortsGatherer *m_portsGatherer = nullptr;
|
2019-06-04 14:22:35 +02:00
|
|
|
bool m_usePerf;
|
|
|
|
|
bool m_useGdbServer;
|
|
|
|
|
bool m_useQmlServer;
|
|
|
|
|
QmlDebug::QmlDebugServicesPreset m_qmlServices;
|
|
|
|
|
ApplicationLauncher m_launcher;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// QdbDeviceDebugSupport
|
|
|
|
|
|
|
|
|
|
QdbDeviceDebugSupport::QdbDeviceDebugSupport(RunControl *runControl)
|
|
|
|
|
: Debugger::DebuggerRunTool(runControl)
|
|
|
|
|
{
|
|
|
|
|
setId("QdbDeviceDebugSupport");
|
|
|
|
|
|
|
|
|
|
m_debuggee = new QdbDeviceInferiorRunner(runControl, false, isCppDebugging(), isQmlDebugging(),
|
|
|
|
|
QmlDebug::QmlDebuggerServices);
|
|
|
|
|
addStartDependency(m_debuggee);
|
|
|
|
|
|
|
|
|
|
m_debuggee->addStopDependency(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QdbDeviceDebugSupport::start()
|
|
|
|
|
{
|
|
|
|
|
setStartMode(Debugger::AttachToRemoteServer);
|
|
|
|
|
setCloseMode(KillAndExitMonitorAtClose);
|
|
|
|
|
setRemoteChannel(m_debuggee->gdbServer());
|
|
|
|
|
setQmlServer(m_debuggee->qmlServer());
|
|
|
|
|
setUseContinueInsteadOfRun(true);
|
|
|
|
|
setContinueAfterAttach(true);
|
|
|
|
|
addSolibSearchDir("%{sysroot}/system/lib");
|
|
|
|
|
|
|
|
|
|
DebuggerRunTool::start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QdbDeviceDebugSupport::stop()
|
|
|
|
|
{
|
|
|
|
|
// Do nothing unusual. The launcher will die as result of (gdb) kill.
|
|
|
|
|
DebuggerRunTool::stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// QdbDeviceQmlProfilerSupport
|
|
|
|
|
|
ProjectExplorer: Standardize RunWorker creation logic
This unifies the remaining paths of RunWorker creation to always
use RunWorkerFactories in the plugin pimpls.
There were, and are, still effectively three basic kinds of workers:
- "toplevel" tools corresponding to the run modes, that are often all
that's used for local runs and directly started via the fat buttons
or e.g. entries in the analyze menu, with factories already previously
located in the plugin pimpls
- core "tool helpers", providing tool specific functionality typically
used in conjunction with a remote device specific run mechanism,
set up via RunControl::registerWorkerCreator
- target/device specific runhelper like port gatherers contructed e.g.
via *Device::workerCreator(Core::Id id)
Worse, these categories are partially overlapping, so it was not
clear how a "clean" setup would look like, instead some ad-hoc cobbling
"to make it work" happened.
In some cases, the runMode id was used throughout the whole ensemble
of run workers for a given run, and which worker exactly was created
depended on which of the mechanism above was used in which order.
With the new central setup, the top-level runmodes remain, but the
second kind gets new ids, so the implicit dependencies on order
of setup mechanism are avoided.
This also helps in the cases where there was previously unclarity of where
and how to set up worker factories: It's always and only the plugin
pimpl now.
Change-Id: Icd9a08e2d53e19abe8b21fe546f469fae353a69f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-08-23 15:31:35 +02:00
|
|
|
QdbDeviceQmlToolingSupport::QdbDeviceQmlToolingSupport(RunControl *runControl)
|
2019-06-04 14:22:35 +02:00
|
|
|
: RunWorker(runControl)
|
|
|
|
|
{
|
|
|
|
|
setId("QdbDeviceQmlToolingSupport");
|
|
|
|
|
|
ProjectExplorer: Standardize RunWorker creation logic
This unifies the remaining paths of RunWorker creation to always
use RunWorkerFactories in the plugin pimpls.
There were, and are, still effectively three basic kinds of workers:
- "toplevel" tools corresponding to the run modes, that are often all
that's used for local runs and directly started via the fat buttons
or e.g. entries in the analyze menu, with factories already previously
located in the plugin pimpls
- core "tool helpers", providing tool specific functionality typically
used in conjunction with a remote device specific run mechanism,
set up via RunControl::registerWorkerCreator
- target/device specific runhelper like port gatherers contructed e.g.
via *Device::workerCreator(Core::Id id)
Worse, these categories are partially overlapping, so it was not
clear how a "clean" setup would look like, instead some ad-hoc cobbling
"to make it work" happened.
In some cases, the runMode id was used throughout the whole ensemble
of run workers for a given run, and which worker exactly was created
depended on which of the mechanism above was used in which order.
With the new central setup, the top-level runmodes remain, but the
second kind gets new ids, so the implicit dependencies on order
of setup mechanism are avoided.
This also helps in the cases where there was previously unclarity of where
and how to set up worker factories: It's always and only the plugin
pimpl now.
Change-Id: Icd9a08e2d53e19abe8b21fe546f469fae353a69f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-08-23 15:31:35 +02:00
|
|
|
QmlDebug::QmlDebugServicesPreset services = QmlDebug::servicesForRunMode(runControl->runMode());
|
2019-06-04 14:22:35 +02:00
|
|
|
m_runner = new QdbDeviceInferiorRunner(runControl, false, false, true, services);
|
|
|
|
|
addStartDependency(m_runner);
|
|
|
|
|
addStopDependency(m_runner);
|
|
|
|
|
|
ProjectExplorer: Standardize RunWorker creation logic
This unifies the remaining paths of RunWorker creation to always
use RunWorkerFactories in the plugin pimpls.
There were, and are, still effectively three basic kinds of workers:
- "toplevel" tools corresponding to the run modes, that are often all
that's used for local runs and directly started via the fat buttons
or e.g. entries in the analyze menu, with factories already previously
located in the plugin pimpls
- core "tool helpers", providing tool specific functionality typically
used in conjunction with a remote device specific run mechanism,
set up via RunControl::registerWorkerCreator
- target/device specific runhelper like port gatherers contructed e.g.
via *Device::workerCreator(Core::Id id)
Worse, these categories are partially overlapping, so it was not
clear how a "clean" setup would look like, instead some ad-hoc cobbling
"to make it work" happened.
In some cases, the runMode id was used throughout the whole ensemble
of run workers for a given run, and which worker exactly was created
depended on which of the mechanism above was used in which order.
With the new central setup, the top-level runmodes remain, but the
second kind gets new ids, so the implicit dependencies on order
of setup mechanism are avoided.
This also helps in the cases where there was previously unclarity of where
and how to set up worker factories: It's always and only the plugin
pimpl now.
Change-Id: Icd9a08e2d53e19abe8b21fe546f469fae353a69f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-08-23 15:31:35 +02:00
|
|
|
m_worker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode()));
|
2019-06-04 14:22:35 +02:00
|
|
|
m_worker->addStartDependency(this);
|
|
|
|
|
addStopDependency(m_worker);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QdbDeviceQmlToolingSupport::start()
|
|
|
|
|
{
|
|
|
|
|
m_worker->recordData("QmlServerUrl", m_runner->qmlServer());
|
|
|
|
|
reportStarted();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// QdbDevicePerfProfilerSupport
|
|
|
|
|
|
|
|
|
|
QdbDevicePerfProfilerSupport::QdbDevicePerfProfilerSupport(RunControl *runControl)
|
|
|
|
|
: RunWorker(runControl)
|
|
|
|
|
{
|
|
|
|
|
setId("QdbDevicePerfProfilerSupport");
|
|
|
|
|
|
|
|
|
|
m_profilee = new QdbDeviceInferiorRunner(runControl, true, false, false,
|
|
|
|
|
QmlDebug::NoQmlDebugServices);
|
|
|
|
|
addStartDependency(m_profilee);
|
|
|
|
|
addStopDependency(m_profilee);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QdbDevicePerfProfilerSupport::start()
|
|
|
|
|
{
|
2019-08-23 11:13:29 +02:00
|
|
|
runControl()->setProperty("PerfConnection", m_profilee->perfServer());
|
2019-06-04 14:22:35 +02:00
|
|
|
reportStarted();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Qdb
|