params.executable = runConfig->remoteExecutableFilePath();
params.debuggerCommand
= MaemoGlobal::remoteCommandPrefix(runConfig->remoteExecutableFilePath())
- + environment(runConfig) + QLatin1String(" /usr/bin/gdb");
+ + environment(runConfig->debuggingType(), runConfig->userEnvironmentChanges())
+ + QLatin1String(" /usr/bin/gdb");
params.connParams = devConf.server;
params.localMountDir = runConfig->localDirToMountForRemoteGdb();
params.remoteMountPoint
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, true)),
- m_debuggingType(m_runConfig->debuggingType()),
+ m_runner(new MaemoSshRunner(this, runConfig, true)),
+ m_debuggingType(runConfig->debuggingType()),
+ m_dumperLib(runConfig->dumperLib()),
m_state(Inactive), m_gdbServerPort(-1), m_qmlPort(-1)
{
connect(m_runControl, SIGNAL(engineRequestSetup()), this,
{
ASSERT_STATE(Inactive);
- if (!m_deviceConfig.isValid()) {
- handleAdapterSetupFailed(tr("No device configuration set for run configuration."));
- return;
- }
setState(StartingRunner);
m_runControl->showMessage(tr("Preparing remote side ..."), AppStuff);
disconnect(m_runner, 0, this, 0);
return;
}
- const QString &dumperLib = m_runConfig->dumperLib();
if (m_debuggingType != MaemoRunConfiguration::DebugQmlOnly
- && !dumperLib.isEmpty()
- && m_runConfig->deployStep()->currentlyNeedsDeployment(m_deviceConfig.server.host,
- MaemoDeployable(dumperLib, uploadDir(m_deviceConfig)))) {
+ && !m_dumperLib.isEmpty()
+ && m_runConfig
+ && m_runConfig->deployStep()->currentlyNeedsDeployment(m_runner->deviceConfig().server.host,
+ MaemoDeployable(m_dumperLib, uploadDir(m_runner->deviceConfig())))) {
setState(InitializingUploader);
m_uploader = m_runner->connection()->createSftpChannel();
connect(m_uploader.data(), SIGNAL(initialized()), this,
ASSERT_STATE(InitializingUploader);
- const QString dumperLib = m_runConfig->dumperLib();
- const QString fileName = QFileInfo(dumperLib).fileName();
- const QString remoteFilePath = uploadDir(m_deviceConfig) + '/' + fileName;
- m_uploadJob = m_uploader->uploadFile(dumperLib, remoteFilePath,
+ const QString fileName = QFileInfo(m_dumperLib).fileName();
+ const QString remoteFilePath
+ = uploadDir(m_runner->deviceConfig()) + '/' + fileName;
+ m_uploadJob = m_uploader->uploadFile(m_dumperLib, remoteFilePath,
SftpOverwriteExisting);
if (m_uploadJob == SftpInvalidJob) {
handleAdapterSetupFailed(tr("Upload failed: Could not open file '%1'")
- .arg(dumperLib));
+ .arg(m_dumperLib));
} else {
setState(UploadingDumpers);
m_runControl->showMessage(tr("Started uploading debugging helpers ('%1').")
- .arg(dumperLib), AppStuff);
+ .arg(m_dumperLib), AppStuff);
}
}
.arg(error));
} else {
setState(DumpersUploaded);
- m_runConfig->deployStep()->setDeployed(m_deviceConfig.server.host,
- MaemoDeployable(m_runConfig->dumperLib(), uploadDir(m_deviceConfig)));
+ if (m_runConfig) {
+ m_runConfig->deployStep()->setDeployed(m_runner->deviceConfig().server.host,
+ MaemoDeployable(m_dumperLib, uploadDir(m_runner->deviceConfig())));
+ }
m_runControl->showMessage(tr("Finished uploading debugging helpers."), AppStuff);
startDebugging();
}
SLOT(handleRemoteErrorOutput(QByteArray)));
connect(m_runner, SIGNAL(remoteOutput(QByteArray)), this,
SLOT(handleRemoteOutput(QByteArray)));
- const QString &remoteExe = m_runConfig->remoteExecutableFilePath();
+ const QString &remoteExe = m_runner->remoteExecutable();
const QString cmdPrefix = MaemoGlobal::remoteCommandPrefix(remoteExe);
- const QString env = environment(m_runConfig);
- const QString args = m_runConfig->arguments().join(QLatin1String(" "));
+ const QString env
+ = environment(m_debuggingType, m_runner->userEnvChanges());
+ const QString args = m_runner->arguments().join(QLatin1String(" "));
const QString remoteCommandLine
= m_debuggingType == MaemoRunConfiguration::DebugQmlOnly
? QString::fromLocal8Bit("%1 %2 %3 %4").arg(cmdPrefix).arg(env)
}
}
-QString MaemoDebugSupport::environment(const MaemoRunConfiguration *rc)
+QString MaemoDebugSupport::environment(MaemoRunConfiguration::DebuggingType debuggingType,
+ const QList<Utils::EnvironmentItem> &userEnvChanges)
{
- QList<Utils::EnvironmentItem> env = rc->userEnvironmentChanges();
// FIXME: this must use command line argument instead: -qmljsdebugger=port:1234.
- if (rc->debuggingType() != MaemoRunConfiguration::DebugCppOnly) {
+ if (debuggingType != MaemoRunConfiguration::DebugCppOnly) {
// env << Utils::EnvironmentItem(QLatin1String(Debugger::Constants::E_QML_DEBUG_SERVER_PORT),
// QString::number(qmlServerPort(rc)));
}
- return MaemoGlobal::remoteEnvironment(env);
+ return MaemoGlobal::remoteEnvironment(userEnvChanges);
}
QString MaemoDebugSupport::uploadDir(const MaemoDeviceConfig &devConf)
#ifndef MAEMODEBUGSUPPORT_H
#define MAEMODEBUGSUPPORT_H
-#include "maemodeviceconfigurations.h"
#include "maemorunconfiguration.h"
#include <coreplugin/ssh/sftpdefs.h>
+#include <utils/environment.h>
#include <QtCore/QObject>
#include <QtCore/QPointer>
DumpersUploaded, StartingRemoteProcess, Debugging
};
- static QString environment(const MaemoRunConfiguration *rc);
+ static QString environment(MaemoRunConfiguration::DebuggingType debuggingType,
+ const QList<Utils::EnvironmentItem> &userEnvChanges);
void handleAdapterSetupFailed(const QString &error);
void handleAdapterSetupDone();
bool setPort(int &port);
const QPointer<Debugger::DebuggerRunControl> m_runControl;
- MaemoRunConfiguration * const m_runConfig;
- const MaemoDeviceConfig m_deviceConfig;
+ const QPointer<MaemoRunConfiguration> m_runConfig;
MaemoSshRunner * const m_runner;
const MaemoRunConfiguration::DebuggingType m_debuggingType;
+ const QString m_dumperLib;
QSharedPointer<Core::SftpChannel> m_uploader;
Core::SftpJobId m_uploadJob;
namespace Internal {
MaemoRemoteMounter::MaemoRemoteMounter(QObject *parent)
- : QObject(parent), m_toolChain(0), m_utfsServerTimer(new QTimer(this)),
+ : QObject(parent), m_utfsServerTimer(new QTimer(this)),
m_uploadJobId(SftpInvalidJob), m_state(Inactive)
{
connect(m_utfsServerTimer, SIGNAL(timeout()), this,
killAllUtfsServers();
}
-void MaemoRemoteMounter::setConnection(const Core::SshConnection::Ptr &connection)
+void MaemoRemoteMounter::setConnection(const SshConnection::Ptr &connection)
{
ASSERT_STATE(Inactive);
-
m_connection = connection;
}
+void MaemoRemoteMounter::setToolchain(const MaemoToolChain *toolChain)
+{
+ ASSERT_STATE(Inactive);
+ m_remoteMountsAllowed = toolChain->allowsRemoteMounts();
+ m_maddeRoot = toolChain->maddeRoot();
+}
+
void MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec,
bool mountAsRoot)
{
- Q_ASSERT(m_toolChain);
ASSERT_STATE(Inactive);
- if (m_toolChain->allowsRemoteMounts() && mountSpec.isValid())
+ if (m_remoteMountsAllowed && mountSpec.isValid())
m_mountSpecs << MountInfo(mountSpec, mountAsRoot);
}
SIGNAL(finished(Core::SftpJobId, QString)), this,
SLOT(handleUploadFinished(Core::SftpJobId, QString)));
const QString localFile
- = m_toolChain->maddeRoot() + QLatin1String("/madlib/armel/utfs-client");
+ = m_maddeRoot + QLatin1String("/madlib/armel/utfs-client");
m_uploadJobId = m_utfsClientUploader->uploadFile(localFile,
utfsClientOnDevice(), SftpOverwriteExisting);
if (m_uploadJobId == SftpInvalidJob) {
QString MaemoRemoteMounter::utfsServer() const
{
- return m_toolChain->maddeRoot() + QLatin1String("/madlib/utfs-server");
+ return m_maddeRoot + QLatin1String("/madlib/utfs-server");
}
void MaemoRemoteMounter::killAllUtfsServers()
public:
MaemoRemoteMounter(QObject *parent);
~MaemoRemoteMounter();
- void setToolchain(const MaemoToolChain *toolchain) { m_toolChain = toolchain; }
+
+ // Must already be connected.
+ void setConnection(const QSharedPointer<Core::SshConnection> &connection);
+
+ void setToolchain(const MaemoToolChain *toolChain);
void addMountSpecification(const MaemoMountSpecification &mountSpec,
bool mountAsRoot);
bool hasValidMountSpecifications() const;
void unmount();
void stop();
- // Must be connected already.
- void setConnection(const QSharedPointer<Core::SshConnection> &connection);
-
signals:
void mounted();
void unmounted();
QString utfsClientOnDevice() const;
QString utfsServer() const;
- const MaemoToolChain *m_toolChain;
QTimer * const m_utfsServerTimer;
struct MountInfo {
QByteArray m_umountStderr;
MaemoPortList *m_freePorts;
const MaemoUsedPortsGatherer *m_portsGatherer;
+ bool m_remoteMountsAllowed;
+ QString m_maddeRoot;
State m_state;
};
int validMountSpecificationCount() const;
MaemoMountSpecification mountSpecificationAt(int pos) const { return m_mountSpecs.at(pos); }
bool hasValidMountSpecifications() const;
+ const QList<MaemoMountSpecification> &mountSpecs() const { return m_mountSpecs; }
void addMountSpecification(const QString &localDir);
void removeMountSpecificationAt(int pos);
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, false))
+ , m_runner(new MaemoSshRunner(this, qobject_cast<MaemoRunConfiguration *>(rc), false))
, m_running(false)
{
}
void MaemoRunControl::start()
{
- if (!m_devConfig.isValid()) {
- handleError(tr("No device configuration set for run configuration."));
- } else if (!m_runConfig) {
- handleError(tr("Run configuration no longer available."));
- } else {
- m_running = true;
- emit started();
- disconnect(m_runner, 0, this, 0);
- connect(m_runner, SIGNAL(error(QString)), this,
- SLOT(handleSshError(QString)));
- connect(m_runner, SIGNAL(readyForExecution()), this,
- SLOT(startExecution()));
- connect(m_runner, SIGNAL(remoteErrorOutput(QByteArray)), this,
- SLOT(handleRemoteErrorOutput(QByteArray)));
- connect(m_runner, SIGNAL(remoteOutput(QByteArray)), this,
- SLOT(handleRemoteOutput(QByteArray)));
- connect(m_runner, SIGNAL(remoteProcessStarted()), this,
- SLOT(handleRemoteProcessStarted()));
- connect(m_runner, SIGNAL(remoteProcessFinished(qint64)), this,
- SLOT(handleRemoteProcessFinished(qint64)));
- connect(m_runner, SIGNAL(reportProgress(QString)), this,
- SLOT(handleProgressReport(QString)));
- connect(m_runner, SIGNAL(mountDebugOutput(QString)), this,
- SLOT(handleMountDebugOutput(QString)));
- m_runner->start();
- }
+ m_running = true;
+ emit started();
+ disconnect(m_runner, 0, this, 0);
+ connect(m_runner, SIGNAL(error(QString)), SLOT(handleSshError(QString)));
+ connect(m_runner, SIGNAL(readyForExecution()), SLOT(startExecution()));
+ connect(m_runner, SIGNAL(remoteErrorOutput(QByteArray)),
+ SLOT(handleRemoteErrorOutput(QByteArray)));
+ connect(m_runner, SIGNAL(remoteOutput(QByteArray)),
+ SLOT(handleRemoteOutput(QByteArray)));
+ connect(m_runner, SIGNAL(remoteProcessStarted()),
+ SLOT(handleRemoteProcessStarted()));
+ connect(m_runner, SIGNAL(remoteProcessFinished(qint64)),
+ SLOT(handleRemoteProcessFinished(qint64)));
+ connect(m_runner, SIGNAL(reportProgress(QString)),
+ SLOT(handleProgressReport(QString)));
+ connect(m_runner, SIGNAL(mountDebugOutput(QString)),
+ SLOT(handleMountDebugOutput(QString)));
+ m_runner->start();
}
ProjectExplorer::RunControl::StopResult MaemoRunControl::stop()
void MaemoRunControl::startExecution()
{
emit appendMessage(this, tr("Starting remote process ..."), false);
- const QString &remoteExe = m_runConfig->remoteExecutableFilePath();
m_runner->startExecution(QString::fromLocal8Bit("%1 %2 %3 %4")
- .arg(MaemoGlobal::remoteCommandPrefix(remoteExe))
- .arg(MaemoGlobal::remoteEnvironment(m_runConfig->userEnvironmentChanges()))
- .arg(remoteExe)
- .arg(m_runConfig->arguments().join(QLatin1String(" "))).toUtf8());
+ .arg(MaemoGlobal::remoteCommandPrefix(m_runner->remoteExecutable()))
+ .arg(MaemoGlobal::remoteEnvironment(m_runner->userEnvChanges()))
+ .arg(m_runner->remoteExecutable())
+ .arg(m_runner->arguments().join(QLatin1String(" "))).toUtf8());
}
void MaemoRunControl::handleRemoteProcessFinished(qint64 exitCode)
#ifndef MAEMORUNCONTROL_H
#define MAEMORUNCONTROL_H
-#include "maemodeviceconfigurations.h"
-
#include <projectexplorer/runconfiguration.h>
-#include <QtCore/QPointer>
#include <QtCore/QString>
namespace Qt4ProjectManager {
void setFinished();
void handleError(const QString &errString);
- QPointer<MaemoRunConfiguration> m_runConfig;
- const MaemoDeviceConfig m_devConfig;
MaemoSshRunner * const m_runner;
bool m_running;
};
MaemoSshRunner::MaemoSshRunner(QObject *parent,
MaemoRunConfiguration *runConfig, bool debugging)
- : QObject(parent), m_runConfig(runConfig),
+ : QObject(parent),
m_mounter(new MaemoRemoteMounter(this)),
m_portsGatherer(new MaemoUsedPortsGatherer(this)),
m_devConfig(runConfig->deviceConfig()),
- m_freePorts(runConfig->freePorts()),
- m_debugging(debugging), m_state(Inactive)
+ m_remoteExecutable(runConfig->remoteExecutableFilePath()),
+ m_appArguments(runConfig->arguments()),
+ m_userEnvChanges(runConfig->userEnvironmentChanges()),
+ m_initialFreePorts(runConfig->freePorts()),
+ m_mountSpecs(runConfig->remoteMounts()->mountSpecs()),
+ m_state(Inactive)
{
- m_procsToKill << QFileInfo(m_runConfig->localExecutableFilePath()).fileName();
+ m_connection = runConfig->deployStep()->sshConnection();
+ m_mounter->setToolchain(runConfig->toolchain());
+ if (debugging && runConfig->useRemoteGdb()) {
+ m_mountSpecs << MaemoMountSpecification(runConfig->localDirToMountForRemoteGdb(),
+ runConfig->remoteProjectSourcesMountPoint());
+ }
+
+ m_procsToKill << QFileInfo(m_remoteExecutable).fileName();
connect(m_mounter, SIGNAL(mounted()), this, SLOT(handleMounted()));
connect(m_mounter, SIGNAL(unmounted()), this, SLOT(handleUnmounted()));
connect(m_mounter, SIGNAL(error(QString)), this,
{
ASSERT_STATE(QList<State>() << Inactive << StopRequested);
+ if (m_remoteExecutable.isEmpty()) {
+ emitError(tr("Cannot run: No remote executable set."));
+ return;
+ }
+ if (!m_devConfig.isValid()) {
+ emitError(tr("Cannot run: No device configuration set."));
+ return;
+ }
+
setState(Connecting);
m_exitStatus = -1;
+ m_freePorts = m_initialFreePorts;
if (m_connection)
disconnect(m_connection.data(), 0, this, 0);
- m_connection = m_runConfig->deployStep()->sshConnection();
const bool reUse = isConnectionUsable();
if (!reUse)
m_connection = SshConnection::create();
switch (m_state) {
case PreRunCleaning: {
- m_mounter->resetMountSpecifications();
- m_mounter->setToolchain(m_runConfig->toolchain());
- const MaemoRemoteMountsModel * const remoteMounts
- = m_runConfig->remoteMounts();
- for (int i = 0; i < remoteMounts->mountSpecificationCount(); ++i)
- m_mounter->addMountSpecification(remoteMounts->mountSpecificationAt(i), false);
- if (m_debugging && m_runConfig->useRemoteGdb()) {
- m_mounter->addMountSpecification(MaemoMountSpecification(
- m_runConfig->localDirToMountForRemoteGdb(),
- m_runConfig->remoteProjectSourcesMountPoint()), false);
- }
+ for (int i = 0; i < m_mountSpecs.count(); ++i)
+ m_mounter->addMountSpecification(m_mountSpecs.at(i), false);
setState(PreMountUnmounting);
unmount();
break;
{
ASSERT_STATE(ReadyForExecution);
- if (m_runConfig->remoteExecutableFilePath().isEmpty()) {
- emitError(tr("Cannot run: No remote executable set."));
- return;
- }
-
m_runner = m_connection->createRemoteProcess(remoteCall);
connect(m_runner.data(), SIGNAL(started()), this,
SIGNAL(remoteProcessStarted()));
#include "maemodeviceconfigurations.h"
#include "maemomountspecification.h"
+#include <utils/environment.h>
+
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
#include <QtCore/QStringList>
const MaemoUsedPortsGatherer *usedPortsGatherer() const { return m_portsGatherer; }
MaemoPortList *freePorts() { return &m_freePorts; }
+ MaemoDeviceConfig deviceConfig() const { return m_devConfig; }
+ QString remoteExecutable() const { return m_remoteExecutable; }
+ QStringList arguments() const { return m_appArguments; }
+ QList<Utils::EnvironmentItem> userEnvChanges() const { return m_userEnvChanges; }
static const qint64 InvalidExitCode;
void mount();
void unmount();
- MaemoRunConfiguration * const m_runConfig; // TODO this pointer can be invalid
MaemoRemoteMounter * const m_mounter;
MaemoUsedPortsGatherer * const m_portsGatherer;
const MaemoDeviceConfig m_devConfig;
+ const QString m_remoteExecutable;
+ const QStringList m_appArguments;
+ const QList<Utils::EnvironmentItem> m_userEnvChanges;
+ const MaemoPortList m_initialFreePorts;
+ QList<MaemoMountSpecification> m_mountSpecs;
QSharedPointer<Core::SshConnection> m_connection;
QSharedPointer<Core::SshRemoteProcess> m_runner;
MaemoPortList m_freePorts;
int m_exitStatus;
- const bool m_debugging;
State m_state;
};