Debugger: Let the DebuggerRunTool optionally handle the PortsGatherer

Less code in the target implementations.

Change-Id: I759f082eba5eab7f4e8252c0d7b5ec64059ba860
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2017-10-19 14:23:43 +02:00
parent c99b8c2fd1
commit f521b2428d
3 changed files with 41 additions and 23 deletions

View File

@@ -243,6 +243,8 @@ class DebuggerRunToolPrivate
public:
QPointer<TerminalRunner> terminalRunner;
QPointer<CoreUnpacker> coreUnpacker;
QPointer<GdbServerPortsGatherer> portsGatherer;
bool addQmlServerInferiorCommandLineArgumentIfNeeded = false;
};
} // namespace Internal
@@ -469,14 +471,7 @@ void DebuggerRunTool::prependInferiorCommandLineArgument(const QString &arg)
void DebuggerRunTool::addQmlServerInferiorCommandLineArgumentIfNeeded()
{
if (isQmlDebugging() && isCppDebugging()) {
using namespace QmlDebug;
int qmlServerPort = m_runParameters.qmlServer.port();
QTC_ASSERT(qmlServerPort > 0, reportFailure(); return);
QString mode = QString("port:%1").arg(qmlServerPort);
QString qmlServerArg = qmlDebugCommandLineArguments(QmlDebuggerServices, mode, true);
prependInferiorCommandLineArgument(qmlServerArg);
}
d->addQmlServerInferiorCommandLineArgumentIfNeeded = true;
}
void DebuggerRunTool::setCrashParameter(const QString &event)
@@ -501,6 +496,21 @@ void DebuggerRunTool::start()
TaskHub::clearTasks(Debugger::Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO);
TaskHub::clearTasks(Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME);
if (d->portsGatherer) {
setRemoteChannel(d->portsGatherer->gdbServerChannel());
setQmlServer(d->portsGatherer->qmlServer());
if (d->addQmlServerInferiorCommandLineArgumentIfNeeded
&& m_runParameters.isQmlDebugging
&& m_runParameters.isCppDebugging) {
using namespace QmlDebug;
int qmlServerPort = m_runParameters.qmlServer.port();
QTC_ASSERT(qmlServerPort > 0, reportFailure(); return);
QString mode = QString("port:%1").arg(qmlServerPort);
QString qmlServerArg = qmlDebugCommandLineArguments(QmlDebuggerServices, mode, true);
prependInferiorCommandLineArgument(qmlServerArg);
}
}
// User canceled input dialog asking for executable when working on library project.
if (m_runParameters.startMode == StartInternal
&& m_runParameters.inferior.executable.isEmpty()
@@ -630,6 +640,20 @@ int DebuggerRunTool::portsUsedByDebugger() const
return isCppDebugging() + isQmlDebugging();
}
void DebuggerRunTool::setUsePortsGatherer(bool useCpp, bool useQml)
{
QTC_ASSERT(!d->portsGatherer, reportFailure(); return);
d->portsGatherer = new GdbServerPortsGatherer(runControl());
d->portsGatherer->setUseGdbServer(useCpp);
d->portsGatherer->setUseQmlServer(useQml);
addStartDependency(d->portsGatherer);
}
GdbServerPortsGatherer *DebuggerRunTool::portsGatherer() const
{
return d->portsGatherer;
}
void DebuggerRunTool::setSolibSearchPath(const QStringList &list)
{
m_runParameters.solibSearchPath = list;