Commit 3e9d918f authored by Tobias Hunger's avatar Tobias Hunger

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: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent 9df694c6
......@@ -78,6 +78,9 @@ void MaemoRunConfiguration::init()
connect(m_remoteMounts, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
SLOT(handleRemoteMountsChanged()));
connect(m_remoteMounts, SIGNAL(modelReset()), SLOT(handleRemoteMountsChanged()));
if (!maemoTarget()->allowsQmlDebugging())
setUseQmlDebugger(false);
}
bool MaemoRunConfiguration::isEnabled() const
......@@ -136,13 +139,6 @@ PortList MaemoRunConfiguration::freePorts() const
: PortList();
}
RemoteLinuxRunConfiguration::DebuggingType MaemoRunConfiguration::debuggingType() const
{
if (!maemoTarget()->allowsQmlDebugging())
return DebugCppOnly;
return RemoteLinuxRunConfiguration::debuggingType();
}
QString MaemoRunConfiguration::localDirToMountForRemoteGdb() const
{
const QString projectDir
......
......@@ -53,7 +53,6 @@ public:
QString environmentPreparationCommand() const;
QString commandPrefix() const;
RemoteLinux::PortList freePorts() const;
DebuggingType debuggingType() const;
Internal::MaemoRemoteMountsModel *remoteMounts() const { return m_remoteMounts; }
bool hasEnoughFreePorts(const QString &mode) const;
......
......@@ -63,15 +63,17 @@ public:
AbstractRemoteLinuxDebugSupportPrivate(RemoteLinuxRunConfiguration *runConfig,
DebuggerEngine *engine)
: engine(engine), deviceConfig(runConfig->deviceConfig()),
debuggingType(runConfig->debuggingType()), state(Inactive),
qmlDebugging(runConfig->useQmlDebugger()),
cppDebugging(runConfig->useCppDebugger()),
state(Inactive),
gdbServerPort(-1), qmlPort(-1)
{
}
const QPointer<Debugger::DebuggerEngine> engine;
const LinuxDeviceConfiguration::ConstPtr deviceConfig;
const RemoteLinuxRunConfiguration::DebuggingType debuggingType;
bool qmlDebugging;
bool cppDebugging;
QByteArray gdbserverOutput;
State state;
int gdbServerPort;
......@@ -94,13 +96,11 @@ DebuggerStartParameters AbstractRemoteLinuxDebugSupport::startParameters(const R
{
DebuggerStartParameters params;
const LinuxDeviceConfiguration::ConstPtr &devConf = runConfig->deviceConfig();
const RemoteLinuxRunConfiguration::DebuggingType debuggingType
= runConfig->debuggingType();
if (debuggingType != RemoteLinuxRunConfiguration::DebugCppOnly) {
if (runConfig->useQmlDebugger()) {
params.qmlServerAddress = runConfig->deviceConfig()->sshParameters().host;
params.qmlServerPort = -1;
}
if (debuggingType != RemoteLinuxRunConfiguration::DebugQmlOnly) {
if (runConfig->useCppDebugger()) {
params.processArgs = runConfig->arguments();
if (runConfig->activeQt4BuildConfiguration()->qtVersion())
params.sysroot = runConfig->activeQt4BuildConfiguration()->qtVersion()->systemRoot();
......@@ -183,14 +183,10 @@ void AbstractRemoteLinuxDebugSupport::startExecution()
QTC_ASSERT(d->state == StartingRunner, return);
if (d->debuggingType != RemoteLinuxRunConfiguration::DebugQmlOnly) {
if (!setPort(d->gdbServerPort))
return;
}
if (d->debuggingType != RemoteLinuxRunConfiguration::DebugCppOnly) {
if (!setPort(d->qmlPort))
if (d->cppDebugging && !setPort(d->gdbServerPort))
return;
if (d->qmlDebugging && !setPort(d->qmlPort))
return;
}
d->state = StartingRemoteProcess;
d->gdbserverOutput.clear();
......@@ -198,18 +194,18 @@ void AbstractRemoteLinuxDebugSupport::startExecution()
SLOT(handleRemoteErrorOutput(QByteArray)));
connect(runner(), SIGNAL(remoteOutput(QByteArray)), this,
SLOT(handleRemoteOutput(QByteArray)));
if (d->debuggingType == RemoteLinuxRunConfiguration::DebugQmlOnly) {
if (d->qmlDebugging && !d->cppDebugging) {
connect(runner(), SIGNAL(remoteProcessStarted()),
SLOT(handleRemoteProcessStarted()));
}
const QString &remoteExe = runner()->remoteExecutable();
QString args = runner()->arguments();
if (d->debuggingType != RemoteLinuxRunConfiguration::DebugCppOnly) {
if (d->qmlDebugging) {
args += QString(QLatin1String(" -qmljsdebugger=port:%1,block"))
.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 gdbserver :%2 %3 %4").arg(runner()->commandPrefix())
.arg(d->gdbServerPort).arg(remoteExe).arg(args);
......@@ -225,13 +221,13 @@ void AbstractRemoteLinuxDebugSupport::handleRemoteProcessFinished(qint64 exitCod
if (d->state == Debugging) {
// 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();
else if (exitCode != 0)
d->engine->notifyInferiorIll();
} 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("The gdbserver process closed unexpectedly.");
d->engine->handleRemoteSetupFailed(errorMsg);
......@@ -259,8 +255,7 @@ void AbstractRemoteLinuxDebugSupport::handleRemoteErrorOutput(const QByteArray &
return;
showMessage(QString::fromUtf8(output), AppOutput);
if (d->state == StartingRemoteProcess
&& d->debuggingType != RemoteLinuxRunConfiguration::DebugQmlOnly) {
if (d->state == StartingRemoteProcess && d->cppDebugging) {
d->gdbserverOutput += output;
if (d->gdbserverOutput.contains("Listening on port")) {
handleAdapterSetupDone();
......@@ -288,7 +283,7 @@ void AbstractRemoteLinuxDebugSupport::handleAdapterSetupDone()
void AbstractRemoteLinuxDebugSupport::handleRemoteProcessStarted()
{
Q_ASSERT(d->debuggingType == RemoteLinuxRunConfiguration::DebugQmlOnly);
Q_ASSERT(d->qmlDebugging && !d->cppDebugging);
QTC_ASSERT(d->state == StartingRemoteProcess, return);
handleAdapterSetupDone();
......
......@@ -127,8 +127,6 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Qt4BaseTarget *parent,
void RemoteLinuxRunConfiguration::init()
{
setDefaultDisplayName(defaultDisplayName());
setUseCppDebugger(true);
setUseQmlDebugger(false);
connect(target(),
SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)),
......@@ -364,26 +362,15 @@ QString RemoteLinuxRunConfiguration::alternateRemoteExecutable() const
return d->alternateRemoteExecutable;
}
RemoteLinuxRunConfiguration::DebuggingType RemoteLinuxRunConfiguration::debuggingType() const
{
if (useCppDebugger()) {
if (useQmlDebugger())
return DebugCppAndQml;
return DebugCppOnly;
}
return DebugQmlOnly;
}
int RemoteLinuxRunConfiguration::portsUsedByDebuggers() const
{
switch (debuggingType()) {
case DebugCppOnly:
case DebugQmlOnly:
return 1;
case DebugCppAndQml:
default:
return 2;
}
int ports = 0;
if (useQmlDebugger())
++ports;
if (useCppDebugger())
++ports;
return ports;
}
void RemoteLinuxRunConfiguration::updateDeviceConfigurations()
......
......@@ -86,7 +86,6 @@ public:
virtual QString environmentPreparationCommand() const;
virtual QString commandPrefix() const;
virtual PortList freePorts() const;
virtual DebuggingType debuggingType() const;
QString localExecutableFilePath() const;
QString defaultRemoteExecutableFilePath() const;
......
......@@ -44,7 +44,6 @@
#include <qt4projectmanager/qt4target.h>
#include <utils/detailswidget.h>
#include <QtGui/QButtonGroup>
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
#include <QtGui/QCheckBox>
......@@ -56,7 +55,6 @@
#include <QtGui/QLineEdit>
#include <QtGui/QMessageBox>
#include <QtGui/QPushButton>
#include <QtGui/QRadioButton>
using namespace Qt4ProjectManager;
......@@ -91,9 +89,8 @@ public:
QLineEdit alternateCommand;
QLabel devConfLabel;
QLabel debuggingLanguagesLabel;
QRadioButton debugCppOnlyButton;
QRadioButton debugQmlOnlyButton;
QRadioButton debugCppAndQmlButton;
QCheckBox debugCppButton;
QCheckBox debugQmlButton;
QPushButton fetchEnvButton;
QComboBox baseEnvironmentComboBox;
ProjectExplorer::EnvironmentWidget *environmentWidget;
......@@ -150,9 +147,8 @@ void RemoteLinuxRunConfigurationWidget::addDisabledLabel(QVBoxLayout *topLayout)
void RemoteLinuxRunConfigurationWidget::suppressQmlDebuggingOptions()
{
d->debuggingLanguagesLabel.hide();
d->debugCppOnlyButton.hide();
d->debugQmlOnlyButton.hide();
d->debugCppAndQmlButton.hide();
d->debugCppButton.hide();
d->debugQmlButton.hide();
}
void RemoteLinuxRunConfigurationWidget::runConfigurationEnabledChange(bool enabled)
......@@ -204,36 +200,23 @@ void RemoteLinuxRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayou
d->genericWidgetsLayout.addRow(tr("Working directory:"), &d->workingDirLineEdit);
QHBoxLayout * const debugButtonsLayout = new QHBoxLayout;
d->debugCppOnlyButton.setText(tr("C++ only"));
d->debugQmlOnlyButton.setText(tr("QML only"));
d->debugCppAndQmlButton.setText(tr("C++ and QML"));
d->debugCppButton.setText(tr("C++"));
d->debugQmlButton.setText(tr("QML"));
d->debuggingLanguagesLabel.setText(tr("Debugging type:"));
QButtonGroup * const buttonGroup = new QButtonGroup;
buttonGroup->addButton(&d->debugCppOnlyButton);
buttonGroup->addButton(&d->debugQmlOnlyButton);
buttonGroup->addButton(&d->debugCppAndQmlButton);
debugButtonsLayout->addWidget(&d->debugCppOnlyButton);
debugButtonsLayout->addWidget(&d->debugQmlOnlyButton);
debugButtonsLayout->addWidget(&d->debugCppAndQmlButton);
debugButtonsLayout->addWidget(&d->debugCppButton);
debugButtonsLayout->addWidget(&d->debugQmlButton);
debugButtonsLayout->addStretch(1);
d->genericWidgetsLayout.addRow(&d->debuggingLanguagesLabel, debugButtonsLayout);
if (d->runConfiguration->useCppDebugger()) {
if (d->runConfiguration->useQmlDebugger())
d->debugCppAndQmlButton.setChecked(true);
else
d->debugCppOnlyButton.setChecked(true);
} else {
d->debugQmlOnlyButton.setChecked(true);
}
d->debugCppButton.setChecked(d->runConfiguration->useCppDebugger());
d->debugQmlButton.setChecked(d->runConfiguration->useQmlDebugger());
connect(addDevConfLabel, SIGNAL(linkActivated(QString)), this,
SLOT(showDeviceConfigurationsDialog(QString)));
connect(debuggerConfLabel, SIGNAL(linkActivated(QString)), this,
SLOT(showDeviceConfigurationsDialog(QString)));
connect(&d->argsLineEdit, SIGNAL(textEdited(QString)), SLOT(argumentsEdited(QString)));
connect(&d->debugCppOnlyButton, SIGNAL(toggled(bool)), SLOT(handleDebuggingTypeChanged()));
connect(&d->debugQmlOnlyButton, SIGNAL(toggled(bool)), SLOT(handleDebuggingTypeChanged()));
connect(&d->debugCppAndQmlButton, SIGNAL(toggled(bool)), SLOT(handleDebuggingTypeChanged()));
connect(&d->debugCppButton, SIGNAL(toggled(bool)), SLOT(handleDebuggingTypeChanged()));
connect(&d->debugQmlButton, SIGNAL(toggled(bool)), SLOT(handleDebuggingTypeChanged()));
connect(d->runConfiguration, SIGNAL(targetInformationChanged()), this,
SLOT(updateTargetInformation()));
connect(d->runConfiguration, SIGNAL(deploySpecsChanged()), SLOT(handleDeploySpecsChanged()));
......@@ -402,10 +385,8 @@ void RemoteLinuxRunConfigurationWidget::userEnvironmentChangesChanged(const QLis
void RemoteLinuxRunConfigurationWidget::handleDebuggingTypeChanged()
{
d->runConfiguration->setUseCppDebugger(d->debugCppOnlyButton.isChecked()
|| d->debugCppAndQmlButton.isChecked());
d->runConfiguration->setUseQmlDebugger(d->debugQmlOnlyButton.isChecked()
|| d->debugCppAndQmlButton.isChecked());
d->runConfiguration->setUseCppDebugger(d->debugCppButton.isChecked());
d->runConfiguration->setUseQmlDebugger(d->debugQmlButton.isChecked());
}
} // namespace RemoteLinux
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