Commit 08bc6c00 authored by ck's avatar ck

Maemo: Get rid of MaemoDebugRunControl.

Use Debugger::DebuggerRunControl directly instead of wrapping it
into another RunControl.

Reviewed-by: hjk
parent db99f828
......@@ -924,7 +924,8 @@ public slots:
QVariant configValue(const QString &name) const
{ return settings()->value(name); }
DebuggerRunControl *createDebugger(const DebuggerStartParameters &sp);
DebuggerRunControl *createDebugger(const DebuggerStartParameters &sp,
ProjectExplorer::RunConfiguration *rc = 0);
void startDebugger(ProjectExplorer::RunControl *runControl);
void displayDebugger(ProjectExplorer::RunControl *runControl);
......@@ -1921,9 +1922,10 @@ void DebuggerPluginPrivate::showToolTip(ITextEditor *editor, const QPoint &point
}
DebuggerRunControl *
DebuggerPluginPrivate::createDebugger(const DebuggerStartParameters &sp)
DebuggerPluginPrivate::createDebugger(const DebuggerStartParameters &sp,
ProjectExplorer::RunConfiguration *rc)
{
return m_debuggerRunControlFactory->create(sp);
return m_debuggerRunControlFactory->create(sp, rc);
}
void DebuggerPluginPrivate::displayDebugger(ProjectExplorer::RunControl *rc)
......@@ -2643,9 +2645,10 @@ QWidget *DebuggerPlugin::mainWindow() const
}
DebuggerRunControl *
DebuggerPlugin::createDebugger(const DebuggerStartParameters &sp)
DebuggerPlugin::createDebugger(const DebuggerStartParameters &sp,
ProjectExplorer::RunConfiguration *rc)
{
return instance()->d->createDebugger(sp);
return instance()->d->createDebugger(sp, rc);
}
void DebuggerPlugin::startDebugger(ProjectExplorer::RunControl *runControl)
......
......@@ -44,6 +44,7 @@ class Snapshot;
}
namespace ProjectExplorer {
class RunConfiguration;
class RunControl;
}
......@@ -82,7 +83,8 @@ public:
void readSettings();
void writeSettings() const;
static DebuggerRunControl *createDebugger(const DebuggerStartParameters &sp);
static DebuggerRunControl *createDebugger(const DebuggerStartParameters &sp,
ProjectExplorer::RunConfiguration *rc = 0);
static void startDebugger(ProjectExplorer::RunControl *runControl);
static void displayDebugger(ProjectExplorer::RunControl *runControl);
......
......@@ -179,7 +179,6 @@ static QByteArray parsePlainConsoleStream(const GdbResponse &response)
GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters)
: DebuggerEngine(startParameters)
{
m_gdbAdapter = 0;
m_progress = 0;
m_commandTimer = new QTimer(this);
......@@ -189,6 +188,7 @@ GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters)
// Needs no resetting in initializeVariables()
m_busy = false;
initializeVariables();
m_gdbAdapter = createAdapter();
connect(theDebuggerAction(AutoDerefPointers), SIGNAL(valueChanged(QVariant)),
this, SLOT(setAutoDerefPointers(QVariant)));
......@@ -1754,7 +1754,6 @@ void GdbEngine::setupEngine()
//qDebug() << "GDB START DEBUGGER";
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
QTC_ASSERT(m_debuggingHelperState == DebuggingHelperUninitialized, /**/);
QTC_ASSERT(m_gdbAdapter == 0, /**/);
m_progress = new QFutureInterface<void>();
m_progress->setProgressRange(0, 100);
......@@ -1763,7 +1762,6 @@ void GdbEngine::setupEngine()
fp->setKeepOnFinish(false);
m_progress->reportStarted();
m_gdbAdapter = createAdapter();
//qDebug() << "CREATED ADAPTER: " << m_gdbAdapter;
if (m_gdbAdapter->dumperHandling() != AbstractGdbAdapter::DumperNotAvailable) {
......
......@@ -83,13 +83,14 @@ enum DebuggingHelperState
};
class GdbEngine : public DebuggerEngine
class DEBUGGER_EXPORT GdbEngine : public DebuggerEngine
{
Q_OBJECT
public:
explicit GdbEngine(const DebuggerStartParameters &startParameters);
~GdbEngine();
AbstractGdbAdapter *gdbAdapter() const { return m_gdbAdapter; }
private:
friend class AbstractGdbAdapter;
......
......@@ -62,6 +62,8 @@ RemoteGdbServerAdapter::RemoteGdbServerAdapter(GdbEngine *engine, int toolChainT
this, SLOT(readUploadStandardOutput()));
connect(&m_uploadProc, SIGNAL(readyReadStandardError()),
this, SLOT(readUploadStandardError()));
connect(&m_uploadProc, SIGNAL(finished(int)), this,
SLOT(uploadProcFinished()));
}
AbstractGdbAdapter::DumperHandling RemoteGdbServerAdapter::dumperHandling() const
......@@ -86,22 +88,13 @@ void RemoteGdbServerAdapter::startAdapter()
{
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
showMessage(_("TRYING TO START ADAPTER"));
// FIXME: make asynchroneous
// Start the remote server
if (startParameters().serverStartScript.isEmpty()) {
showMessage(_("No server start script given. "
"Assuming server runs already."), StatusBar);
showMessage(_("No server start script given. "), StatusBar);
emit requestSetup();
} else {
m_uploadProc.start(_("/bin/sh ") + startParameters().serverStartScript);
m_uploadProc.waitForStarted();
}
if (!m_engine->startGdb(QStringList(), startParameters().debuggerCommand))
// FIXME: cleanup missing
return;
m_engine->handleAdapterStarted();
}
void RemoteGdbServerAdapter::uploadProcError(QProcess::ProcessError error)
......@@ -154,6 +147,15 @@ void RemoteGdbServerAdapter::readUploadStandardError()
showMessage(msg, AppError);
}
void RemoteGdbServerAdapter::uploadProcFinished()
{
if (m_uploadProc.exitStatus() == QProcess::NormalExit
&& m_uploadProc.exitCode() == 0)
handleSetupDone();
else
handleSetupFailed(m_uploadProc.errorString());
}
void RemoteGdbServerAdapter::setupInferior()
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
......@@ -245,5 +247,20 @@ void RemoteGdbServerAdapter::shutdownAdapter()
m_engine->notifyAdapterShutdownOk();
}
void RemoteGdbServerAdapter::handleSetupDone()
{
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
if (m_engine->startGdb(QStringList(), startParameters().debuggerCommand))
m_engine->handleAdapterStarted();
}
void RemoteGdbServerAdapter::handleSetupFailed(const QString &reason)
{
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
m_engine->handleAdapterStartFailed(reason);
}
} // namespace Internal
} // namespace Debugger
......@@ -43,12 +43,14 @@ namespace Internal {
//
///////////////////////////////////////////////////////////////////////
class RemoteGdbServerAdapter : public AbstractGdbAdapter
class DEBUGGER_EXPORT RemoteGdbServerAdapter : public AbstractGdbAdapter
{
Q_OBJECT
public:
RemoteGdbServerAdapter(GdbEngine *engine, int toolChainType, QObject *parent = 0);
void handleSetupDone();
void handleSetupFailed(const QString &reason);
private:
DumperHandling dumperHandling() const;
......@@ -62,9 +64,14 @@ private:
AbstractGdbProcess *gdbProc() { return &m_gdbProc; }
signals:
void requestSetup();
private:
Q_SLOT void readUploadStandardOutput();
Q_SLOT void readUploadStandardError();
Q_SLOT void uploadProcError(QProcess::ProcessError error);
Q_SLOT void uploadProcFinished();
void handleSetTargetAsync(const GdbResponse &response);
void handleFileExecAndSymbols(const GdbResponse &response);
......
......@@ -48,13 +48,7 @@ void RemotePlainGdbAdapter::startAdapter()
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
showMessage(QLatin1String("TRYING TO START ADAPTER"));
if (!startParameters().workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(startParameters().workingDirectory);
if (!startParameters().environment.isEmpty())
m_gdbProc.setEnvironment(startParameters().environment);
if (m_engine->startGdb(QStringList(), m_engine->startParameters().debuggerCommand))
m_engine->handleAdapterStarted();
emit requestSetup();
}
void RemotePlainGdbAdapter::interruptInferior()
......@@ -97,5 +91,25 @@ void RemotePlainGdbAdapter::shutdownAdapter()
m_engine->notifyAdapterShutdownOk();
}
void RemotePlainGdbAdapter::handleSetupDone()
{
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
if (!startParameters().workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(startParameters().workingDirectory);
if (!startParameters().environment.isEmpty())
m_gdbProc.setEnvironment(startParameters().environment);
if (m_engine->startGdb(QStringList(), m_engine->startParameters().debuggerCommand))
m_engine->handleAdapterStarted();
}
void RemotePlainGdbAdapter::handleSetupFailed(const QString &reason)
{
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
m_engine->handleAdapterStartFailed(reason);
}
} // namespace Internal
} // namespace Debugger
......@@ -36,13 +36,18 @@
namespace Debugger {
namespace Internal {
class RemotePlainGdbAdapter : public AbstractPlainGdbAdapter
class DEBUGGER_EXPORT RemotePlainGdbAdapter : public AbstractPlainGdbAdapter
{
Q_OBJECT
public:
friend class RemoteGdbProcess;
RemotePlainGdbAdapter(GdbEngine *engine, QObject *parent = 0);
void handleSetupDone();
void handleSetupFailed(const QString &reason);
signals:
void requestSetup();
private:
void startAdapter();
......
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** 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$
**
****************************************************************************/
#ifndef MAEMODEBUGSUPPORT_H
#define MAEMODEBUGSUPPORT_H
#include "maemodeviceconfigurations.h"
#include <coreplugin/ssh/sftpdefs.h>
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
#define USE_GDBSERVER
namespace Core { class SftpChannel; }
namespace Debugger {
class DebuggerRunControl;
namespace Internal {
class RemoteGdbServerAdapter;
class RemotePlainGdbAdapter;
}
}
namespace ProjectExplorer { class RunControl; }
namespace Qt4ProjectManager {
namespace Internal {
class MaemoRunConfiguration;
class MaemoSshRunner;
class MaemoDebugSupport : public QObject
{
Q_OBJECT
public:
static ProjectExplorer::RunControl *createDebugRunControl(MaemoRunConfiguration *runConfig);
MaemoDebugSupport(MaemoRunConfiguration *runConfig,
Debugger::DebuggerRunControl *runControl);
~MaemoDebugSupport();
static QString gdbServerPort(const MaemoRunConfiguration *rc,
const MaemoDeviceConfig &devConf);
static QString uploadDir(const MaemoDeviceConfig &devConf);
private slots:
void handleAdapterSetupRequested();
void handleSshError(const QString &error);
void startExecution();
void handleSftpChannelInitialized();
void handleSftpChannelInitializationFailed(const QString &error);
void handleSftpJobFinished(Core::SftpJobId job, const QString &error);
void handleRemoteProcessStarted();
void handleDebuggingFinished();
void handleRemoteOutput(const QByteArray &output);
void handleRemoteErrorOutput(const QByteArray &output);
private:
void stopSsh();
void handleAdapterSetupFailed(const QString &error);
void handleAdapterSetupDone();
void startDebugging();
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;
QSharedPointer<Core::SftpChannel> m_uploader;
Core::SftpJobId m_uploadJob;
bool m_adapterStarted;
bool m_stopped;
};
} // namespace Internal
} // namespace Qt4ProjectManager
#endif // MAEMODEBUGSUPPORT_H
......@@ -46,5 +46,11 @@ QString MaemoGlobal::remoteSudo()
return QLatin1String("/usr/lib/mad-developer/devrootsh");
}
QString MaemoGlobal::remoteCommandPrefix(const QString &commandFilePath)
{
return QString::fromLocal8Bit("%1 chmod a+x %2 && source /etc/profile && DISPLAY=:0.0 ")
.arg(remoteSudo()).arg(commandFilePath);
}
} // namespace Internal
} // namespace Qt4ProjectManager
......@@ -46,6 +46,7 @@ class MaemoGlobal
public:
static QString homeDirOnDevice(const QString &uname);
static QString remoteSudo();
static QString remoteCommandPrefix(const QString &commandFilePath);
template<class T> static T *buildStep(const ProjectExplorer::BuildConfiguration *bc)
{
......
......@@ -37,105 +37,45 @@
#include "maemodeviceconfigurations.h"
#include <coreplugin/ssh/sftpdefs.h>
#include <projectexplorer/runconfiguration.h>
#include <QtCore/QString>
namespace Core {
class SftpChannel;
class SshConnection;
class SshRemoteProcess;
}
namespace Debugger {
class DebuggerRunControl;
class DebuggerStartParameters;
} // namespace Debugger
namespace Qt4ProjectManager {
namespace Internal {
class MaemoRunConfiguration;
class MaemoSshRunner;
class AbstractMaemoRunControl : public ProjectExplorer::RunControl
class MaemoRunControl : public ProjectExplorer::RunControl
{
Q_OBJECT
public:
explicit AbstractMaemoRunControl(ProjectExplorer::RunConfiguration *runConfig, QString mode);
virtual ~AbstractMaemoRunControl();
protected:
virtual void start();
virtual void stop();
void setFinished();
void handleError(const QString &errString);
const QString targetCmdLinePrefix() const;
QString arguments() const;
explicit MaemoRunControl(ProjectExplorer::RunConfiguration *runConfig);
virtual ~MaemoRunControl();
private slots:
virtual void startExecution();
void startExecution();
void handleSshError(const QString &error);
virtual void handleRemoteProcessStarted() {}
void handleRemoteProcessStarted() {}
void handleRemoteProcessFinished(int exitCode);
void handleRemoteOutput(const QByteArray &output);
void handleRemoteErrorOutput(const QByteArray &output);
protected:
private:
virtual void start();
virtual void stop();
virtual bool isRunning() const;
void setFinished();
void handleError(const QString &errString);
MaemoRunConfiguration *m_runConfig; // TODO this pointer can be invalid
const MaemoDeviceConfig m_devConfig;
MaemoSshRunner * const m_runner;
bool m_stopped;
private:
virtual bool isRunning() const;
virtual void stopInternal()=0;
bool m_running;
};
class MaemoRunControl : public AbstractMaemoRunControl
{
Q_OBJECT
public:
explicit MaemoRunControl(ProjectExplorer::RunConfiguration *runConfiguration);
~MaemoRunControl();
private:
virtual void stopInternal();
};
class MaemoDebugRunControl : public AbstractMaemoRunControl
{
Q_OBJECT
public:
explicit MaemoDebugRunControl(ProjectExplorer::RunConfiguration *runConfiguration);
~MaemoDebugRunControl();
private slots:
virtual void handleRemoteProcessStarted();
void debuggerOutput(const QString &output);
void debuggingFinished();
void handleSftpChannelInitialized();
void handleSftpChannelInitializationFailed(const QString &error);
void handleSftpJobFinished(Core::SftpJobId job, const QString &error);
private:
virtual void stopInternal();
virtual void startExecution();
QString uploadDir() const;
QString gdbServerPort() const;
void startDebugging();
bool isDeploying() const;
Debugger::DebuggerRunControl *m_debuggerRunControl;
QSharedPointer<Debugger::DebuggerStartParameters> m_startParams;
QSharedPointer<Core::SftpChannel> m_uploader;
Core::SftpJobId m_uploadJob;
};
} // namespace Internal
} // namespace Qt4ProjectManager
......
......@@ -35,6 +35,7 @@
#include "maemorunfactories.h"
#include "maemoconstants.h"
#include "maemodebugsupport.h"
#include "maemorunconfiguration.h"
#include "maemoruncontrol.h"
......@@ -171,7 +172,7 @@ RunControl* MaemoRunControlFactory::create(RunConfiguration *runConfig,
|| mode == ProjectExplorer::Constants::DEBUGMODE);
if (mode == ProjectExplorer::Constants::RUNMODE)
return new MaemoRunControl(rc);
return new MaemoDebugRunControl(rc);
return MaemoDebugSupport::createDebugRunControl(rc);
}
QString MaemoRunControlFactory::displayName() const
......
......@@ -24,7 +24,8 @@ HEADERS += \
$$PWD/maemodeploystepwidget.h \
$$PWD/maemodeploystepfactory.h \
$$PWD/maemoglobal.h \
$$PWD/maemosshrunner.h
$$PWD/maemosshrunner.h \
$$PWD/maemodebugsupport.h
SOURCES += \
$$PWD/maemoconfigtestdialog.cpp \
......@@ -50,7 +51,8 @@ SOURCES += \
$$PWD/maemodeploystepwidget.cpp \
$$PWD/maemodeploystepfactory.cpp \
$$PWD/maemoglobal.cpp \
$$PWD/maemosshrunner.cpp
$$PWD/maemosshrunner.cpp \
$$PWD/maemodebugsupport.cpp
FORMS += \
$$PWD/maemoconfigtestdialog.ui \
......
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