2010-01-06 18:20:43 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2010-01-06 18:20:43 +01:00
|
|
|
** All rights reserved.
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** This file is part of the Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
|
|
|
|
** No Commercial Usage
|
|
|
|
|
** This file contains pre-release code and may not be distributed.
|
|
|
|
|
** You may use this file in accordance with the terms and conditions
|
|
|
|
|
** contained in the Technology Preview License Agreement accompanying
|
|
|
|
|
** this package.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
|
|
|
|
**
|
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "maemoruncontrol.h"
|
2010-04-15 12:47:02 +02:00
|
|
|
|
|
|
|
|
#include "maemopackagecreationstep.h"
|
2010-03-18 10:59:06 +01:00
|
|
|
#include "maemosshthread.h"
|
2010-01-06 18:20:43 +01:00
|
|
|
#include "maemorunconfiguration.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/progressmanager/progressmanager.h>
|
|
|
|
|
#include <debugger/debuggermanager.h>
|
2010-01-07 15:23:33 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
#include <projectexplorer/toolchain.h>
|
2010-01-06 18:20:43 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2010-04-30 13:19:31 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2010-01-06 18:20:43 +01:00
|
|
|
|
|
|
|
|
#include <QtCore/QDir>
|
|
|
|
|
#include <QtCore/QFileInfo>
|
|
|
|
|
#include <QtCore/QFuture>
|
2010-03-09 14:01:59 +01:00
|
|
|
#include <QtCore/QProcess>
|
2010-01-06 18:20:43 +01:00
|
|
|
#include <QtCore/QStringBuilder>
|
|
|
|
|
|
2010-04-12 10:55:17 +02:00
|
|
|
#include <QtGui/QMessageBox>
|
|
|
|
|
|
2010-01-06 18:20:43 +01:00
|
|
|
namespace Qt4ProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-01-07 11:21:11 +01:00
|
|
|
using ProjectExplorer::RunConfiguration;
|
|
|
|
|
using ProjectExplorer::ToolChain;
|
|
|
|
|
|
2010-04-30 13:19:31 +02:00
|
|
|
AbstractMaemoRunControl::AbstractMaemoRunControl(RunConfiguration *rc, QString mode)
|
|
|
|
|
: RunControl(rc, mode)
|
2010-04-13 12:16:47 +02:00
|
|
|
, m_runConfig(qobject_cast<MaemoRunConfiguration *>(rc))
|
|
|
|
|
, m_devConfig(m_runConfig ? m_runConfig->deviceConfig() : MaemoDeviceConfig())
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-18 10:59:06 +01:00
|
|
|
AbstractMaemoRunControl::~AbstractMaemoRunControl()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-13 12:03:32 +02:00
|
|
|
void AbstractMaemoRunControl::start()
|
|
|
|
|
{
|
|
|
|
|
m_stoppedByUser = false;
|
2010-04-14 15:47:07 +02:00
|
|
|
if (!m_devConfig.isValid()) {
|
|
|
|
|
handleError(tr("No device configuration set for run configuration."));
|
|
|
|
|
} else {
|
|
|
|
|
emit started();
|
|
|
|
|
startInitialCleanup();
|
|
|
|
|
}
|
2010-04-13 16:30:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractMaemoRunControl::startInitialCleanup()
|
2010-04-14 15:47:07 +02:00
|
|
|
{
|
2010-04-19 14:21:33 +02:00
|
|
|
emit appendMessage(this, tr("Cleaning up remote leftovers first ..."), false);
|
2010-04-13 16:30:52 +02:00
|
|
|
const QStringList appsToKill
|
|
|
|
|
= QStringList() << executableFileName() << QLatin1String("gdbserver");
|
|
|
|
|
killRemoteProcesses(appsToKill, true);
|
2010-04-13 12:03:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractMaemoRunControl::stop()
|
|
|
|
|
{
|
|
|
|
|
m_stoppedByUser = true;
|
2010-04-13 16:30:52 +02:00
|
|
|
if (isCleaning())
|
|
|
|
|
m_initialCleaner->stop();
|
|
|
|
|
else if (isDeploying())
|
|
|
|
|
m_sshDeployer->stop();
|
2010-04-13 14:34:22 +02:00
|
|
|
else
|
|
|
|
|
stopInternal();
|
2010-04-13 12:03:32 +02:00
|
|
|
}
|
|
|
|
|
|
2010-04-13 16:30:52 +02:00
|
|
|
void AbstractMaemoRunControl::handleInitialCleanupFinished()
|
|
|
|
|
{
|
|
|
|
|
if (m_stoppedByUser) {
|
2010-04-19 14:21:33 +02:00
|
|
|
emit appendMessage(this, tr("Initial cleanup canceled by user."), false);
|
2010-04-13 16:30:52 +02:00
|
|
|
emit finished();
|
|
|
|
|
} else if (m_initialCleaner->hasError()) {
|
|
|
|
|
handleError(tr("Error running initial cleanup: %1.")
|
|
|
|
|
.arg(m_initialCleaner->error()));
|
|
|
|
|
emit finished();
|
|
|
|
|
} else {
|
2010-04-19 14:21:33 +02:00
|
|
|
emit appendMessage(this, tr("Initial cleanup done."), false);
|
2010-04-13 16:30:52 +02:00
|
|
|
startInternal();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-06 18:20:43 +01:00
|
|
|
void AbstractMaemoRunControl::startDeployment(bool forDebugging)
|
|
|
|
|
{
|
2010-04-13 12:16:47 +02:00
|
|
|
QTC_ASSERT(m_runConfig, return);
|
2010-01-06 18:20:43 +01:00
|
|
|
|
2010-04-14 15:47:07 +02:00
|
|
|
if (m_stoppedByUser) {
|
2010-04-13 14:34:22 +02:00
|
|
|
emit finished();
|
|
|
|
|
} else {
|
2010-04-13 10:46:54 +02:00
|
|
|
m_deployables.clear();
|
2010-04-26 11:43:25 +02:00
|
|
|
if (m_runConfig->currentlyNeedsDeployment(m_devConfig.server.host)) {
|
2010-04-15 12:47:02 +02:00
|
|
|
m_deployables.append(Deployable(packageFileName(),
|
2010-01-06 18:20:43 +01:00
|
|
|
QFileInfo(executableOnHost()).canonicalPath(),
|
|
|
|
|
&MaemoRunConfiguration::wasDeployed));
|
2010-04-16 12:52:00 +02:00
|
|
|
m_needsInstall = true;
|
|
|
|
|
} else {
|
|
|
|
|
m_needsInstall = false;
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
2010-03-05 16:06:47 +01:00
|
|
|
if (forDebugging
|
2010-04-26 11:43:25 +02:00
|
|
|
&& m_runConfig->debuggingHelpersNeedDeployment(m_devConfig.server.host)) {
|
2010-04-13 12:16:47 +02:00
|
|
|
const QFileInfo &info(m_runConfig->dumperLib());
|
2010-04-13 10:46:54 +02:00
|
|
|
m_deployables.append(Deployable(info.fileName(), info.canonicalPath(),
|
2010-01-06 18:20:43 +01:00
|
|
|
&MaemoRunConfiguration::debuggingHelpersDeployed));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deploy();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractMaemoRunControl::deploy()
|
|
|
|
|
{
|
2010-04-12 12:15:08 +02:00
|
|
|
Core::ICore::instance()->progressManager()
|
|
|
|
|
->addTask(m_progress.future(), tr("Deploying"),
|
|
|
|
|
QLatin1String("Maemo.Deploy"));
|
2010-04-13 10:46:54 +02:00
|
|
|
if (!m_deployables.isEmpty()) {
|
2010-04-26 11:43:25 +02:00
|
|
|
QList<Core::SftpTransferInfo> deploySpecs;
|
2010-01-06 18:20:43 +01:00
|
|
|
QStringList files;
|
2010-04-13 10:46:54 +02:00
|
|
|
foreach (const Deployable &deployable, m_deployables) {
|
2010-01-07 15:23:33 +01:00
|
|
|
const QString srcFilePath
|
|
|
|
|
= deployable.dir % QDir::separator() % deployable.fileName;
|
2010-01-07 16:42:01 +01:00
|
|
|
const QString tgtFilePath
|
|
|
|
|
= remoteDir() % QDir::separator() % deployable.fileName;
|
2010-01-07 15:23:33 +01:00
|
|
|
files << srcFilePath;
|
2010-04-26 11:43:25 +02:00
|
|
|
deploySpecs << Core::SftpTransferInfo(srcFilePath,
|
|
|
|
|
tgtFilePath.toUtf8(), Core::SftpTransferInfo::Upload);
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
2010-04-19 14:21:33 +02:00
|
|
|
emit appendMessage(this, tr("Files to deploy: %1.").arg(files.join(" ")), false);
|
2010-04-26 11:43:25 +02:00
|
|
|
m_sshDeployer.reset(new MaemoSshDeployer(m_devConfig.server, deploySpecs));
|
2010-04-13 10:46:54 +02:00
|
|
|
connect(m_sshDeployer.data(), SIGNAL(finished()),
|
2010-04-13 14:34:22 +02:00
|
|
|
this, SLOT(handleDeployThreadFinished()));
|
2010-04-13 10:46:54 +02:00
|
|
|
connect(m_sshDeployer.data(), SIGNAL(fileCopied(QString)),
|
2010-01-06 18:20:43 +01:00
|
|
|
this, SLOT(handleFileCopied()));
|
2010-04-13 10:46:54 +02:00
|
|
|
m_progress.setProgressRange(0, m_deployables.count());
|
2010-01-06 18:20:43 +01:00
|
|
|
m_progress.setProgressValue(0);
|
|
|
|
|
m_progress.reportStarted();
|
2010-04-13 10:46:54 +02:00
|
|
|
m_sshDeployer->start();
|
2010-01-06 18:20:43 +01:00
|
|
|
} else {
|
2010-04-12 12:15:08 +02:00
|
|
|
m_progress.reportFinished();
|
2010-04-13 14:34:22 +02:00
|
|
|
startExecution();
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractMaemoRunControl::handleFileCopied()
|
|
|
|
|
{
|
2010-04-13 10:46:54 +02:00
|
|
|
Deployable deployable = m_deployables.takeFirst();
|
2010-04-26 11:43:25 +02:00
|
|
|
(m_runConfig->*deployable.updateTimestamp)(m_devConfig.server.host);
|
2010-01-06 18:20:43 +01:00
|
|
|
m_progress.setProgressValue(m_progress.progressValue() + 1);
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-13 16:30:52 +02:00
|
|
|
bool AbstractMaemoRunControl::isDeploying() const
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
2010-04-13 16:30:52 +02:00
|
|
|
return m_sshDeployer && m_sshDeployer->isRunning();
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-15 12:47:02 +02:00
|
|
|
QString AbstractMaemoRunControl::packageFileName() const
|
|
|
|
|
{
|
|
|
|
|
return QFileInfo(packageFilePath()).fileName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AbstractMaemoRunControl::packageFilePath() const
|
|
|
|
|
{
|
|
|
|
|
return m_runConfig->packageStep()->packageFilePath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AbstractMaemoRunControl::executableFilePathOnTarget() const
|
|
|
|
|
{
|
2010-04-20 17:02:31 +02:00
|
|
|
return m_runConfig->packageStep()->remoteExecutableFilePath();
|
2010-04-15 12:47:02 +02:00
|
|
|
}
|
|
|
|
|
|
2010-04-13 16:30:52 +02:00
|
|
|
bool AbstractMaemoRunControl::isCleaning() const
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
2010-04-13 16:30:52 +02:00
|
|
|
return m_initialCleaner && m_initialCleaner->isRunning();
|
2010-04-12 17:43:46 +02:00
|
|
|
}
|
|
|
|
|
|
2010-04-13 14:34:22 +02:00
|
|
|
void AbstractMaemoRunControl::startExecution()
|
2010-04-12 17:43:46 +02:00
|
|
|
{
|
2010-04-26 11:43:25 +02:00
|
|
|
m_sshRunner.reset(new MaemoSshRunner(m_devConfig.server, remoteCall()));
|
2010-04-13 14:34:22 +02:00
|
|
|
connect(m_sshRunner.data(), SIGNAL(finished()),
|
|
|
|
|
this, SLOT(handleRunThreadFinished()));
|
|
|
|
|
connect(m_sshRunner.data(), SIGNAL(remoteOutput(QString)),
|
|
|
|
|
this, SLOT(handleRemoteOutput(QString)));
|
2010-04-19 14:21:33 +02:00
|
|
|
emit appendMessage(this, tr("Starting remote application."), false);
|
2010-04-13 10:46:54 +02:00
|
|
|
m_sshRunner->start();
|
2010-04-12 17:43:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AbstractMaemoRunControl::isRunning() const
|
|
|
|
|
{
|
2010-04-13 10:46:54 +02:00
|
|
|
return isDeploying() || (m_sshRunner && m_sshRunner->isRunning());
|
2010-04-12 17:43:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractMaemoRunControl::stopRunning(bool forDebugging)
|
|
|
|
|
{
|
2010-04-13 10:46:54 +02:00
|
|
|
if (m_sshRunner && m_sshRunner->isRunning()) {
|
|
|
|
|
m_sshRunner->stop();
|
2010-04-12 17:43:46 +02:00
|
|
|
QStringList apps(executableFileName());
|
|
|
|
|
if (forDebugging)
|
|
|
|
|
apps << QLatin1String("gdbserver");
|
2010-04-13 16:30:52 +02:00
|
|
|
killRemoteProcesses(apps, false);
|
2010-04-12 17:43:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-13 16:30:52 +02:00
|
|
|
void AbstractMaemoRunControl::killRemoteProcesses(const QStringList &apps,
|
|
|
|
|
bool initialCleanup)
|
2010-04-12 17:43:46 +02:00
|
|
|
{
|
|
|
|
|
QString niceKill;
|
|
|
|
|
QString brutalKill;
|
|
|
|
|
foreach (const QString &app, apps) {
|
|
|
|
|
niceKill += QString::fromLocal8Bit("pkill -x %1;").arg(app);
|
|
|
|
|
brutalKill += QString::fromLocal8Bit("pkill -x -9 %1;").arg(app);
|
|
|
|
|
}
|
2010-04-16 12:15:08 +02:00
|
|
|
QString remoteCall = niceKill + QLatin1String("sleep 1; ") + brutalKill;
|
|
|
|
|
remoteCall.remove(remoteCall.count() - 1, 1); // Get rid of trailing semicolon.
|
2010-04-13 16:30:52 +02:00
|
|
|
QScopedPointer<MaemoSshRunner> &runner
|
|
|
|
|
= initialCleanup ? m_initialCleaner : m_sshStopper;
|
2010-04-26 11:43:25 +02:00
|
|
|
runner.reset(new MaemoSshRunner(m_devConfig.server, remoteCall));
|
2010-04-13 16:30:52 +02:00
|
|
|
if (initialCleanup)
|
|
|
|
|
connect(runner.data(), SIGNAL(finished()),
|
|
|
|
|
this, SLOT(handleInitialCleanupFinished()));
|
|
|
|
|
runner->start();
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-13 14:34:22 +02:00
|
|
|
void AbstractMaemoRunControl::handleDeployThreadFinished()
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
2010-04-13 14:34:22 +02:00
|
|
|
bool cancel;
|
2010-04-13 12:03:32 +02:00
|
|
|
if (m_stoppedByUser) {
|
2010-04-19 14:21:33 +02:00
|
|
|
emit appendMessage(this, tr("Deployment canceled by user."), false);
|
2010-04-13 14:34:22 +02:00
|
|
|
cancel = true;
|
|
|
|
|
} else if (m_sshDeployer->hasError()) {
|
2010-04-13 10:46:54 +02:00
|
|
|
handleError(tr("Deployment failed: %1").arg(m_sshDeployer->error()));
|
2010-04-13 14:34:22 +02:00
|
|
|
cancel = true;
|
|
|
|
|
} else {
|
2010-04-19 14:21:33 +02:00
|
|
|
emit appendMessage(this, tr("Deployment finished."), false);
|
2010-04-13 14:34:22 +02:00
|
|
|
cancel = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cancel) {
|
2010-01-06 18:20:43 +01:00
|
|
|
m_progress.reportCanceled();
|
2010-04-13 14:34:22 +02:00
|
|
|
m_progress.reportFinished();
|
|
|
|
|
emit finished();
|
|
|
|
|
} else {
|
|
|
|
|
m_progress.reportFinished();
|
|
|
|
|
startExecution();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractMaemoRunControl::handleRunThreadFinished()
|
|
|
|
|
{
|
|
|
|
|
if (m_stoppedByUser) {
|
2010-04-19 14:21:33 +02:00
|
|
|
emit appendMessage(this,
|
|
|
|
|
tr("Remote execution canceled due to user request."),
|
|
|
|
|
false);
|
2010-04-13 14:34:22 +02:00
|
|
|
} else if (m_sshRunner->hasError()) {
|
2010-04-19 14:21:33 +02:00
|
|
|
emit appendMessage(this, tr("Error running remote process: %1")
|
|
|
|
|
.arg(m_sshRunner->error()),
|
|
|
|
|
true);
|
2010-04-13 14:34:22 +02:00
|
|
|
} else {
|
2010-04-19 14:21:33 +02:00
|
|
|
emit appendMessage(this, tr("Finished running remote process."),
|
|
|
|
|
false);
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
2010-04-13 14:34:22 +02:00
|
|
|
emit finished();
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString AbstractMaemoRunControl::executableOnHost() const
|
|
|
|
|
{
|
2010-04-13 12:16:47 +02:00
|
|
|
return m_runConfig->executable();
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString AbstractMaemoRunControl::executableFileName() const
|
|
|
|
|
{
|
|
|
|
|
return QFileInfo(executableOnHost()).fileName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString AbstractMaemoRunControl::remoteDir() const
|
|
|
|
|
{
|
2010-04-26 11:43:25 +02:00
|
|
|
return homeDirOnDevice(m_devConfig.server.uname);
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-15 12:47:02 +02:00
|
|
|
QString AbstractMaemoRunControl::remoteSudo() const
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
2010-04-15 12:47:02 +02:00
|
|
|
return QLatin1String("/usr/lib/mad-developer/devrootsh");
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-15 12:47:02 +02:00
|
|
|
QString AbstractMaemoRunControl::remoteInstallCommand() const
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
2010-04-15 12:47:02 +02:00
|
|
|
return QString::fromLocal8Bit("%1 dpkg -i %2").arg(remoteSudo())
|
|
|
|
|
.arg(packageFileName());
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString AbstractMaemoRunControl::targetCmdLinePrefix() const
|
|
|
|
|
{
|
2010-04-16 12:52:00 +02:00
|
|
|
const QString &installPrefix = m_needsInstall
|
|
|
|
|
? remoteInstallCommand() + QLatin1String(" && ")
|
|
|
|
|
: QString();
|
2010-05-03 14:47:40 +02:00
|
|
|
return QString::fromLocal8Bit("%1%2 chmod a+x %3 && source /etc/profile && ")
|
2010-04-16 12:52:00 +02:00
|
|
|
.arg(installPrefix).arg(remoteSudo()).arg(executableFilePathOnTarget());
|
2010-04-15 12:47:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AbstractMaemoRunControl::targetCmdLineSuffix() const
|
|
|
|
|
{
|
|
|
|
|
return m_runConfig->arguments().join(" ");
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-12 10:55:17 +02:00
|
|
|
void AbstractMaemoRunControl::handleError(const QString &errString)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::critical(0, tr("Remote Execution Failure"), errString);
|
2010-04-19 14:21:33 +02:00
|
|
|
emit appendMessage(this, errString, true);
|
2010-04-12 10:55:17 +02:00
|
|
|
}
|
|
|
|
|
|
2010-01-06 18:20:43 +01:00
|
|
|
|
|
|
|
|
MaemoRunControl::MaemoRunControl(RunConfiguration *runConfiguration)
|
2010-04-30 13:19:31 +02:00
|
|
|
: AbstractMaemoRunControl(runConfiguration, ProjectExplorer::Constants::RUNMODE)
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaemoRunControl::~MaemoRunControl()
|
|
|
|
|
{
|
|
|
|
|
stop();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-13 12:03:32 +02:00
|
|
|
void MaemoRunControl::startInternal()
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
|
|
|
|
startDeployment(false);
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-13 14:34:22 +02:00
|
|
|
QString MaemoRunControl::remoteCall() const
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
2010-04-15 12:47:02 +02:00
|
|
|
return QString::fromLocal8Bit("%1 %2 %3").arg(targetCmdLinePrefix())
|
|
|
|
|
.arg(executableFilePathOnTarget()).arg(targetCmdLineSuffix());
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-13 12:03:32 +02:00
|
|
|
void MaemoRunControl::stopInternal()
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
2010-04-13 14:34:22 +02:00
|
|
|
AbstractMaemoRunControl::stopRunning(false);
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-20 08:57:44 +02:00
|
|
|
void MaemoRunControl::handleRemoteOutput(const QString &output)
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
2010-04-20 08:57:44 +02:00
|
|
|
emit addToOutputWindowInline(this, output, false);
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MaemoDebugRunControl::MaemoDebugRunControl(RunConfiguration *runConfiguration)
|
2010-04-30 13:19:31 +02:00
|
|
|
: AbstractMaemoRunControl(runConfiguration, ProjectExplorer::Constants::DEBUGMODE)
|
2010-04-13 10:46:54 +02:00
|
|
|
, m_debuggerManager(ExtensionSystem::PluginManager::instance()
|
2010-04-13 10:39:24 +02:00
|
|
|
->getObject<Debugger::DebuggerManager>())
|
2010-04-13 10:46:54 +02:00
|
|
|
, m_startParams(new Debugger::DebuggerStartParameters)
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
2010-04-13 10:46:54 +02:00
|
|
|
QTC_ASSERT(m_debuggerManager != 0, return);
|
|
|
|
|
m_startParams->startMode = Debugger::StartRemote;
|
|
|
|
|
m_startParams->executable = executableOnHost();
|
|
|
|
|
m_startParams->remoteChannel
|
2010-04-26 11:43:25 +02:00
|
|
|
= m_devConfig.server.host % QLatin1Char(':') % gdbServerPort();
|
2010-04-13 10:46:54 +02:00
|
|
|
m_startParams->remoteArchitecture = QLatin1String("arm");
|
2010-04-13 12:16:47 +02:00
|
|
|
m_startParams->sysRoot = m_runConfig->sysRoot();
|
2010-04-13 10:46:54 +02:00
|
|
|
m_startParams->toolChainType = ToolChain::GCC_MAEMO;
|
2010-04-13 12:16:47 +02:00
|
|
|
m_startParams->debuggerCommand = m_runConfig->gdbCmd();
|
|
|
|
|
m_startParams->dumperLibrary = m_runConfig->dumperLib();
|
2010-04-13 10:46:54 +02:00
|
|
|
m_startParams->remoteDumperLib = QString::fromLocal8Bit("%1/%2")
|
2010-04-13 12:16:47 +02:00
|
|
|
.arg(remoteDir()).arg(QFileInfo(m_runConfig->dumperLib()).fileName());
|
2010-01-06 18:20:43 +01:00
|
|
|
|
2010-04-13 10:46:54 +02:00
|
|
|
connect(m_debuggerManager, SIGNAL(debuggingFinished()), this,
|
2010-01-06 18:20:43 +01:00
|
|
|
SLOT(debuggingFinished()), Qt::QueuedConnection);
|
2010-04-19 14:21:33 +02:00
|
|
|
connect(m_debuggerManager, SIGNAL(applicationOutputAvailable(QString, bool)),
|
2010-04-20 08:57:44 +02:00
|
|
|
this, SLOT(debuggerOutput(QString)), Qt::QueuedConnection);
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaemoDebugRunControl::~MaemoDebugRunControl()
|
|
|
|
|
{
|
2010-04-20 08:57:44 +02:00
|
|
|
disconnect(SIGNAL(addToOutputWindow(RunControl*,QString, bool)));
|
|
|
|
|
disconnect(SIGNAL(addToOutputWindowInline(RunControl*,QString, bool)));
|
2010-01-06 18:20:43 +01:00
|
|
|
stop();
|
|
|
|
|
debuggingFinished();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-13 12:03:32 +02:00
|
|
|
void MaemoDebugRunControl::startInternal()
|
2010-04-12 17:43:46 +02:00
|
|
|
{
|
2010-04-16 14:36:55 +02:00
|
|
|
m_debuggingStarted = false;
|
2010-04-13 14:34:22 +02:00
|
|
|
startDeployment(true);
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-13 14:34:22 +02:00
|
|
|
QString MaemoDebugRunControl::remoteCall() const
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
2010-04-13 14:34:22 +02:00
|
|
|
return QString::fromLocal8Bit("%1 gdbserver :%2 %3 %4")
|
|
|
|
|
.arg(targetCmdLinePrefix()).arg(gdbServerPort())
|
2010-04-15 12:47:02 +02:00
|
|
|
.arg(executableFilePathOnTarget()).arg(targetCmdLineSuffix());
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-20 08:57:44 +02:00
|
|
|
void MaemoDebugRunControl::handleRemoteOutput(const QString &output)
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
2010-04-16 14:36:55 +02:00
|
|
|
if (!m_debuggingStarted) {
|
|
|
|
|
m_debuggingStarted = true;
|
2010-04-13 14:34:22 +02:00
|
|
|
startDebugging();
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
2010-04-20 08:57:44 +02:00
|
|
|
emit addToOutputWindowInline(this, output, false);
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoDebugRunControl::startDebugging()
|
|
|
|
|
{
|
2010-04-13 10:46:54 +02:00
|
|
|
m_debuggerManager->startNewDebugger(m_startParams);
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-13 12:03:32 +02:00
|
|
|
void MaemoDebugRunControl::stopInternal()
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
2010-04-13 14:34:22 +02:00
|
|
|
m_debuggerManager->exitDebugger();
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MaemoDebugRunControl::isRunning() const
|
|
|
|
|
{
|
2010-04-12 17:43:46 +02:00
|
|
|
return AbstractMaemoRunControl::isRunning()
|
2010-04-13 10:46:54 +02:00
|
|
|
|| m_debuggerManager->state() != Debugger::DebuggerNotReady;
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoDebugRunControl::debuggingFinished()
|
|
|
|
|
{
|
2010-04-12 17:43:46 +02:00
|
|
|
AbstractMaemoRunControl::stopRunning(true);
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-20 08:57:44 +02:00
|
|
|
void MaemoDebugRunControl::debuggerOutput(const QString &output)
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
2010-04-20 08:57:44 +02:00
|
|
|
emit appendMessage(this, QLatin1String("[gdb says:] ") + output, true);
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-03 15:20:12 +01:00
|
|
|
QString MaemoDebugRunControl::gdbServerPort() const
|
|
|
|
|
{
|
2010-04-13 12:16:47 +02:00
|
|
|
return m_devConfig.type == MaemoDeviceConfig::Physical
|
|
|
|
|
? QString::number(m_devConfig.gdbServerPort)
|
|
|
|
|
: m_runConfig->simulatorGdbServerPort();
|
2010-02-03 15:20:12 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-06 18:20:43 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Qt4ProjectManager
|