Maemo: Complete support for debugging via remote gdb.

1) Make sources available on device.
2) Enable users to switch between gdb and gdbserver approach (users may not be able to use the former if they have no control over their firewall).

Reviewed-by: kh1
This commit is contained in:
ck
2010-07-30 12:14:54 +02:00
parent 933d23bced
commit ca7f49071b
16 changed files with 310 additions and 147 deletions

View File

@@ -75,20 +75,23 @@ public:
bool useTerminal;
bool breakAtMain;
QString crashParameter; // for AttachCrashedExternal
// for remote debugging
QString remoteChannel;
QString remoteArchitecture;
QString symbolFileName;
QString serverStartScript;
QString sysRoot;
QByteArray remoteDumperLib;
QByteArray remoteSourcesDir;
Core::SshConnectionParameters connParams;
QString debuggerCommand;
int toolChainType;
QByteArray remoteDumperLib;
QString qtInstallPath;
QString dumperLibrary;
QStringList dumperLibraryLocations;
Core::SshConnectionParameters connParams;
DebuggerStartMode startMode;
};

View File

@@ -43,7 +43,7 @@ class AbstractPlainGdbAdapter : public AbstractGdbAdapter
public:
AbstractPlainGdbAdapter(GdbEngine *engine, QObject *parent = 0);
void setupInferior();
virtual void setupInferior();
void runEngine();
protected:

View File

@@ -51,6 +51,13 @@ void RemotePlainGdbAdapter::startAdapter()
emit requestSetup();
}
void RemotePlainGdbAdapter::setupInferior()
{
AbstractPlainGdbAdapter::setupInferior();
m_engine->postCommand("directory "
+ m_engine->startParameters().remoteSourcesDir);
}
void RemotePlainGdbAdapter::interruptInferior()
{
m_gdbProc.interruptInferior();

View File

@@ -51,6 +51,7 @@ signals:
private:
void startAdapter();
void setupInferior();
void interruptInferior();
void shutdownInferior();
void shutdownAdapter();

View File

@@ -72,6 +72,8 @@ static const QLatin1String MountPortsKey(PREFIX ".MountPorts");
static const QLatin1String HostAddressFromDeviceKey(PREFIX ".HostAddressFromDevice");
static const QLatin1String BaseEnvironmentBaseKey(PREFIX ".BaseEnvironmentBase");
static const QLatin1String UserEnvironmentChangesKey(PREFIX ".UserEnvironmentChanges");
static const QLatin1String UseRemoteGdbKey(PREFIX ".UseRemoteGdb");
static const QLatin1String GdbMountPortKey(PREFIX ".GdbMountPort");
} // namespace Internal
} // namespace Qt4ProjectManager

View File

