S60: Dis-embed the embedded run S60 debugger run control.

As it created 2 output panes that could be closed indepently
of each other.
This commit is contained in:
Friedemann Kleint
2010-08-20 15:23:42 +02:00
parent b230898b66
commit 5b4f826552
4 changed files with 77 additions and 101 deletions

View File

@@ -229,6 +229,12 @@ DebuggerRunControl::~DebuggerRunControl()
delete engine; delete engine;
} }
const DebuggerStartParameters &DebuggerRunControl::startParameters() const
{
QTC_ASSERT(m_engine, return *(new DebuggerStartParameters()));
return m_engine->startParameters();
}
static DebuggerEngineType engineForToolChain(int toolChainType) static DebuggerEngineType engineForToolChain(int toolChainType)
{ {
switch (toolChainType) { switch (toolChainType) {

View File

@@ -87,7 +87,7 @@ class DEBUGGER_EXPORT DebuggerRunControl
public: public:
typedef ProjectExplorer::RunConfiguration RunConfiguration; typedef ProjectExplorer::RunConfiguration RunConfiguration;
DebuggerRunControl(RunConfiguration *runConfiguration, explicit DebuggerRunControl(RunConfiguration *runConfiguration,
DebuggerEngineType enabledEngines, const DebuggerStartParameters &sp); DebuggerEngineType enabledEngines, const DebuggerStartParameters &sp);
~DebuggerRunControl(); ~DebuggerRunControl();
@@ -122,6 +122,9 @@ private slots:
void handleStarted(); void handleStarted();
void handleFinished(); void handleFinished();
protected:
const DebuggerStartParameters &startParameters() const;
private: private:
DebuggerEngineType engineForExecutable(const QString &executable); DebuggerEngineType engineForExecutable(const QString &executable);
DebuggerEngineType engineForMode(DebuggerStartMode mode); DebuggerEngineType engineForMode(DebuggerStartMode mode);

View File

@@ -56,7 +56,6 @@
#include <debugger/debuggerengine.h> #include <debugger/debuggerengine.h>
#include <debugger/debuggerplugin.h> #include <debugger/debuggerplugin.h>
#include <debugger/debuggerrunner.h>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
#include <QtGui/QMainWindow> #include <QtGui/QMainWindow>
@@ -576,58 +575,66 @@ void S60DeviceRunControl::applicationRunFailedNotice(const QString &errorMessage
// ======== S60DeviceDebugRunControl // ======== S60DeviceDebugRunControl
S60DeviceDebugRunControl::S60DeviceDebugRunControl(S60DeviceRunConfiguration *rc, QString mode) : static inline QString localExecutable(const S60DeviceRunConfiguration *rc)
RunControl(rc, mode),
m_startParams(new Debugger::DebuggerStartParameters),
m_debuggerRunControl(0),
m_debugProgress(0)
{ {
QTC_ASSERT(rc, return); if (const S60DeployConfiguration *activeDeployConf = qobject_cast<S60DeployConfiguration *>(rc->qt4Target()->activeDeployConfiguration()))
return activeDeployConf->localExecutableFileName();
return QString();
}
S60DeployConfiguration *activeDeployConf = qobject_cast<S60DeployConfiguration *>(rc->qt4Target()->activeDeployConfiguration()); // Create start parameters from run configuration
Debugger::DebuggerStartParameters S60DeviceDebugRunControl::s60DebuggerStartParams(const S60DeviceRunConfiguration *rc)
{
Debugger::DebuggerStartParameters sp;
QTC_ASSERT(rc, return sp);
const S60DeployConfiguration *activeDeployConf = qobject_cast<S60DeployConfiguration *>(rc->qt4Target()->activeDeployConfiguration());
const QString debugFileName = QString::fromLatin1("%1:\\sys\\bin\\%2.exe") const QString debugFileName = QString::fromLatin1("%1:\\sys\\bin\\%2.exe")
.arg(activeDeployConf->installationDrive()).arg(activeDeployConf->targetName()); .arg(activeDeployConf->installationDrive()).arg(activeDeployConf->targetName());
m_startParams->remoteChannel = activeDeployConf->serialPortName(); sp.remoteChannel = activeDeployConf->serialPortName();
m_startParams->processArgs = rc->commandLineArguments(); sp.processArgs = rc->commandLineArguments();
m_startParams->startMode = Debugger::StartInternal; sp.startMode = Debugger::StartInternal;
m_startParams->toolChainType = rc->toolChainType(); sp.toolChainType = rc->toolChainType();
m_startParams->executable = debugFileName; sp.executable = debugFileName;
m_startParams->executableUid = activeDeployConf->executableUid(); sp.executableUid = activeDeployConf->executableUid();
QTC_ASSERT(m_startParams->executableUid, return); QTC_ASSERT(sp.executableUid, return sp);
// Prefer the '*.sym' file over the '.exe', which should exist at the same // Prefer the '*.sym' file over the '.exe', which should exist at the same
// location in debug builds // location in debug builds
const QString localExecutableFileName = localExecutable(rc);
if (!QFileInfo(m_startParams->symbolFileName).isFile()) { const int lastDotPos = localExecutableFileName.lastIndexOf(QLatin1Char('.'));
m_startParams->symbolFileName.clear();
emit appendMessage(this, tr("Warning: Cannot locate the symbol file belonging to %1.").arg(m_localExecutableFileName), true);
}
m_localExecutableFileName = activeDeployConf->localExecutableFileName();
const int lastDotPos = m_localExecutableFileName.lastIndexOf(QLatin1Char('.'));
if (lastDotPos != -1) { if (lastDotPos != -1) {
m_startParams->symbolFileName = m_localExecutableFileName.mid(0, lastDotPos) + QLatin1String(".sym"); const QString symbolFileName = localExecutableFileName.mid(0, lastDotPos) + QLatin1String(".sym");
if (QFileInfo(symbolFileName).isFile())
sp.symbolFileName = symbolFileName;
} }
return sp;
}
S60DeviceDebugRunControl::S60DeviceDebugRunControl(S60DeviceRunConfiguration *rc,
const QString &) :
Debugger::DebuggerRunControl(rc, Debugger::GdbEngineType,
S60DeviceDebugRunControl::s60DebuggerStartParams(rc))
{
if (startParameters().symbolFileName.isEmpty()) {
const QString msg = tr("Warning: Cannot locate the symbol file belonging to %1.").
arg(localExecutable(rc));
emit appendMessage(this, msg, true);
}
connect(this, SIGNAL(finished()), this, SLOT(slotFinished()));
} }
void S60DeviceDebugRunControl::start() void S60DeviceDebugRunControl::start()
{ {
m_debugProgress = new QFutureInterface<void>;
Core::ICore::instance()->progressManager()->addTask(m_debugProgress->future(),
tr("Debugging"),
QLatin1String("Symbian.Debug"));
m_debugProgress->setProgressRange(0, PROGRESS_MAX);
m_debugProgress->setProgressValue(0);
m_debugProgress->reportStarted();
emit started();
QString errorMessage; QString errorMessage;
QString settingsCategory; QString settingsCategory;
QString settingsPage; QString settingsPage;
if (!checkConfiguration(&errorMessage, &settingsCategory, &settingsPage)) { if (!Debugger::DebuggerRunControl::checkDebugConfiguration(startParameters().toolChainType,
&errorMessage, &settingsCategory, &settingsPage)) {
m_debugProgress->reportCanceled(); m_debugProgress->reportCanceled();
appendMessage(this, errorMessage, true); appendMessage(this, errorMessage, true);
emit finished(); emit finished();
@@ -636,72 +643,36 @@ void S60DeviceDebugRunControl::start()
settingsCategory, settingsPage); settingsCategory, settingsPage);
return; return;
} }
m_debugProgress.reset(new QFutureInterface<void>);
Core::ICore::instance()->progressManager()->addTask(m_debugProgress->future(),
tr("Debugging"),
QLatin1String("Symbian.Debug"));
m_debugProgress->setProgressRange(0, PROGRESS_MAX);
m_debugProgress->setProgressValue(0);
m_debugProgress->reportStarted();
using namespace Debugger;
emit appendMessage(this, tr("Launching debugger..."), false); emit appendMessage(this, tr("Launching debugger..."), false);
QTC_ASSERT(m_debuggerRunControl == 0, /* Should happen only once. */); Debugger::DebuggerRunControl::start();
m_debuggerRunControl = DebuggerPlugin::createDebugger(*m_startParams.data());
connect(m_debuggerRunControl,
SIGNAL(finished()),
SLOT(debuggingFinished()),
Qt::QueuedConnection);
connect(m_debuggerRunControl,
SIGNAL(addToOutputWindowInline(ProjectExplorer::RunControl*,QString,bool)),
SIGNAL(addToOutputWindowInline(ProjectExplorer::RunControl*,QString,bool)),
Qt::QueuedConnection);
DebuggerPlugin::startDebugger(m_debuggerRunControl);
} }
S60DeviceDebugRunControl::~S60DeviceDebugRunControl() S60DeviceDebugRunControl::~S60DeviceDebugRunControl()
{ {
delete m_debugProgress;
// FIXME: Needed? m_debuggerRunControl->deleteLater();
} }
bool S60DeviceDebugRunControl::aboutToStop() const
{
return m_debuggerRunControl ? m_debuggerRunControl->aboutToStop() : true;
}
RunControl::StopResult S60DeviceDebugRunControl::stop() RunControl::StopResult S60DeviceDebugRunControl::stop()
{ {
QTC_ASSERT(m_debuggerRunControl, return StoppedSynchronously) if (!m_debugProgress.isNull()) {
if (m_debugProgress)
m_debugProgress->reportCanceled(); m_debugProgress->reportCanceled();
delete m_debugProgress; m_debugProgress.reset();
m_debugProgress = 0; }
return m_debuggerRunControl->stop(); return Debugger::DebuggerRunControl::stop();
} }
bool S60DeviceDebugRunControl::isRunning() const void S60DeviceDebugRunControl::slotFinished()
{ {
return m_debuggerRunControl if (!m_debugProgress.isNull()) {
&& m_debuggerRunControl->isRunning();
}
void S60DeviceDebugRunControl::debuggingFinished()
{
emit appendMessage(this, tr("Debugging finished."), false);
emit finished();
if (m_debugProgress) {
m_debugProgress->setProgressValue(PROGRESS_MAX); m_debugProgress->setProgressValue(PROGRESS_MAX);
m_debugProgress->reportFinished(); m_debugProgress->reportFinished();
m_debugProgress.reset();
} }
delete m_debugProgress;
m_debugProgress = 0;
}
bool S60DeviceDebugRunControl::checkConfiguration(QString *errorMessage,
QString *settingsCategory,
QString *settingsPage) const
{
return Debugger::DebuggerRunControl::checkDebugConfiguration(
m_startParams->toolChainType,
errorMessage,
settingsCategory,
settingsPage);
} }

View File

@@ -32,11 +32,14 @@
#include "launcher.h" #include "launcher.h"
#include <debugger/debuggerrunner.h>
#include <projectexplorer/runconfiguration.h> #include <projectexplorer/runconfiguration.h>
#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
#include <QtCore/QProcess> #include <QtCore/QProcess>
#include <QtCore/QFutureInterface> #include <QtCore/QFutureInterface>
#include <QtCore/QSharedPointer>
#include <QtCore/QScopedPointer>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QMessageBox; class QMessageBox;
@@ -181,31 +184,24 @@ private:
// S60DeviceDebugRunControl starts debugging // S60DeviceDebugRunControl starts debugging
class S60DeviceDebugRunControl : public ProjectExplorer::RunControl class S60DeviceDebugRunControl : public Debugger::DebuggerRunControl
{ {
Q_DISABLE_COPY(S60DeviceDebugRunControl) Q_DISABLE_COPY(S60DeviceDebugRunControl)
Q_OBJECT Q_OBJECT
public: public:
explicit S60DeviceDebugRunControl(S60DeviceRunConfiguration *runConfiguration, QString mode); explicit S60DeviceDebugRunControl(S60DeviceRunConfiguration *runConfiguration,
const QString &mode);
virtual ~S60DeviceDebugRunControl(); virtual ~S60DeviceDebugRunControl();
virtual void start(); virtual void start();
virtual bool aboutToStop() const;
virtual StopResult stop(); virtual StopResult stop();
virtual bool isRunning() const;
protected:
virtual bool checkConfiguration(QString *errorMessage,
QString *settingsCategory,
QString *settingsPage) const;
private slots: private slots:
void debuggingFinished(); void slotFinished();
protected: private:
QSharedPointer<Debugger::DebuggerStartParameters> m_startParams; static Debugger::DebuggerStartParameters s60DebuggerStartParams(const S60DeviceRunConfiguration *rc);
Debugger::DebuggerRunControl *m_debuggerRunControl;
QFutureInterface<void> *m_debugProgress; QScopedPointer<QFutureInterface<void> > m_debugProgress;
QString m_localExecutableFileName;
}; };
} // namespace Internal } // namespace Internal