forked from qt-creator/qt-creator
ProjectExplorer: Dismantle ChannelProvider
Merge it with DebugServerPortsGatherer. Change-Id: I0b5448574cc4eca1f13040bc977f4427172df9ce Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -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.
|
// 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)
|
DebugServerPortsGatherer::DebugServerPortsGatherer(RunControl *runControl)
|
||||||
: ChannelProvider(runControl, 2)
|
: RunWorker(runControl)
|
||||||
{
|
{
|
||||||
setId("DebugServerPortsGatherer");
|
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;
|
DebugServerPortsGatherer::~DebugServerPortsGatherer() = default;
|
||||||
|
|
||||||
QUrl DebugServerPortsGatherer::gdbServer() const
|
QUrl DebugServerPortsGatherer::gdbServer() const
|
||||||
{
|
{
|
||||||
return channel(0);
|
return m_channelProviders[0]->channel();
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl DebugServerPortsGatherer::qmlServer() const
|
QUrl DebugServerPortsGatherer::qmlServer() const
|
||||||
{
|
{
|
||||||
return channel(1);
|
return m_channelProviders[1]->channel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerRunTool::startDebugServerIfNeededAndContinueStartup()
|
void DebuggerRunTool::startDebugServerIfNeededAndContinueStartup()
|
||||||
|
@@ -15,7 +15,10 @@
|
|||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
|
||||||
namespace Internal { class DebuggerRunToolPrivate; }
|
namespace Internal {
|
||||||
|
class DebuggerRunToolPrivate;
|
||||||
|
class SubChannelProvider;
|
||||||
|
}
|
||||||
|
|
||||||
class DebugServerPortsGatherer;
|
class DebugServerPortsGatherer;
|
||||||
|
|
||||||
@@ -124,7 +127,7 @@ private:
|
|||||||
Internal::DebuggerRunParameters m_runParameters;
|
Internal::DebuggerRunParameters m_runParameters;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DEBUGGER_EXPORT DebugServerPortsGatherer : public ProjectExplorer::ChannelProvider
|
class DEBUGGER_EXPORT DebugServerPortsGatherer : public ProjectExplorer::RunWorker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit DebugServerPortsGatherer(ProjectExplorer::RunControl *runControl);
|
explicit DebugServerPortsGatherer(ProjectExplorer::RunControl *runControl);
|
||||||
@@ -139,6 +142,7 @@ public:
|
|||||||
QUrl qmlServer() const;
|
QUrl qmlServer() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::array<Internal::SubChannelProvider *, 2> m_channelProviders;
|
||||||
bool m_useGdbServer = false;
|
bool m_useGdbServer = false;
|
||||||
bool m_useQmlServer = false;
|
bool m_useQmlServer = false;
|
||||||
};
|
};
|
||||||
|
@@ -150,107 +150,4 @@ void PortsGatherer::stop()
|
|||||||
reportStopped();
|
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
|
} // namespace ProjectExplorer
|
||||||
|
@@ -15,10 +15,7 @@ using namespace Tasking;
|
|||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal { class DeviceUsedPortsGathererPrivate; }
|
||||||
class DeviceUsedPortsGathererPrivate;
|
|
||||||
class SubChannelProvider;
|
|
||||||
} // Internal
|
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT DeviceUsedPortsGatherer : public QObject
|
class PROJECTEXPLORER_EXPORT DeviceUsedPortsGatherer : public QObject
|
||||||
{
|
{
|
||||||
@@ -71,20 +68,6 @@ private:
|
|||||||
Utils::PortList m_portList;
|
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<Internal::SubChannelProvider *> m_channelProviders;
|
|
||||||
};
|
|
||||||
|
|
||||||
using DeviceUsedPortsGathererTask = CustomTask<DeviceUsedPortsGathererTaskAdapter>;
|
using DeviceUsedPortsGathererTask = CustomTask<DeviceUsedPortsGathererTaskAdapter>;
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
Reference in New Issue
Block a user