diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index f92088001c2..8468cd40032 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -1021,30 +1021,112 @@ void DebuggerRunTool::showMessage(const QString &msg, int channel, int timeout) } } +namespace Internal { + +/*! + \class Debugger::SubChannelProvider + + \internal + + This is a helper RunWorker implementation to either use or not + use port forwarding for one SubChannel in the ChannelProvider + implementation. + + By default it is assumed that no forwarding is needed, i.e. + end points provided by the shared endpoint resource provider + are directly accessible. +*/ + +class SubChannelProvider : public RunWorker +{ +public: + SubChannelProvider(RunControl *runControl, PortsGatherer *portsGatherer) + : RunWorker(runControl) + , m_portGatherer(portsGatherer) + { + setId("SubChannelProvider"); + } + + void start() final + { + m_channel.setScheme(urlTcpScheme()); + if (device()->extraData(RemoteLinux::Constants::SshForwardDebugServerPort).toBool()) + m_channel.setHost("localhost"); + else + m_channel.setHost(device()->toolControlChannel(IDevice::ControlChannelHint()).host()); + if (m_portGatherer) + m_channel.setPort(m_portGatherer->findEndPoint().port()); + reportStarted(); + } + + QUrl channel() const { return m_channel; } + +private: + QUrl m_channel; + PortsGatherer *m_portGatherer = nullptr; +}; + +} // Internal + //////////////////////////////////////////////////////////////////////// // // Externally visible helper. // //////////////////////////////////////////////////////////////////////// -// GdbServerPortGatherer +/*! + \class Debugger::DebugServerPortsGatherer + + \internal + + The class implements a \c RunWorker to provide + to provide a set of urls indicating usable connection end + points for 'server-using' tools (typically one, like plain + gdbserver and the Qml tooling, but two for mixed debugging). + + Urls can describe local or tcp servers that are directly + accessible to the host tools. + + The tool implementations can assume that any needed port + forwarding setup is setup and handled transparently by + a \c DebugServerPortsGatherer instance. + + If there are multiple subchannels needed that need to share a + common set of resources on the remote side, a device implementation + can provide a "SharedEndpointGatherer" RunWorker. + + If none is provided, it is assumed that the shared resource + is open TCP ports, provided by the device's PortGatherer i + implementation. + + FIXME: The current implementation supports only the case + of "any number of TCP channels that do not need actual + forwarding. +*/ DebugServerPortsGatherer::DebugServerPortsGatherer(RunControl *runControl) - : ChannelProvider(runControl, 2) + : RunWorker(runControl) { setId("DebugServerPortsGatherer"); + auto portsGatherer = new PortsGatherer(runControl); + + for (int i = 0; i < 2; ++i) { + auto channelProvider = new Internal::SubChannelProvider(runControl, portsGatherer); + m_channelProviders[i] = channelProvider; + addStartDependency(channelProvider); + } } DebugServerPortsGatherer::~DebugServerPortsGatherer() = default; QUrl DebugServerPortsGatherer::gdbServer() const { - return channel(0); + return m_channelProviders[0]->channel(); } QUrl DebugServerPortsGatherer::qmlServer() const { - return channel(1); + return m_channelProviders[1]->channel(); } void DebuggerRunTool::startDebugServerIfNeededAndContinueStartup() diff --git a/src/plugins/debugger/debuggerruncontrol.h b/src/plugins/debugger/debuggerruncontrol.h index dcd2a8e6875..db5658a2e87 100644 --- a/src/plugins/debugger/debuggerruncontrol.h +++ b/src/plugins/debugger/debuggerruncontrol.h @@ -15,7 +15,10 @@ namespace Debugger { -namespace Internal { class DebuggerRunToolPrivate; } +namespace Internal { +class DebuggerRunToolPrivate; +class SubChannelProvider; +} class DebugServerPortsGatherer; @@ -124,7 +127,7 @@ private: Internal::DebuggerRunParameters m_runParameters; }; -class DEBUGGER_EXPORT DebugServerPortsGatherer : public ProjectExplorer::ChannelProvider +class DEBUGGER_EXPORT DebugServerPortsGatherer : public ProjectExplorer::RunWorker { public: explicit DebugServerPortsGatherer(ProjectExplorer::RunControl *runControl); @@ -139,6 +142,7 @@ public: QUrl qmlServer() const; private: + std::array m_channelProviders; bool m_useGdbServer = false; bool m_useQmlServer = false; }; diff --git a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp index 714d311a1ef..abfbb099842 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp +++ b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp @@ -150,107 +150,4 @@ void PortsGatherer::stop() reportStopped(); } -namespace Internal { - -// SubChannelProvider - -/*! - \class ProjectExplorer::SubChannelProvider - - \internal - - This is a helper RunWorker implementation to either use or not - use port forwarding for one SubChannel in the ChannelProvider - implementation. - - By default it is assumed that no forwarding is needed, i.e. - end points provided by the shared endpoint resource provider - are directly accessible. -*/ - -class SubChannelProvider : public RunWorker -{ -public: - SubChannelProvider(RunControl *runControl, PortsGatherer *portsGatherer) - : RunWorker(runControl) - , m_portGatherer(portsGatherer) - { - setId("SubChannelProvider"); - } - - void start() final - { - m_channel.setScheme(urlTcpScheme()); - if (device()->extraData(RemoteLinux::Constants::SshForwardDebugServerPort).toBool()) - m_channel.setHost("localhost"); - else - m_channel.setHost(device()->toolControlChannel(IDevice::ControlChannelHint()).host()); - if (m_portGatherer) - m_channel.setPort(m_portGatherer->findEndPoint().port()); - reportStarted(); - } - - QUrl channel() const { return m_channel; } - -private: - QUrl m_channel; - PortsGatherer *m_portGatherer = nullptr; -}; - -} // Internal - -// ChannelProvider - -/*! - \class ProjectExplorer::ChannelProvider - - \internal - - The class implements a \c RunWorker to provide - to provide a set of urls indicating usable connection end - points for 'server-using' tools (typically one, like plain - gdbserver and the Qml tooling, but two for mixed debugging). - - Urls can describe local or tcp servers that are directly - accessible to the host tools. - - The tool implementations can assume that any needed port - forwarding setup is setup and handled transparently by - a \c ChannelProvider instance. - - If there are multiple subchannels needed that need to share a - common set of resources on the remote side, a device implementation - can provide a "SharedEndpointGatherer" RunWorker. - - If none is provided, it is assumed that the shared resource - is open TCP ports, provided by the device's PortGatherer i - implementation. - - FIXME: The current implementation supports only the case - of "any number of TCP channels that do not need actual - forwarding. -*/ - -ChannelProvider::ChannelProvider(RunControl *runControl, int requiredChannels) - : RunWorker(runControl) -{ - setId("ChannelProvider"); - auto portsGatherer = new PortsGatherer(runControl); - - for (int i = 0; i < requiredChannels; ++i) { - auto channelProvider = new Internal::SubChannelProvider(runControl, portsGatherer); - m_channelProviders.append(channelProvider); - addStartDependency(channelProvider); - } -} - -ChannelProvider::~ChannelProvider() = default; - -QUrl ChannelProvider::channel(int i) const -{ - if (Internal::SubChannelProvider *provider = m_channelProviders.value(i)) - return provider->channel(); - return {}; -} - } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.h b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.h index 73aacdfbfeb..0c08aadeb68 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.h +++ b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.h @@ -15,10 +15,7 @@ using namespace Tasking; namespace ProjectExplorer { -namespace Internal { -class DeviceUsedPortsGathererPrivate; -class SubChannelProvider; -} // Internal +namespace Internal { class DeviceUsedPortsGathererPrivate; } class PROJECTEXPLORER_EXPORT DeviceUsedPortsGatherer : public QObject { @@ -71,20 +68,6 @@ private: Utils::PortList m_portList; }; -class PROJECTEXPLORER_EXPORT ChannelProvider : public RunWorker -{ - Q_OBJECT - -public: - ChannelProvider(RunControl *runControl, int requiredChannels = 1); - ~ChannelProvider() override; - - QUrl channel(int i = 0) const; - -private: - QVector m_channelProviders; -}; - using DeviceUsedPortsGathererTask = CustomTask; } // namespace ProjectExplorer