@@ -48,6 +48,7 @@
#include <debugger/gdb/remoteplaingdbadapter.h>
#include <projectexplorer/toolchain.h>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
using namespace Core;
@@ -62,20 +63,28 @@ RunControl *MaemoDebugSupport::createDebugRunControl(MaemoRunConfiguration *runC
{
DebuggerStartParameters params;
const MaemoDeviceConfig &devConf = runConfig->deviceConfig();
#ifdef USE_GDBSERVER
if (runConfig->useRemoteGdb()) {
params.startMode = StartRemoteGdb;
params.executable = runConfig->remoteExecutableFilePath();
params.debuggerCommand
= MaemoGlobal::remoteCommandPrefix(runConfig->remoteExecutableFilePath())
+ QLatin1String(" /usr/bin/gdb");
params.connParams = devConf.server;
const QString execDirAbs
= QDir::fromNativeSeparators(QFileInfo(runConfig->localExecutableFilePath()).path());
const QString execDirRel
= QDir(runConfig->localDirToMountForRemoteGdb()).relativeFilePath(execDirAbs);
params.remoteSourcesDir
= QString(MaemoGlobal::remoteProjectSourcesMountPoint()
+ QLatin1Char('/') + execDirRel).toUtf8();
} else {
params.startMode = AttachToRemote;
params.executable = runConfig->localExecutableFilePath();
params.debuggerCommand = runConfig->gdbCmd();
params.remoteChannel = devConf.server.host + QLatin1Char(':')
+ gdbServerPort(runConfig, devConf);
params.remoteArchitecture = QLatin1String("arm");
#else
params.startMode = StartRemoteGdb;
params.executable = runConfig->remoteExecutableFilePath();
params.debuggerCommand = MaemoGlobal::remoteCommandPrefix(runConfig->remoteExecutableFilePath())
+ QLatin1String(" /usr/bin/gdb");
params.connParams = devConf.server;
#endif
}
params.processArgs = runConfig->arguments();
params.sysRoot = runConfig->sysRoot();
params.toolChainType = ToolChain::GCC_MAEMO;
@@ -93,24 +102,22 @@ MaemoDebugSupport::MaemoDebugSupport(MaemoRunConfiguration *runConfig,
DebuggerRunControl *runControl)
: QObject(runControl), m_runControl(runControl), m_runConfig(runConfig),
m_deviceConfig(m_runConfig->deviceConfig()),
m_runner(new MaemoSshRunner(this, m_runConfig))
m_runner(new MaemoSshRunner(this, m_runConfig, true))
{
GdbEngine *engine = qobject_cast<GdbEngine *>(m_runControl->engine());
Q_ASSERT(engine);
m_gdbAdapter = qobject_cast<GdbAdapter *>(engine->gdbAdapter());
m_gdbAdapter = engine->gdbAdapter();
Q_ASSERT(m_gdbAdapter);
connect(m_gdbAdapter, SIGNAL(requestSetup()), this,
SLOT(handleAdapterSetupRequested()));
connect(m_runControl, SIGNAL(finished()), this,
SLOT(handleDebuggingFinished()));
#ifdef USE_GDBSERVER
m_runner->addProcsToKill(QStringList() << QLatin1String("gdbserver"));
#else
m_runner->addProcsToKill(QStringList() << QLatin1String("gdb"));
#endif
}
MaemoDebugSupport::~MaemoDebugSupport() {}
MaemoDebugSupport::~MaemoDebugSupport()
{
stopSsh();
}
void MaemoDebugSupport::handleAdapterSetupRequested()
{
@@ -209,7 +216,9 @@ void MaemoDebugSupport::handleSftpJobFinished(Core::SftpJobId job,
void MaemoDebugSupport::startDebugging()
{
#ifdef USE_GDBSERVER
if (useGdb()) {
handleAdapterSetupDone();
} else {
connect(m_runner, SIGNAL(remoteErrorOutput(QByteArray)), this,
SLOT(handleRemoteErrorOutput(QByteArray)));
connect(m_runner, SIGNAL(remoteOutput(QByteArray)), this,
@@ -222,10 +231,7 @@ void MaemoDebugSupport::startDebugging()
.arg(gdbServerPort(m_runConfig, m_deviceConfig))
.arg(remoteExe).arg(m_runConfig->arguments()
.join(QLatin1String(" "))).toUtf8());
#else
stopSsh();
handleAdapterSetupDone();
#endif
}
}
void MaemoDebugSupport::handleRemoteProcessStarted()
@@ -261,7 +267,11 @@ void MaemoDebugSupport::stopSsh()
void MaemoDebugSupport::handleAdapterSetupFailed(const QString &error)
{
m_gdbAdapter->handleSetupFailed(tr("Initial setup failed: %1").arg(error));
const QString msg = tr("Initial setup failed: %1").arg(error);
if (useGdb())
qobject_cast<RemotePlainGdbAdapter *>(m_gdbAdapter)->handleSetupFailed(msg);
else
qobject_cast<RemoteGdbServerAdapter*>(m_gdbAdapter)->handleSetupFailed(msg);
m_stopped = true;
stopSsh();
}
@@ -269,7 +279,10 @@ void MaemoDebugSupport::handleAdapterSetupFailed(const QString &error)
void MaemoDebugSupport::handleAdapterSetupDone()
{
m_adapterStarted = true;
m_gdbAdapter->handleSetupDone();
if (useGdb())
qobject_cast<RemotePlainGdbAdapter *>(m_gdbAdapter)->handleSetupDone();
else
qobject_cast<RemoteGdbServerAdapter*>(m_gdbAdapter)->handleSetupDone();
}
QString MaemoDebugSupport::gdbServerPort(const MaemoRunConfiguration *rc,
@@ -288,5 +301,10 @@ QString MaemoDebugSupport::uploadDir(const MaemoDeviceConfig &devConf)
return MaemoGlobal::homeDirOnDevice(devConf.server.uname);
}
bool MaemoDebugSupport::useGdb() const
{
return m_runControl->engine()->startParameters().startMode == StartRemoteGdb;
}
} // namespace Internal
} // namespace Qt4ProjectManager

View File

@@ -42,15 +42,12 @@
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
#define USE_GDBSERVER
namespace Core { class SftpChannel; }
namespace Debugger {
class DebuggerRunControl;
namespace Internal {
class RemoteGdbServerAdapter;
class RemotePlainGdbAdapter;
class AbstractGdbAdapter;
}
}
@@ -93,19 +90,14 @@ private:
void handleAdapterSetupFailed(const QString &error);
void handleAdapterSetupDone();
void startDebugging();
bool useGdb() const;
Debugger::DebuggerRunControl *m_runControl;
MaemoRunConfiguration * const m_runConfig;
const MaemoDeviceConfig m_deviceConfig;
MaemoSshRunner * const m_runner;
#ifdef USE_GDBSERVER
typedef Debugger::Internal::RemoteGdbServerAdapter GdbAdapter;
#else
typedef Debugger::Internal::RemotePlainGdbAdapter GdbAdapter;
#endif
GdbAdapter *m_gdbAdapter;
Debugger::Internal::AbstractGdbAdapter *m_gdbAdapter;
QSharedPointer<Core::SftpChannel> m_uploader;
Core::SftpJobId m_uploadJob;

View File

@@ -61,5 +61,10 @@ QString MaemoGlobal::remoteEnvironment(const QList<ProjectExplorer::EnvironmentI
return env.mid(0, env.size() - 1);
}
QString MaemoGlobal::remoteProjectSourcesMountPoint()
{
return QLatin1String("/tmp/gdbSourcesDir");
}
} // namespace Internal
} // namespace Qt4ProjectManager

