Remote Linux: Fix handling of debuggers

Use the RunConfigurations mechanismn of enabling/disableing C++ and
QML debuggers everywhere.

This makes the code a bit shorter, removes duplicate functionality and
fixes the QML debugger not being enabled when creating a fresh QML
application in the embedded linux target.

Change-Id: I390e95c46074a96b2187ccfae538ae209bf70712
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
Tobias Hunger
2011-11-11 02:52:34 +01:00
parent 9df694c6eb
commit 3e9d918f2e
6 changed files with 41 additions and 84 deletions

View File

@@ -78,6 +78,9 @@ void MaemoRunConfiguration::init()
connect(m_remoteMounts, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, connect(m_remoteMounts, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
SLOT(handleRemoteMountsChanged())); SLOT(handleRemoteMountsChanged()));
connect(m_remoteMounts, SIGNAL(modelReset()), SLOT(handleRemoteMountsChanged())); connect(m_remoteMounts, SIGNAL(modelReset()), SLOT(handleRemoteMountsChanged()));
if (!maemoTarget()->allowsQmlDebugging())
setUseQmlDebugger(false);
} }
bool MaemoRunConfiguration::isEnabled() const bool MaemoRunConfiguration::isEnabled() const
@@ -136,13 +139,6 @@ PortList MaemoRunConfiguration::freePorts() const
: PortList(); : PortList();
} }
RemoteLinuxRunConfiguration::DebuggingType MaemoRunConfiguration::debuggingType() const
{
if (!maemoTarget()->allowsQmlDebugging())
return DebugCppOnly;
return RemoteLinuxRunConfiguration::debuggingType();
}
QString MaemoRunConfiguration::localDirToMountForRemoteGdb() const QString MaemoRunConfiguration::localDirToMountForRemoteGdb() const
{ {
const QString projectDir const QString projectDir

View File

@@ -53,7 +53,6 @@ public:
QString environmentPreparationCommand() const; QString environmentPreparationCommand() const;
QString commandPrefix() const; QString commandPrefix() const;
RemoteLinux::PortList freePorts() const; RemoteLinux::PortList freePorts() const;
DebuggingType debuggingType() const;
Internal::MaemoRemoteMountsModel *remoteMounts() const { return m_remoteMounts; } Internal::MaemoRemoteMountsModel *remoteMounts() const { return m_remoteMounts; }
bool hasEnoughFreePorts(const QString &mode) const; bool hasEnoughFreePorts(const QString &mode) const;

View File

@@ -63,15 +63,17 @@ public:
AbstractRemoteLinuxDebugSupportPrivate(RemoteLinuxRunConfiguration *runConfig, AbstractRemoteLinuxDebugSupportPrivate(RemoteLinuxRunConfiguration *runConfig,
DebuggerEngine *engine) DebuggerEngine *engine)
: engine(engine), deviceConfig(runConfig->deviceConfig()), : engine(engine), deviceConfig(runConfig->deviceConfig()),
debuggingType(runConfig->debuggingType()), state(Inactive), qmlDebugging(runConfig->useQmlDebugger()),
cppDebugging(runConfig->useCppDebugger()),
state(Inactive),
gdbServerPort(-1), qmlPort(-1) gdbServerPort(-1), qmlPort(-1)
{ {
} }
const QPointer<Debugger::DebuggerEngine> engine; const QPointer<Debugger::DebuggerEngine> engine;
const LinuxDeviceConfiguration::ConstPtr deviceConfig; const LinuxDeviceConfiguration::ConstPtr deviceConfig;
const RemoteLinuxRunConfiguration::DebuggingType debuggingType; bool qmlDebugging;
bool cppDebugging;
QByteArray gdbserverOutput; QByteArray gdbserverOutput;
State state; State state;
int gdbServerPort; int gdbServerPort;
@@ -94,13 +96,11 @@ DebuggerStartParameters AbstractRemoteLinuxDebugSupport::startParameters(const R
{ {
DebuggerStartParameters params; DebuggerStartParameters params;
const LinuxDeviceConfiguration::ConstPtr &devConf = runConfig->deviceConfig(); const LinuxDeviceConfiguration::ConstPtr &devConf = runConfig->deviceConfig();
const RemoteLinuxRunConfiguration::DebuggingType debuggingType if (runConfig->useQmlDebugger()) {
= runConfig->debuggingType();
if (debuggingType != RemoteLinuxRunConfiguration::DebugCppOnly) {
params.qmlServerAddress = runConfig->deviceConfig()->sshParameters().host; params.qmlServerAddress = runConfig->deviceConfig()->sshParameters().host;
params.qmlServerPort = -1; params.qmlServerPort = -1;
} }
if (debuggingType != RemoteLinuxRunConfiguration::DebugQmlOnly) { if (runConfig->useCppDebugger()) {
params.processArgs = runConfig->arguments(); params.processArgs = runConfig->arguments();
if (runConfig->activeQt4BuildConfiguration()->qtVersion()) if (runConfig->activeQt4BuildConfiguration()->qtVersion())
params.sysroot = runConfig->activeQt4BuildConfiguration()->qtVersion()->systemRoot(); params.sysroot = runConfig->activeQt4BuildConfiguration()->qtVersion()->systemRoot();
@@ -183,14 +183,10 @@ void AbstractRemoteLinuxDebugSupport::startExecution()
QTC_ASSERT(d->state == StartingRunner, return); QTC_ASSERT(d->state == StartingRunner, return);
if (d->debuggingType != RemoteLinuxRunConfiguration::DebugQmlOnly) { if (d->cppDebugging && !setPort(d->gdbServerPort))
if (!setPort(d->gdbServerPort))
return; return;
} if (d->qmlDebugging && !setPort(d->qmlPort))
if (d->debuggingType != RemoteLinuxRunConfiguration::DebugCppOnly) {
if (!setPort(d->qmlPort))
return; return;
}
d->state = StartingRemoteProcess; d->state = StartingRemoteProcess;
d->gdbserverOutput.clear(); d->gdbserverOutput.clear();
@@ -198,18 +194,18 @@ void AbstractRemoteLinuxDebugSupport::startExecution()
SLOT(handleRemoteErrorOutput(QByteArray))); SLOT(handleRemoteErrorOutput(QByteArray)));
connect(runner(), SIGNAL(remoteOutput(QByteArray)), this, connect(runner(), SIGNAL(remoteOutput(QByteArray)), this,
SLOT(handleRemoteOutput(QByteArray))); SLOT(handleRemoteOutput(QByteArray)));
if (d->debuggingType == RemoteLinuxRunConfiguration::DebugQmlOnly) { if (d->qmlDebugging && !d->cppDebugging) {
connect(runner(), SIGNAL(remoteProcessStarted()), connect(runner(), SIGNAL(remoteProcessStarted()),
SLOT(handleRemoteProcessStarted())); SLOT(handleRemoteProcessStarted()));
} }
const QString &remoteExe = runner()->remoteExecutable(); const QString &remoteExe = runner()->remoteExecutable();
QString args = runner()->arguments(); QString args = runner()->arguments();
if (d->debuggingType != RemoteLinuxRunConfiguration::DebugCppOnly) { if (d->qmlDebugging) {
args += QString(QLatin1String(" -qmljsdebugger=port:%1,block")) args += QString(QLatin1String(" -qmljsdebugger=port:%1,block"))
.arg(d->qmlPort); .arg(d->qmlPort);
} }
const QString remoteCommandLine = d->debuggingType == RemoteLinuxRunConfiguration::DebugQmlOnly const QString remoteCommandLine = (d->qmlDebugging && !d->cppDebugging)
? QString::fromLocal8Bit("%1 %2 %3").arg(runner()->commandPrefix()).arg(remoteExe).arg(args) ? QString::fromLocal8Bit("%1 %2 %3").arg(runner()->commandPrefix()).arg(remoteExe).arg(args)
: QString::fromLocal8Bit("%1 gdbserver :%2 %3 %4").arg(runner()->commandPrefix()) : QString::fromLocal8Bit("%1 gdbserver :%2 %3 %4").arg(runner()->commandPrefix())
.arg(d->gdbServerPort).arg(remoteExe).arg(args); .arg(d->gdbServerPort).arg(remoteExe).arg(args);
@@ -225,13 +221,13 @@ void AbstractRemoteLinuxDebugSupport::handleRemoteProcessFinished(qint64 exitCod
if (d->state == Debugging) { if (d->state == Debugging) {
// The QML engine does not realize on its own that the application has finished. // The QML engine does not realize on its own that the application has finished.
if (d->debuggingType == RemoteLinuxRunConfiguration::DebugQmlOnly) if (d->qmlDebugging && !d->cppDebugging)
d->engine->quitDebugger(); d->engine->quitDebugger();
else if (exitCode != 0) else if (exitCode != 0)
d->engine->notifyInferiorIll(); d->engine->notifyInferiorIll();
} else { } else {
const QString errorMsg = d->debuggingType == RemoteLinuxRunConfiguration::DebugQmlOnly const QString errorMsg = (d->qmlDebugging && !d->cppDebugging)
? tr("Remote application failed with exit code %1.").arg(exitCode) ? tr("Remote application failed with exit code %1.").arg(exitCode)
: tr("The gdbserver process closed unexpectedly."); : tr("The gdbserver process closed unexpectedly.");
d->engine->handleRemoteSetupFailed(errorMsg); d->engine->handleRemoteSetupFailed(errorMsg);
@@ -259,8 +255,7 @@ void AbstractRemoteLinuxDebugSupport::handleRemoteErrorOutput(const QByteArray &
return; return;
showMessage(QString::fromUtf8(output), AppOutput); showMessage(QString::fromUtf8(output), AppOutput);
if (d->state == StartingRemoteProcess if (d->state == StartingRemoteProcess && d->cppDebugging) {
&& d->debuggingType != RemoteLinuxRunConfiguration::DebugQmlOnly) {
d->gdbserverOutput += output; d->gdbserverOutput += output;
if (d->gdbserverOutput.contains("Listening on port")) { if (d->gdbserverOutput.contains("Listening on port")) {
handleAdapterSetupDone(); handleAdapterSetupDone();
@@ -288,7 +283,7 @@ void AbstractRemoteLinuxDebugSupport::handleAdapterSetupDone()
void AbstractRemoteLinuxDebugSupport::handleRemoteProcessStarted() void AbstractRemoteLinuxDebugSupport::handleRemoteProcessStarted()
{ {
Q_ASSERT(d->debuggingType == RemoteLinuxRunConfiguration::DebugQmlOnly); Q_ASSERT(d->qmlDebugging && !d->cppDebugging);
QTC_ASSERT(d->state == StartingRemoteProcess, return); QTC_ASSERT(d->state == StartingRemoteProcess, return);
handleAdapterSetupDone(); handleAdapterSetupDone();

View File

@@ -127,8 +127,6 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Qt4BaseTarget *parent,
void RemoteLinuxRunConfiguration::init() void RemoteLinuxRunConfiguration::init()
{ {
setDefaultDisplayName(defaultDisplayName()); setDefaultDisplayName(defaultDisplayName());
setUseCppDebugger(true);
setUseQmlDebugger(false);
connect(target(), connect(target(),
SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)), SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)),
@@ -364,26 +362,15 @@ QString RemoteLinuxRunConfiguration::alternateRemoteExecutable() const
return d->alternateRemoteExecutable; return d->alternateRemoteExecutable;
} }
RemoteLinuxRunConfiguration::DebuggingType RemoteLinuxRunConfiguration::debuggingType() const
{
if (useCppDebugger()) {
if (useQmlDebugger())
return DebugCppAndQml;
return DebugCppOnly;
}
return DebugQmlOnly;
}
int RemoteLinuxRunConfiguration::portsUsedByDebuggers() const int RemoteLinuxRunConfiguration::portsUsedByDebuggers() const
{ {
switch (debuggingType()) { int ports = 0;
case DebugCppOnly: if (useQmlDebugger())
case DebugQmlOnly: ++ports;
return 1; if (useCppDebugger())
case DebugCppAndQml: ++ports;
default:
return 2; return ports;
}
} }
void RemoteLinuxRunConfiguration::updateDeviceConfigurations() void RemoteLinuxRunConfiguration::updateDeviceConfigurations()

View File

@@ -86,7 +86,6 @@ public:
virtual QString environmentPreparationCommand() const; virtual QString environmentPreparationCommand() const;
virtual QString commandPrefix() const; virtual QString commandPrefix() const;
virtual PortList freePorts() const; virtual PortList freePorts() const;
virtual DebuggingType debuggingType() const;
QString localExecutableFilePath() const; QString localExecutableFilePath() const;
QString defaultRemoteExecutableFilePath() const; QString defaultRemoteExecutableFilePath() const;

View File

@@ -44,7 +44,6 @@
#include <qt4projectmanager/qt4target.h> #include <qt4projectmanager/qt4target.h>
#include <utils/detailswidget.h> #include <utils/detailswidget.h>
#include <QtGui/QButtonGroup>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtGui/QCheckBox> #include <QtGui/QCheckBox>
@@ -56,7 +55,6 @@
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
#include <QtGui/QPushButton> #include <QtGui/QPushButton>
#include <QtGui/QRadioButton>
using namespace Qt4ProjectManager; using namespace Qt4ProjectManager;
@@ -91,9 +89,8 @@ public:
QLineEdit alternateCommand; QLineEdit alternateCommand;
QLabel devConfLabel; QLabel devConfLabel;
QLabel debuggingLanguagesLabel; QLabel debuggingLanguagesLabel;
QRadioButton debugCppOnlyButton; QCheckBox debugCppButton;
QRadioButton debugQmlOnlyButton; QCheckBox debugQmlButton;
QRadioButton debugCppAndQmlButton;
QPushButton fetchEnvButton; QPushButton fetchEnvButton;
QComboBox baseEnvironmentComboBox; QComboBox baseEnvironmentComboBox;
ProjectExplorer::EnvironmentWidget *environmentWidget; ProjectExplorer::EnvironmentWidget *environmentWidget;
@@ -150,9 +147,8 @@ void RemoteLinuxRunConfigurationWidget::addDisabledLabel(QVBoxLayout *topLayout)
void RemoteLinuxRunConfigurationWidget::suppressQmlDebuggingOptions() void RemoteLinuxRunConfigurationWidget::suppressQmlDebuggingOptions()
{ {
d->debuggingLanguagesLabel.hide(); d->debuggingLanguagesLabel.hide();
d->debugCppOnlyButton.hide(); d->debugCppButton.hide();
d->debugQmlOnlyButton.hide(); d->debugQmlButton.hide();
d->debugCppAndQmlButton.hide();
} }
void RemoteLinuxRunConfigurationWidget::runConfigurationEnabledChange(bool enabled) void RemoteLinuxRunConfigurationWidget::runConfigurationEnabledChange(bool enabled)
@@ -204,36 +200,23 @@ void RemoteLinuxRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayou
d->genericWidgetsLayout.addRow(tr("Working directory:"), &d->workingDirLineEdit); d->genericWidgetsLayout.addRow(tr("Working directory:"), &d->workingDirLineEdit);
QHBoxLayout * const debugButtonsLayout = new QHBoxLayout; QHBoxLayout * const debugButtonsLayout = new QHBoxLayout;
d->debugCppOnlyButton.setText(tr("C++ only")); d->debugCppButton.setText(tr("C++"));
d->debugQmlOnlyButton.setText(tr("QML only")); d->debugQmlButton.setText(tr("QML"));
d->debugCppAndQmlButton.setText(tr("C++ and QML"));
d->debuggingLanguagesLabel.setText(tr("Debugging type:")); d->debuggingLanguagesLabel.setText(tr("Debugging type:"));
QButtonGroup * const buttonGroup = new QButtonGroup; debugButtonsLayout->addWidget(&d->debugCppButton);
buttonGroup->addButton(&d->debugCppOnlyButton); debugButtonsLayout->addWidget(&d->debugQmlButton);
buttonGroup->addButton(&d->debugQmlOnlyButton);
buttonGroup->addButton(&d->debugCppAndQmlButton);
debugButtonsLayout->addWidget(&d->debugCppOnlyButton);
debugButtonsLayout->addWidget(&d->debugQmlOnlyButton);
debugButtonsLayout->addWidget(&d->debugCppAndQmlButton);
debugButtonsLayout->addStretch(1); debugButtonsLayout->addStretch(1);
d->genericWidgetsLayout.addRow(&d->debuggingLanguagesLabel, debugButtonsLayout); d->genericWidgetsLayout.addRow(&d->debuggingLanguagesLabel, debugButtonsLayout);
if (d->runConfiguration->useCppDebugger()) { d->debugCppButton.setChecked(d->runConfiguration->useCppDebugger());
if (d->runConfiguration->useQmlDebugger()) d->debugQmlButton.setChecked(d->runConfiguration->useQmlDebugger());
d->debugCppAndQmlButton.setChecked(true);
else
d->debugCppOnlyButton.setChecked(true);
} else {
d->debugQmlOnlyButton.setChecked(true);
}
connect(addDevConfLabel, SIGNAL(linkActivated(QString)), this, connect(addDevConfLabel, SIGNAL(linkActivated(QString)), this,
SLOT(showDeviceConfigurationsDialog(QString))); SLOT(showDeviceConfigurationsDialog(QString)));
connect(debuggerConfLabel, SIGNAL(linkActivated(QString)), this, connect(debuggerConfLabel, SIGNAL(linkActivated(QString)), this,
SLOT(showDeviceConfigurationsDialog(QString))); SLOT(showDeviceConfigurationsDialog(QString)));
connect(&d->argsLineEdit, SIGNAL(textEdited(QString)), SLOT(argumentsEdited(QString))); connect(&d->argsLineEdit, SIGNAL(textEdited(QString)), SLOT(argumentsEdited(QString)));
connect(&d->debugCppOnlyButton, SIGNAL(toggled(bool)), SLOT(handleDebuggingTypeChanged())); connect(&d->debugCppButton, SIGNAL(toggled(bool)), SLOT(handleDebuggingTypeChanged()));
connect(&d->debugQmlOnlyButton, SIGNAL(toggled(bool)), SLOT(handleDebuggingTypeChanged())); connect(&d->debugQmlButton, SIGNAL(toggled(bool)), SLOT(handleDebuggingTypeChanged()));
connect(&d->debugCppAndQmlButton, SIGNAL(toggled(bool)), SLOT(handleDebuggingTypeChanged()));
connect(d->runConfiguration, SIGNAL(targetInformationChanged()), this, connect(d->runConfiguration, SIGNAL(targetInformationChanged()), this,
SLOT(updateTargetInformation())); SLOT(updateTargetInformation()));
connect(d->runConfiguration, SIGNAL(deploySpecsChanged()), SLOT(handleDeploySpecsChanged())); connect(d->runConfiguration, SIGNAL(deploySpecsChanged()), SLOT(handleDeploySpecsChanged()));
@@ -402,10 +385,8 @@ void RemoteLinuxRunConfigurationWidget::userEnvironmentChangesChanged(const QLis
void RemoteLinuxRunConfigurationWidget::handleDebuggingTypeChanged() void RemoteLinuxRunConfigurationWidget::handleDebuggingTypeChanged()
{ {
d->runConfiguration->setUseCppDebugger(d->debugCppOnlyButton.isChecked() d->runConfiguration->setUseCppDebugger(d->debugCppButton.isChecked());
|| d->debugCppAndQmlButton.isChecked()); d->runConfiguration->setUseQmlDebugger(d->debugQmlButton.isChecked());
d->runConfiguration->setUseQmlDebugger(d->debugQmlOnlyButton.isChecked()
|| d->debugCppAndQmlButton.isChecked());
} }
} // namespace RemoteLinux } // namespace RemoteLinux