summaryrefslogtreecommitdiff
path: root/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
blob: af476d48b94d3b7833f168c99934bc90a947c194 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "remotelinuxdebugsupport.h"

#include "remotelinux_constants.h"

#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfigurationaspects.h>

#include <debugger/debuggerruncontrol.h>

#include <qmldebug/qmldebugcommandlinearguments.h>

using namespace Debugger;
using namespace ProjectExplorer;
using namespace Utils;

namespace RemoteLinux::Internal {

class RemoteLinuxDebugWorker final : public DebuggerRunTool
{
public:
    explicit RemoteLinuxDebugWorker(RunControl *runControl)
        : DebuggerRunTool(runControl, DoNotAllowTerminal)
    {
        setId("RemoteLinuxDebugWorker");

        setUsePortsGatherer(isCppDebugging(), isQmlDebugging());
        addQmlServerInferiorCommandLineArgumentIfNeeded();

        auto debugServer = new DebugServerRunner(runControl, portsGatherer());
        debugServer->setEssential(true);

        addStartDependency(debugServer);

        setStartMode(AttachToRemoteServer);
        setCloseMode(KillAndExitMonitorAtClose);
        setUseExtendedRemote(true);
        setLldbPlatform("remote-linux");
    }
};

class RemoteLinuxQmlToolingSupport final : public SimpleTargetRunner
{
public:
    explicit RemoteLinuxQmlToolingSupport(RunControl *runControl)
        : SimpleTargetRunner(runControl)
    {
        setId("RemoteLinuxQmlToolingSupport");

        auto portsGatherer = new PortsGatherer(runControl);
        addStartDependency(portsGatherer);

        // The ports gatherer can safely be stopped once the process is running, even though it has to
        // be started before.
        addStopDependency(portsGatherer);

        auto runworker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode()));
        runworker->addStartDependency(this);
        addStopDependency(runworker);

        setStartModifier([this, runControl, portsGatherer, runworker] {
            const QUrl serverUrl = portsGatherer->findEndPoint();
            runworker->recordData("QmlServerUrl", serverUrl);

            QmlDebug::QmlDebugServicesPreset services = QmlDebug::servicesForRunMode(runControl->runMode());

            CommandLine cmd = commandLine();
            cmd.addArg(QmlDebug::qmlDebugTcpArguments(services, serverUrl));
            setCommandLine(cmd);
        });
    }
};

// Factories

static const QList<Id> supportedRunConfigs()
{
    return {
        Constants::RunConfigId,
        Constants::CustomRunConfigId,
        "QmlProjectManager.QmlRunConfiguration"
    };
}

RemoteLinuxRunWorkerFactory::RemoteLinuxRunWorkerFactory()
{
    setProduct<SimpleTargetRunner>();
    addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE);
    addSupportedDeviceType(Constants::GenericLinuxOsType);
    setSupportedRunConfigs(supportedRunConfigs());
}

RemoteLinuxDebugWorkerFactory::RemoteLinuxDebugWorkerFactory()
{
    setProduct<RemoteLinuxDebugWorker>();
    addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
    addSupportedDeviceType(Constants::GenericLinuxOsType);
    setSupportedRunConfigs(supportedRunConfigs());
}

RemoteLinuxQmlToolingWorkerFactory::RemoteLinuxQmlToolingWorkerFactory()
{
    setProduct<RemoteLinuxQmlToolingSupport>();
    addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
    addSupportedRunMode(ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE);
    addSupportedDeviceType(Constants::GenericLinuxOsType);
    setSupportedRunConfigs(supportedRunConfigs());
}

} // RemoteLinux::Internal