Commit ce62181c authored by hjk's avatar hjk

Debugger: Add a few convience setters for some run parameters

The idea is to use them later to make the DebugRunTool setup leaner.
As proof of concept, use the new interface in LinuxDeviceDebugSupport.

Change-Id: I045ba4d05cfc56a9e875fd4461e9f562153872dd
Reviewed-by: Christian Kandeler's avatarChristian Kandeler <christian.kandeler@qt.io>
parent b725018e
......@@ -183,6 +183,70 @@ void DebuggerRunTool::setBreakOnMainNextTime()
breakOnMainNextTime = true;
}
void DebuggerRunTool::setStartMode(DebuggerStartMode startMode)
{
m_runParameters.startMode = startMode;
}
void DebuggerRunTool::setCloseMode(DebuggerCloseMode closeMode)
{
m_runParameters.closeMode = closeMode;
}
void DebuggerRunTool::setSymbolFile(const QString &symbolFile)
{
if (symbolFile.isEmpty())
reportFailure(tr("Cannot debug: Local executable is not set."));
m_runParameters.symbolFile = symbolFile;
}
void DebuggerRunTool::setGdbServerChannel(const QString &channel)
{
m_runParameters.remoteChannel = channel;
}
void DebuggerRunTool::setUseExtendedRemote(bool on)
{
m_runParameters.useExtendedRemote = on;
}
void DebuggerRunTool::setQmlServer(const QUrl &qmlServer)
{
m_runParameters.qmlServer = qmlServer;
}
void DebuggerRunTool::setInferior(const Runnable &runnable)
{
QTC_ASSERT(runnable.is<StandardRunnable>(), reportFailure(); return);
m_runParameters.inferior = runnable.as<StandardRunnable>();
}
void DebuggerRunTool::appendInferiorCommandLineArgument(const QString &arg)
{
if (!m_runParameters.inferior.commandLineArguments.isEmpty())
m_runParameters.inferior.commandLineArguments.append(' ');
m_runParameters.inferior.commandLineArguments.append(arg);
}
void DebuggerRunTool::prependInferiorCommandLineArgument(const QString &arg)
{
if (!m_runParameters.inferior.commandLineArguments.isEmpty())
m_runParameters.inferior.commandLineArguments.prepend(' ');
m_runParameters.inferior.commandLineArguments.prepend(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);
}
}
static QLatin1String engineTypeName(DebuggerEngineType et)
{
switch (et) {
......@@ -589,6 +653,10 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl)
" Would you still like to terminate it?"),
QString(), QString(), optionalPrompt);
});
Runnable r = runnable();
if (r.is<StandardRunnable>())
m_runParameters.inferior = r.as<StandardRunnable>();
}
DebuggerRunTool::DebuggerRunTool(RunControl *runControl, const DebuggerStartParameters &sp)
......@@ -761,6 +829,19 @@ GdbServerPortsGatherer::~GdbServerPortsGatherer()
{
}
QString GdbServerPortsGatherer::gdbServerChannel() const
{
const QString host = device()->sshParameters().host;
return QString("%1:%2").arg(host).arg(m_gdbServerPort.number());
}
QUrl GdbServerPortsGatherer::qmlServer() const
{
QUrl server = device()->toolControlChannel(IDevice::QmlControlChannel);
server.setPort(m_qmlServerPort.number());
return server;
}
void GdbServerPortsGatherer::start()
{
appendMessage(tr("Checking available ports..."), NormalMessageFormat);
......
......@@ -81,6 +81,20 @@ public:
static void setBreakOnMainNextTime();
void setInferior(const ProjectExplorer::Runnable &runnable);
void appendInferiorCommandLineArgument(const QString &arg);
void prependInferiorCommandLineArgument(const QString &arg);
void addQmlServerInferiorCommandLineArgumentIfNeeded();
void setStartMode(DebuggerStartMode startMode);
void setCloseMode(DebuggerCloseMode closeMode);
void setSymbolFile(const QString &symbolFile);
void setGdbServerChannel(const QString &channel);
void setUseExtendedRemote(bool on);
void setQmlServer(const QUrl &qmlServer);
signals:
void aboutToNotifyInferiorSetupOk();
......@@ -106,10 +120,12 @@ public:
void setUseGdbServer(bool useIt) { m_useGdbServer = useIt; }
bool useGdbServer() const { return m_useGdbServer; }
Utils::Port gdbServerPort() const { return m_gdbServerPort; }
QString gdbServerChannel() const;
void setUseQmlServer(bool useIt) { m_useQmlServer = useIt; }
bool useQmlServer() const { return m_useQmlServer; }
Utils::Port qmlServerPort() const { return m_qmlServerPort; }
QUrl qmlServer() const;
private:
void start() override;
......
......@@ -28,22 +28,8 @@
#include "remotelinuxcustomrunconfiguration.h"
#include "remotelinuxrunconfiguration.h"
#include <debugger/debuggerruncontrol.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/project.h>
#include <projectexplorer/runnables.h>
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
using namespace Debugger;
using namespace ProjectExplorer;
using namespace Utils;
namespace RemoteLinux {
......@@ -61,51 +47,22 @@ LinuxDeviceDebugSupport::LinuxDeviceDebugSupport(RunControl *runControl)
addStartDependency(gdbServer);
setStartMode(AttachToRemoteServer);
setCloseMode(KillAndExitMonitorAtClose);
setUseExtendedRemote(true);
RunConfiguration *runConfig = runControl->runConfiguration();
if (auto rlrc = qobject_cast<RemoteLinuxRunConfiguration *>(runConfig))
m_symbolFile = rlrc->localExecutableFilePath();
setSymbolFile(rlrc->localExecutableFilePath());
else if (auto rlrc = qobject_cast<Internal::RemoteLinuxCustomRunConfiguration *>(runConfig))
m_symbolFile = rlrc->localExecutableFilePath();
setSymbolFile(rlrc->localExecutableFilePath());
}
void LinuxDeviceDebugSupport::start()
{
if (m_symbolFile.isEmpty()) {
reportFailure(tr("Cannot debug: Local executable is not set."));
return;
}
const QString host = device()->sshParameters().host;
const Port gdbServerPort = m_portsGatherer->gdbServerPort();
const int qmlServerPort = m_portsGatherer->qmlServerPort().number();
DebuggerStartParameters params;
params.startMode = AttachToRemoteServer;
params.closeMode = KillAndExitMonitorAtClose;
if (isQmlDebugging()) {
params.qmlServer.setHost(host);
params.qmlServer.setPort(qmlServerPort);
params.inferior.commandLineArguments.replace("%qml_port%", QString::number(qmlServerPort));
}
if (isCppDebugging()) {
Runnable r = runnable();
QTC_ASSERT(r.is<StandardRunnable>(), return);
auto stdRunnable = r.as<StandardRunnable>();
params.useExtendedRemote = true;
params.inferior.executable = stdRunnable.executable;
params.inferior.commandLineArguments = stdRunnable.commandLineArguments;
if (isQmlDebugging()) {
params.inferior.commandLineArguments.prepend(' ');
params.inferior.commandLineArguments.prepend(
QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices));
}
params.remoteChannel = QString("%1:%2").arg(host).arg(gdbServerPort.number());
params.symbolFile = m_symbolFile;
}
setStartParameters(params);
setGdbServerChannel(m_portsGatherer->gdbServerChannel());
setQmlServer(m_portsGatherer->qmlServer());
addQmlServerInferiorCommandLineArgumentIfNeeded();
DebuggerRunTool::start();
}
......
......@@ -33,16 +33,12 @@ namespace RemoteLinux {
class REMOTELINUX_EXPORT LinuxDeviceDebugSupport : public Debugger::DebuggerRunTool
{
Q_OBJECT
public:
LinuxDeviceDebugSupport(ProjectExplorer::RunControl *runControl);
private:
void start() override;
protected:
QString m_symbolFile;
Debugger::GdbServerPortsGatherer *m_portsGatherer = nullptr;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment