Commit 7313f3d6 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen

don't instanciate all adaptors at once

parent 94cb4644
......@@ -51,6 +51,7 @@ public:
AbstractGdbAdapter(GdbEngine *engine, QObject *parent = 0)
: QObject(parent), m_engine(engine)
{}
virtual ~AbstractGdbAdapter() { disconnect(); }
virtual QByteArray readAllStandardError() = 0;
virtual QByteArray readAllStandardOutput() = 0;
......
......@@ -179,14 +179,9 @@ GdbEngine::GdbEngine(DebuggerManager *manager) :
m_dumperInjectionLoad(false)
#endif
{
m_trkOptions = QSharedPointer<TrkOptions>(new TrkOptions);
m_trkOptions->fromSettings(Core::ICore::instance()->settings());
m_gdbAdapter = 0;
QSharedPointer<TrkOptions> options(new TrkOptions);
options->fromSettings(Core::ICore::instance()->settings());
m_plainAdapter = new PlainGdbAdapter(this);
m_trkAdapter = new TrkGdbAdapter(this, options);
m_remoteAdapter = new RemoteGdbAdapter(this);
m_coreAdapter = new CoreGdbAdapter(this);
m_attachAdapter = new AttachGdbAdapter(this);
// Output
connect(&m_outputCollector, SIGNAL(byteDelivery(QByteArray)),
......@@ -237,16 +232,7 @@ QMainWindow *GdbEngine::mainWindow() const
GdbEngine::~GdbEngine()
{
// prevent sending error messages afterwards
if (m_gdbAdapter) {
m_gdbAdapter->disconnect(this);
//delete m_gdbAdapter;
m_gdbAdapter = 0;
}
delete m_plainAdapter;
delete m_trkAdapter;
delete m_remoteAdapter;
delete m_coreAdapter;
delete m_attachAdapter;
delete m_gdbAdapter;
}
void GdbEngine::connectAdapter()
......@@ -282,11 +268,6 @@ void GdbEngine::connectAdapter()
this, SLOT(handleAdapterCrashed(QString)));
}
void GdbEngine::disconnectAdapter()
{
disconnect(m_gdbAdapter, 0, this, 0);
}
void GdbEngine::initializeVariables()
{
m_debuggingHelperState = DebuggingHelperUninitialized;
......@@ -1439,31 +1420,30 @@ int GdbEngine::currentFrame() const
return manager()->stackHandler()->currentIndex();
}
AbstractGdbAdapter *GdbEngine::determineAdapter(const DebuggerStartParametersPtr &sp) const
AbstractGdbAdapter *GdbEngine::createAdapter(const DebuggerStartParametersPtr &sp)
{
switch (sp->toolChainType) {
case ProjectExplorer::ToolChain::WINSCW: // S60
case ProjectExplorer::ToolChain::GCCE:
case ProjectExplorer::ToolChain::RVCT_ARMV5:
case ProjectExplorer::ToolChain::RVCT_ARMV6:
return m_trkAdapter;
return new TrkGdbAdapter(this, m_trkOptions);
default:
break;
}
// @todo: remove testing hack
if (sp->processArgs.size() == 3 && sp->processArgs.at(0) == _("@sym@"))
return m_trkAdapter;
return new TrkGdbAdapter(this, m_trkOptions);
switch (sp->startMode) {
case AttachCore:
return m_coreAdapter;
return new CoreGdbAdapter(this);
case StartRemote:
return m_remoteAdapter;
return new RemoteGdbAdapter(this);
case AttachExternal:
return m_attachAdapter;
return new AttachGdbAdapter(this);
default:
break;
return new PlainGdbAdapter(this);
}
return m_plainAdapter;
}
void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp)
......@@ -1477,10 +1457,8 @@ void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp)
m_startParameters = sp;
if (m_gdbAdapter)
disconnectAdapter();
m_gdbAdapter = determineAdapter(sp);
delete m_gdbAdapter;
m_gdbAdapter = createAdapter(sp);
if (startModeAllowsDumpers())
connectDebuggingHelperActions();
......@@ -4226,9 +4204,7 @@ void GdbEngine::handleAdapterShutdownFailed(const QString &msg)
void GdbEngine::addOptionPages(QList<Core::IOptionsPage*> *opts) const
{
opts->push_back(new GdbOptionsPage);
#ifdef QTCREATOR_WITH_S60
opts->push_back(new TrkOptionsPage(m_trkAdapter->options()));
#endif
opts->push_back(new TrkOptionsPage(m_trkOptions));
}
void GdbEngine::showMessageBox(int icon, const QString &title, const QString &text)
......
......@@ -70,6 +70,7 @@ class CoreGdbAdapter;
class PlainGdbAdapter;
class RemoteGdbAdapter;
class TrkGdbAdapter;
struct TrkOptions;
enum DebuggingHelperState
{
......@@ -162,7 +163,6 @@ private:
StackFrame parseStackFrame(const GdbMi &mi, int level);
void connectAdapter();
void disconnectAdapter();
void initializeVariables();
QString fullName(const QString &fileName);
// get one usable name out of these, try full names first
......@@ -396,7 +396,7 @@ private:
void setLocals(const QList<GdbMi> &locals);
void connectDebuggingHelperActions();
void disconnectDebuggingHelperActions();
AbstractGdbAdapter *determineAdapter(const DebuggerStartParametersPtr &dp) const;
AbstractGdbAdapter *createAdapter(const DebuggerStartParametersPtr &dp);
bool startModeAllowsDumpers() const;
QString parseDisassembler(const GdbMi &lines);
......@@ -423,13 +423,9 @@ private:
DebuggerStartParametersPtr m_startParameters;
// make sure to re-initialize new members in initializeVariables();
// only one of those is active at a given time, available in m_gdbAdapter
AbstractGdbAdapter *m_gdbAdapter; // pointer to one listed below
AttachGdbAdapter *m_attachAdapter; // owned
CoreGdbAdapter *m_coreAdapter; // owned
PlainGdbAdapter *m_plainAdapter; // owned
RemoteGdbAdapter *m_remoteAdapter; // owned
TrkGdbAdapter *m_trkAdapter; // owned
QSharedPointer<TrkOptions> m_trkOptions;
AbstractGdbAdapter *m_gdbAdapter;
public:
QString errorMessage(QProcess::ProcessError error);
......
......@@ -145,7 +145,6 @@ public:
// Set a device (from the project) to override the settings.
QString overrideTrkDevice() const;
void setOverrideTrkDevice(const QString &);
const TrkOptionsPtr options() const { return m_options; }
signals:
void output(const QString &msg);
......
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