View File

@@ -49,6 +49,7 @@ public:
static QString remoteSudo();
static QString remoteCommandPrefix(const QString &commandFilePath);
static QString remoteEnvironment(const QList<ProjectExplorer::EnvironmentItem> &list);
static QString remoteProjectSourcesMountPoint();
template<class T> static T *buildStep(const ProjectExplorer::BuildConfiguration *bc)
{

View File

@@ -55,7 +55,11 @@
namespace Qt4ProjectManager {
namespace Internal {
namespace { const QLatin1String DefaultHostAddress("192.168.2.14"); }
namespace {
const QLatin1String DefaultHostAddress("192.168.2.14");
const bool DefaultUseRemoteGdbValue = false; // TODO: Make true once utfs-server works on Windows.
const int DefaultGdbMountPort = 10100;
} // anonymous namespace
using namespace ProjectExplorer;
@@ -63,6 +67,9 @@ MaemoRunConfiguration::MaemoRunConfiguration(Qt4Target *parent,
const QString &proFilePath)
: RunConfiguration(parent, QLatin1String(MAEMO_RC_ID))
, m_proFilePath(proFilePath)
, m_hostAddressFromDevice(DefaultHostAddress)
, m_useRemoteGdb(DefaultUseRemoteGdbValue)
, m_gdbMountPort(DefaultGdbMountPort)
, m_baseEnvironmentBase(SystemEnvironmentBase)
{
init();
@@ -74,6 +81,9 @@ MaemoRunConfiguration::MaemoRunConfiguration(Qt4Target *parent,
, m_proFilePath(source->m_proFilePath)
, m_gdbPath(source->m_gdbPath)
, m_arguments(source->m_arguments)
, m_hostAddressFromDevice(source->localHostAddressFromDevice())
, m_useRemoteGdb(source->useRemoteGdb())
, m_gdbMountPort(source->gdbMountPort())
, m_baseEnvironmentBase(source->m_baseEnvironmentBase)
, m_systemEnvironment(source->m_systemEnvironment)
, m_userEnvironmentChanges(source->m_userEnvironmentChanges)
@@ -85,7 +95,6 @@ void MaemoRunConfiguration::init()
{
m_devConfigModel = new MaemoDeviceConfigListModel(this);
m_remoteMounts = new MaemoRemoteMountsModel(this);
m_hostAddressFromDevice = DefaultHostAddress;
setDisplayName(QFileInfo(m_proFilePath).completeBaseName());
updateDeviceConfigurations();
@@ -144,6 +153,8 @@ QVariantMap MaemoRunConfiguration::toMap() const
const QDir dir = QDir(target()->project()->projectDirectory());
map.insert(ProFileKey, dir.relativeFilePath(m_proFilePath));
map.insert(HostAddressFromDeviceKey, m_hostAddressFromDevice);
map.insert(UseRemoteGdbKey, useRemoteGdb());
map.insert(GdbMountPortKey, gdbMountPort());
map.insert(BaseEnvironmentBaseKey, m_baseEnvironmentBase);
map.insert(UserEnvironmentChangesKey,
ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges));
@@ -162,6 +173,8 @@ bool MaemoRunConfiguration::fromMap(const QVariantMap &map)
m_proFilePath = dir.filePath(map.value(ProFileKey).toString());
m_hostAddressFromDevice = map.value(HostAddressFromDeviceKey,
DefaultHostAddress).toString();
m_useRemoteGdb = map.value(UseRemoteGdbKey, DefaultUseRemoteGdbValue).toBool();
m_gdbMountPort = map.value(GdbMountPortKey, DefaultGdbMountPort).toInt();
m_userEnvironmentChanges =
ProjectExplorer::EnvironmentItem::fromStringList(map.value(UserEnvironmentChangesKey)
.toStringList());
@@ -250,6 +263,26 @@ const QString MaemoRunConfiguration::dumperLib() const
return qt4bc->qtVersion()->debuggingHelperLibrary();
}
QString MaemoRunConfiguration::localDirToMountForRemoteGdb() const
{
const QString projectDir
= QDir::fromNativeSeparators(QDir::cleanPath(activeBuildConfiguration()
->target()->project()->projectDirectory()));
const QString execDir
= QDir::fromNativeSeparators(QFileInfo(localExecutableFilePath()).path());
const int length = qMin(projectDir.length(), execDir.length());
int lastSeparatorPos = 0;
for (int i = 0; i < length; ++i) {
if (projectDir.at(i) != execDir.at(i))
return projectDir.left(lastSeparatorPos);
if (projectDir.at(i) == QLatin1Char('/'))
lastSeparatorPos = i;
}
return projectDir.length() == execDir.length()
? projectDir : projectDir.left(lastSeparatorPos);
}
QString MaemoRunConfiguration::localExecutableFilePath() const
{
TargetInformation ti = qt4Target()->qt4Project()->rootProjectNode()

View File

@@ -96,9 +96,14 @@ public:
MaemoDeviceConfig deviceConfig() const;
MaemoDeviceConfigListModel *deviceConfigModel() const;
QString runtimeGdbServerPort() const;
bool useRemoteGdb() const { return m_useRemoteGdb; }
void setUseRemoteGdb(bool useRemoteGdb) { m_useRemoteGdb = useRemoteGdb; }
int gdbMountPort() const { return m_gdbMountPort; }
void setGdbMountPort(int port) { m_gdbMountPort = port; }
const QString gdbCmd() const;
const QString dumperLib() const;
QString localDirToMountForRemoteGdb() const;
virtual QVariantMap toMap() const;
@@ -141,6 +146,8 @@ private:
MaemoRemoteMountsModel *m_remoteMounts;
QStringList m_arguments;
QString m_hostAddressFromDevice;
bool m_useRemoteGdb;
int m_gdbMountPort;
BaseEnvironmentBase m_baseEnvironmentBase;
ProjectExplorer::Environment m_systemEnvironment;

View File

@@ -54,6 +54,8 @@
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QRadioButton>
#include <QtGui/QSpinBox>
#include <QtGui/QTableView>
#include <QtGui/QToolButton>
@@ -69,7 +71,15 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
{
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
addGenericWidgets(mainLayout);
mainLayout->addSpacing(20);
addDebuggingWidgets(mainLayout);
addMountWidgets(mainLayout);
addEnvironmentWidgets(mainLayout);
}
void MaemoRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayout)
{
QFormLayout *formLayout = new QFormLayout;
mainLayout->addLayout(formLayout);
formLayout->setFormAlignment(Qt::AlignLeft | Qt::AlignVCenter);
@@ -80,7 +90,7 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
QHBoxLayout *devConfLayout = new QHBoxLayout(devConfWidget);
m_devConfBox = new QComboBox;
m_devConfBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
m_devConfBox->setModel(runConfiguration->deviceConfigModel());
m_devConfBox->setModel(m_runConfiguration->deviceConfigModel());
devConfLayout->setMargin(0);
devConfLayout->addWidget(m_devConfBox);
QLabel *addDevConfLabel= new QLabel(tr("<a href=\"%1\">Manage device configurations</a>")
@@ -99,24 +109,86 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
m_argsLineEdit = new QLineEdit(m_runConfiguration->arguments().join(" "));
formLayout->addRow(tr("Arguments:"), m_argsLineEdit);
mainLayout->addSpacing(20);
m_detailsContainer = new Utils::DetailsWidget(this);
QWidget *mountViewWidget = new QWidget;
m_detailsContainer->setWidget(mountViewWidget);
connect(addDevConfLabel, SIGNAL(linkActivated(QString)), this,
SLOT(showSettingsDialog(QString)));
connect(debuggerConfLabel, SIGNAL(linkActivated(QString)), this,
SLOT(showSettingsDialog(QString)));
connect(m_configNameLineEdit, SIGNAL(textEdited(QString)), this,
SLOT(configNameEdited(QString)));
connect(m_argsLineEdit, SIGNAL(textEdited(QString)), this,
SLOT(argumentsEdited(QString)));
connect(m_devConfBox, SIGNAL(activated(int)), this,
SLOT(setCurrentDeviceConfig(int)));
connect(m_runConfiguration->deviceConfigModel(), SIGNAL(currentChanged()),
this, SLOT(handleCurrentDeviceConfigChanged()));
connect(m_runConfiguration, SIGNAL(targetInformationChanged()), this,
SLOT(updateTargetInformation()));
handleCurrentDeviceConfigChanged();
}
void MaemoRunConfigurationWidget::addDebuggingWidgets(QVBoxLayout *mainLayout)
{
m_debugDetailsContainer = new Utils::DetailsWidget(this);
QWidget *debugWidget = new QWidget;
m_debugDetailsContainer->setWidget(debugWidget);
#ifndef Q_OS_WIN
mainLayout->addWidget(m_detailsContainer);
mainLayout->addWidget(m_debugDetailsContainer);
#endif
QFormLayout *debugLayout = new QFormLayout(debugWidget);
QHBoxLayout *debugRadioButtonsLayout = new QHBoxLayout;
debugLayout->addRow(debugRadioButtonsLayout);
QRadioButton *gdbButton = new QRadioButton(tr("Use remote gdb"));
QRadioButton *gdbServerButton = new QRadioButton(tr("Use remote gdbserver"));
debugRadioButtonsLayout->addWidget(gdbButton);
debugRadioButtonsLayout->addWidget(gdbServerButton);
debugRadioButtonsLayout->addStretch(1);
QHBoxLayout *debugHostAddressLayout = new QHBoxLayout;
m_hostAddressLineEdit2 = new QLineEdit;
debugHostAddressLayout->addWidget(m_hostAddressLineEdit2);
debugHostAddressLayout->addStretch(1);
debugLayout->addRow(tr("This host's address from the device:"),
debugHostAddressLayout);
m_hostAddressLineEdit2->setText(m_runConfiguration->localHostAddressFromDevice());
gdbButton->setChecked(m_runConfiguration->useRemoteGdb());
gdbServerButton->setChecked(!gdbButton->isChecked());
connect(m_hostAddressLineEdit2, SIGNAL(textEdited(QString)), this,
SLOT(handleHostAddressChanged(QString)));
connect(gdbButton, SIGNAL(toggled(bool)), this,
SLOT(handleDebuggingTypeChanged(bool)));
QHBoxLayout *spinBoxLayout = new QHBoxLayout;
m_gdbMountPortSpinBox = new QSpinBox;
m_gdbMountPortSpinBox->setMinimum(1024);
m_gdbMountPortSpinBox->setMaximum((1 << 16) - 1);
spinBoxLayout->addWidget(m_gdbMountPortSpinBox);
spinBoxLayout->addStretch(1);
debugLayout->addRow(tr("Local port for mounting the project directory:"),
spinBoxLayout);
m_gdbMountPortSpinBox->setValue(m_runConfiguration->gdbMountPort());
connect(m_gdbMountPortSpinBox, SIGNAL(valueChanged(int)), this,
SLOT(handleGdbMountPortChanged(int)));
handleDebuggingTypeChanged(gdbButton->isChecked());
}
void MaemoRunConfigurationWidget::addMountWidgets(QVBoxLayout *mainLayout)
{
m_mountDetailsContainer = new Utils::DetailsWidget(this);
QWidget *mountViewWidget = new QWidget;
m_mountDetailsContainer->setWidget(mountViewWidget);
#ifndef Q_OS_WIN
mainLayout->addWidget(m_mountDetailsContainer);
#endif
QVBoxLayout *mountViewLayout = new QVBoxLayout(mountViewWidget);
QHBoxLayout *hostAddressLayout = new QHBoxLayout;
mountViewLayout->addLayout(hostAddressLayout);
QLabel *hostNameLabel
= new QLabel(tr("This host's address from the device:"));
m_hostAddressLineEdit = new QLineEdit;
m_hostAddressLineEdit->setText(m_runConfiguration->localHostAddressFromDevice());
connect(m_hostAddressLineEdit, SIGNAL(editingFinished()), this,
SLOT(handleHostAddressChanged()));
m_hostAddressLineEdit1 = new QLineEdit;
m_hostAddressLineEdit1->setText(m_runConfiguration->localHostAddressFromDevice());
connect(m_hostAddressLineEdit1, SIGNAL(textEdited(QString)), this,
SLOT(handleHostAddressChanged(QString)));
hostAddressLayout->addWidget(hostNameLabel);
hostAddressLayout->addWidget(m_hostAddressLineEdit);
hostAddressLayout->addWidget(m_hostAddressLineEdit1);
hostAddressLayout->addStretch(1);
QHBoxLayout *tableLayout = new QHBoxLayout;
mountViewLayout->addLayout(tableLayout);
@@ -139,10 +211,34 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
mountViewButtonsLayout->addWidget(m_removeMountButton);
mountViewButtonsLayout->addStretch(1);
connect(addMountButton, SIGNAL(clicked()), this, SLOT(addMount()));
connect(m_removeMountButton, SIGNAL(clicked()), this, SLOT(removeMount()));
connect(m_mountView, SIGNAL(doubleClicked(QModelIndex)), this,
SLOT(changeLocalMountDir(QModelIndex)));
connect(m_mountView->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this,
SLOT(enableOrDisableRemoveMountSpecButton()));
connect(m_runConfiguration->remoteMounts(),
SIGNAL(rowsInserted(QModelIndex, int, int)), this,
SLOT(handleRemoteMountsChanged()));
connect(m_runConfiguration->remoteMounts(),
SIGNAL(rowsRemoved(QModelIndex, int, int)), this,
SLOT(handleRemoteMountsChanged()));
connect(m_runConfiguration->remoteMounts(),
SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
SLOT(handleRemoteMountsChanged()));
connect(m_runConfiguration->remoteMounts(), SIGNAL(modelReset()), this,
SLOT(handleRemoteMountsChanged()));
enableOrDisableRemoveMountSpecButton();
handleRemoteMountsChanged();
}
void MaemoRunConfigurationWidget::addEnvironmentWidgets(QVBoxLayout *mainLayout)
{
QWidget *baseEnvironmentWidget = new QWidget;
QHBoxLayout *baseEnvironmentLayout = new QHBoxLayout(baseEnvironmentWidget);
baseEnvironmentLayout->setMargin(0);
QLabel *label = new QLabel(tr("Base environment for this runconfiguration:"), this);
QLabel *label = new QLabel(tr("Base environment for this run configuration:"), this);
baseEnvironmentLayout->addWidget(label);
m_baseEnvironmentComboBox = new QComboBox(this);
m_baseEnvironmentComboBox->addItems(QStringList() << tr("Clean Environment")
@@ -160,44 +256,6 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
m_environmentWidget->setUserChanges(m_runConfiguration->userEnvironmentChanges());
mainLayout->addWidget(m_environmentWidget);
handleCurrentDeviceConfigChanged();
enableOrDisableRemoveButton();
handleRemoteMountsChanged();
connect(m_configNameLineEdit, SIGNAL(textEdited(QString)), this,
SLOT(configNameEdited(QString)));
connect(m_argsLineEdit, SIGNAL(textEdited(QString)), this,
SLOT(argumentsEdited(QString)));
connect(m_devConfBox, SIGNAL(activated(int)), this,
SLOT(setCurrentDeviceConfig(int)));
connect(runConfiguration->deviceConfigModel(), SIGNAL(currentChanged()),
this, SLOT(handleCurrentDeviceConfigChanged()));
connect(m_runConfiguration, SIGNAL(targetInformationChanged()), this,
SLOT(updateTargetInformation()));
connect(addDevConfLabel, SIGNAL(linkActivated(QString)), this,
SLOT(showSettingsDialog(QString)));
connect(debuggerConfLabel, SIGNAL(linkActivated(QString)), this,
SLOT(showSettingsDialog(QString)));
connect(addMountButton, SIGNAL(clicked()), this, SLOT(addMount()));
connect(m_removeMountButton, SIGNAL(clicked()), this, SLOT(removeMount()));
connect(m_mountView, SIGNAL(doubleClicked(QModelIndex)), this,
SLOT(changeLocalMountDir(QModelIndex)));
connect(m_mountView->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this,
SLOT(enableOrDisableRemoveButton()));
connect(m_runConfiguration->remoteMounts(),
SIGNAL(rowsInserted(QModelIndex, int, int)), this,
SLOT(handleRemoteMountsChanged()));
connect(m_runConfiguration->remoteMounts(),
SIGNAL(rowsRemoved(QModelIndex, int, int)), this,
SLOT(handleRemoteMountsChanged()));
connect(m_runConfiguration->remoteMounts(),
SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
SLOT(handleRemoteMountsChanged()));
connect(m_runConfiguration->remoteMounts(), SIGNAL(modelReset()), this,
SLOT(handleRemoteMountsChanged()));
connect(m_environmentWidget, SIGNAL(userChangesChanged()), this,
SLOT(userChangesEdited()));
connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)),
@@ -250,7 +308,7 @@ void MaemoRunConfigurationWidget::setCurrentDeviceConfig(int index)
m_runConfiguration->deviceConfigModel()->setCurrentIndex(index);
}
void MaemoRunConfigurationWidget::enableOrDisableRemoveButton()
void MaemoRunConfigurationWidget::enableOrDisableRemoveMountSpecButton()
{
const QModelIndexList selectedRows
= m_mountView->selectionModel()->selectedRows();
@@ -294,9 +352,26 @@ void MaemoRunConfigurationWidget::changeLocalMountDir(const QModelIndex &index)
}
}
void MaemoRunConfigurationWidget::handleHostAddressChanged()
void MaemoRunConfigurationWidget::handleHostAddressChanged(const QString &newAddress)
{
m_runConfiguration->setLocalHostAddressFromDevice(m_hostAddressLineEdit->text());
m_hostAddressLineEdit1->setText(newAddress);
m_hostAddressLineEdit2->setText(newAddress);
m_runConfiguration->setLocalHostAddressFromDevice(newAddress);
}
void MaemoRunConfigurationWidget::handleDebuggingTypeChanged(bool useGdb)
{
m_runConfiguration->setUseRemoteGdb(useGdb);
const QString detailsText = useGdb ? tr("Use gdb") : tr("Use gdbserver");
m_debugDetailsContainer->setSummaryText(tr("<b>Debugging details:</b> ")
+ detailsText);
m_hostAddressLineEdit2->setEnabled(useGdb);
m_gdbMountPortSpinBox->setEnabled(useGdb);
}
void MaemoRunConfigurationWidget::handleGdbMountPortChanged(int port)
{
m_runConfiguration->setGdbMountPort(port);
}
void MaemoRunConfigurationWidget::fetchEnvironment()
@@ -367,7 +442,7 @@ void MaemoRunConfigurationWidget::handleRemoteMountsChanged()
.arg(mountCount);
break;
}
m_detailsContainer->setSummaryText(QLatin1String("<b>") + text
m_mountDetailsContainer->setSummaryText(QLatin1String("<b>") + text
+ QLatin1String("</b>"));
}

View File

@@ -43,8 +43,10 @@ class QLabel;
class QLineEdit;
class QModelIndex;
class QPushButton;
class QSpinBox;
class QTableView;
class QToolButton;
class QVBoxLayout;
QT_END_NAMESPACE
namespace ProjectExplorer {
@@ -77,8 +79,10 @@ private slots:
void addMount();
void removeMount();
void changeLocalMountDir(const QModelIndex &index);
void enableOrDisableRemoveButton();
void handleHostAddressChanged();
void enableOrDisableRemoveMountSpecButton();
void handleHostAddressChanged(const QString &newAddress);
void handleDebuggingTypeChanged(bool useGdb);
void handleGdbMountPortChanged(int port);
void fetchEnvironment();
void fetchEnvironmentFinished();
void userChangesEdited();
@@ -89,14 +93,22 @@ private slots:
void handleRemoteMountsChanged();
private:
void addGenericWidgets(QVBoxLayout *mainLayout);
void addDebuggingWidgets(QVBoxLayout *mainLayout);
void addMountWidgets(QVBoxLayout *mainLayout);
void addEnvironmentWidgets(QVBoxLayout *mainLayout);
QLineEdit *m_configNameLineEdit;
QLineEdit *m_argsLineEdit;
QLabel *m_executableLabel;
QComboBox *m_devConfBox;
QLineEdit *m_hostAddressLineEdit;
QLineEdit *m_hostAddressLineEdit1;
QLineEdit *m_hostAddressLineEdit2;
QSpinBox *m_gdbMountPortSpinBox;
QTableView *m_mountView;
QToolButton *m_removeMountButton;
Utils::DetailsWidget *m_detailsContainer;
Utils::DetailsWidget *m_mountDetailsContainer;
Utils::DetailsWidget *m_debugDetailsContainer;
MaemoRunConfiguration *m_runConfiguration;
bool m_ignoreChange;

View File

@@ -57,7 +57,7 @@ MaemoRunControl::MaemoRunControl(RunConfiguration *rc)
: RunControl(rc, ProjectExplorer::Constants::RUNMODE)
, m_runConfig(qobject_cast<MaemoRunConfiguration *>(rc))
, m_devConfig(m_runConfig ? m_runConfig->deviceConfig() : MaemoDeviceConfig())
, m_runner(new MaemoSshRunner(this, m_runConfig))
, m_runner(new MaemoSshRunner(this, m_runConfig, false))
, m_running(false)
{
}

View File

@@ -36,7 +36,6 @@
#include "maemodeviceconfigurations.h"
#include "maemoglobal.h"
#include "maemoremotemountsmodel.h"
#include "maemorunconfiguration.h"
#include "maemotoolchain.h"
@@ -53,14 +52,17 @@ namespace Qt4ProjectManager {
namespace Internal {
MaemoSshRunner::MaemoSshRunner(QObject *parent,
MaemoRunConfiguration *runConfig)
MaemoRunConfiguration *runConfig, bool debugging)
: QObject(parent), m_runConfig(runConfig),
m_devConfig(runConfig->deviceConfig()),
m_uploadJobId(SftpInvalidJob)
m_uploadJobId(SftpInvalidJob),
m_debugging(debugging)
{
m_procsToKill
<< QFileInfo(m_runConfig->localExecutableFilePath()).fileName()
<< QLatin1String("utfs-client");
if (debugging)
m_procsToKill << QLatin1String("gdbserver");
}
MaemoSshRunner::~MaemoSshRunner() {}
@@ -70,13 +72,24 @@ void MaemoSshRunner::setConnection(const QSharedPointer<Core::SshConnection> &co
m_connection = connection;
}
void MaemoSshRunner::addProcsToKill(const QStringList &appNames)
{
m_procsToKill << appNames;
}
void MaemoSshRunner::start()
{
m_mountSpecs.clear();
const MaemoRemoteMountsModel * const remoteMounts
= m_runConfig->remoteMounts();
for (int i = 0; i < remoteMounts->mountSpecificationCount(); ++i) {
const MaemoRemoteMountsModel::MountSpecification &mountSpec
= remoteMounts->mountSpecificationAt(i);
if (mountSpec.isValid())
m_mountSpecs << mountSpec;
}
if (m_debugging && m_runConfig->useRemoteGdb()) {
m_mountSpecs << MaemoRemoteMountsModel::MountSpecification(
m_runConfig->localDirToMountForRemoteGdb(),
MaemoGlobal::remoteProjectSourcesMountPoint(),
m_runConfig->gdbMountPort());
}
m_stop = false;
if (m_connection)
disconnect(m_connection.data(), 0, this, 0);
@@ -109,9 +122,11 @@ void MaemoSshRunner::stop()
disconnect(m_mountProcess.data(), 0, this, 0);
m_mountProcess->closeChannel();
}
if (m_debugging || m_runner) {
if (m_runner) {
disconnect(m_runner.data(), 0, this, 0);
m_runner->closeChannel();
}
cleanup(false);
}
}
@@ -140,18 +155,12 @@ void MaemoSshRunner::cleanup(bool initialCleanup)
}
QString remoteCall = niceKill + QLatin1String("sleep 1; ") + brutalKill;
const MaemoRemoteMountsModel * const remoteMounts
= m_runConfig->remoteMounts();
for (int i = 0; i < remoteMounts->mountSpecificationCount(); ++i) {
const MaemoRemoteMountsModel::MountSpecification &mountSpec
= remoteMounts->mountSpecificationAt(i);
if (mountSpec.isValid()) {
for (int i = 0; i < m_mountSpecs.count(); ++i) {
remoteCall += QString::fromLocal8Bit("%1 umount %2;")
.arg(MaemoGlobal::remoteSudo(), mountSpec.remoteMountPoint);
.arg(MaemoGlobal::remoteSudo(), m_mountSpecs.at(i).remoteMountPoint);
}
}
remoteCall.remove(remoteCall.count() - 1, 1); // Get rid of trailing semicolon.
SshRemoteProcess::Ptr proc
= m_connection->createRemoteProcess(remoteCall.toUtf8());
if (initialCleanup) {
@@ -180,7 +189,7 @@ void MaemoSshRunner::handleInitialCleanupFinished(int exitStatus)
if (exitStatus != SshRemoteProcess::ExitedNormally) {
emit error(tr("Initial cleanup failed: %1")
.arg(m_initialCleaner->errorString()));
} else if (m_runConfig->remoteMounts()->hasValidMountSpecifications()) {
} else if (!m_mountSpecs.isEmpty()) {
deployUtfsClient();
} else {
emit readyForExecution();
@@ -248,20 +257,15 @@ void MaemoSshRunner::handleUploadFinished(Core::SftpJobId jobId,
void MaemoSshRunner::mount()
{
const MaemoRemoteMountsModel * const remoteMounts
= m_runConfig->remoteMounts();
const QString chmodFuse
= MaemoGlobal::remoteSudo() + QLatin1String(" chmod a+r+w /dev/fuse");
const QString chmodUtfsClient
= QLatin1String("chmod a+x ") + utfsClientOnDevice();
const QLatin1String andOp(" && ");
QString remoteCall = chmodFuse + andOp + chmodUtfsClient;
for (int i = 0; i < remoteMounts->mountSpecificationCount(); ++i) {
for (int i = 0; i < m_mountSpecs.count(); ++i) {
const MaemoRemoteMountsModel::MountSpecification &mountSpec
= remoteMounts->mountSpecificationAt(i);
if (!mountSpec.isValid())
continue;
= m_mountSpecs.at(i);
QProcess * const utfsServerProc = new QProcess(this);
connect(utfsServerProc, SIGNAL(readyReadStandardError()), this,
SLOT(handleUtfsServerErrorOutput()));

View File

@@ -39,6 +39,7 @@
#include <QtCore/QSharedPointer>
#include "maemodeviceconfigurations.h"
#include "maemoremotemountsmodel.h"
#include <coreplugin/ssh/sftpdefs.h>
@@ -60,11 +61,11 @@ class MaemoSshRunner : public QObject
{
Q_OBJECT
public:
MaemoSshRunner(QObject *parent, MaemoRunConfiguration *runConfig);
MaemoSshRunner(QObject *parent, MaemoRunConfiguration *runConfig,
bool debugging);
~MaemoSshRunner();
void setConnection(const QSharedPointer<Core::SshConnection> &connection);
void addProcsToKill(const QStringList &appNames);
void start();
void stop();
@@ -109,9 +110,11 @@ private:
QSharedPointer<Core::SftpChannel> m_utfsClientUploader;
QStringList m_procsToKill;
QList<QProcess *> m_utfsServers;
QList<MaemoRemoteMountsModel::MountSpecification> m_mountSpecs;
Core::SftpJobId m_uploadJobId;
bool m_stop;
const bool m_debugging;
};
} // namespace Internal