Commit c5f13ced authored by hjk's avatar hjk
Browse files

debugger: partial refactoring of debugger engine creation

parent 3215da91
......@@ -1685,25 +1685,21 @@ bool CdbDebugEnginePrivate::setSymbolPaths(const QStringList &s, QString *errorM
return true;
}
} // namespace Internal
} // namespace Debugger
// Accessed by DebuggerManager
Debugger::Internal::IDebuggerEngine *createWinEngine(Debugger::Internal::DebuggerManager *parent,
bool cmdLineEnabled,
QList<Core::IOptionsPage*> *opts)
IDebuggerEngine *createWinEngine(DebuggerManager *parent,
bool cmdLineEnabled,
QList<Core::IOptionsPage*> *opts)
{
// Create options page
QSharedPointer<Debugger::Internal::CdbOptions> options(new Debugger::Internal::CdbOptions);
QSharedPointer<CdbOptions> options(new CdbOptions);
options->fromSettings(Core::ICore::instance()->settings());
Debugger::Internal::CdbOptionsPage *optionsPage = new Debugger::Internal::CdbOptionsPage(options);
CdbOptionsPage *optionsPage = new CdbOptionsPage(options);
opts->push_back(optionsPage);
if (!cmdLineEnabled || !options->enabled)
return 0;
// Create engine
QString errorMessage;
Debugger::Internal::IDebuggerEngine *engine =
Debugger::Internal::CdbDebugEngine::create(parent, options, &errorMessage);
IDebuggerEngine *engine = CdbDebugEngine::create(parent, options, &errorMessage);
if (!engine) {
optionsPage->setFailureMessage(errorMessage);
qWarning("%s\n" ,qPrintable(errorMessage));
......@@ -1711,3 +1707,7 @@ Debugger::Internal::IDebuggerEngine *createWinEngine(Debugger::Internal::Debugge
QObject::connect(optionsPage, SIGNAL(debuggerPathsChanged()), engine, SLOT(syncDebuggerPaths()));
return engine;
}
} // namespace Internal
} // namespace Debugger
......@@ -99,6 +99,7 @@ public:
virtual void reloadRegisters();
virtual void reloadSourceFiles();
virtual void reloadFullStack() {}
virtual void addOptionPages(QList<Core::IOptionsPage*> *) const;
public slots:
void syncDebuggerPaths();
......
......@@ -82,11 +82,17 @@
#include <QtGui/QToolButton>
#include <QtGui/QToolTip>
namespace Debugger {
namespace Internal {
// The creation functions take a list of options pages they can add to.
// This allows for having a "enabled" toggle on the page indepently
// of the engine.
using namespace Debugger::Internal;
IDebuggerEngine *createGdbEngine(DebuggerManager *parent);
IDebuggerEngine *createScriptEngine(DebuggerManager *parent);
IDebuggerEngine *createTcfEngine(DebuggerManager *parent);
// The createWinEngine function takes a list of options pages it can add to.
// This allows for having a "enabled" toggle on the page independently
// of the engine. That's good for not enabling the related ActiveX control
// unnecessarily.
IDebuggerEngine *createWinEngine(DebuggerManager *, bool /* cmdLineEnabled */, QList<Core::IOptionsPage*> *)
#ifdef CDB_ENABLED
......@@ -94,14 +100,6 @@ IDebuggerEngine *createWinEngine(DebuggerManager *, bool /* cmdLineEnabled */, Q
#else
{ return 0; }
#endif
IDebuggerEngine *createScriptEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *);
IDebuggerEngine *createTcfEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *);
namespace Debugger {
namespace Internal {
IDebuggerEngine *createGdbEngine(DebuggerManager *parent);
QDebug operator<<(QDebug str, const DebuggerStartParameters &p)
......@@ -443,15 +441,24 @@ void DebuggerManager::init()
QList<Core::IOptionsPage*> DebuggerManager::initializeEngines(unsigned enabledTypeFlags)
{
QList<Core::IOptionsPage*> rc;
if (enabledTypeFlags & GdbEngineType) {
gdbEngine = createGdbEngine(this);
gdbEngine->addOptionPages(&rc);
}
winEngine = createWinEngine(this, (enabledTypeFlags & CdbEngineType), &rc);
if (enabledTypeFlags & ScriptEngineType)
scriptEngine = createScriptEngine(this, &rc);
if (enabledTypeFlags & TcfEngineType)
tcfEngine = createTcfEngine(this, &rc);
if (enabledTypeFlags & ScriptEngineType) {
scriptEngine = createScriptEngine(this);
scriptEngine->addOptionPages(&rc);
}
if (enabledTypeFlags & TcfEngineType) {
tcfEngine = createTcfEngine(this);
tcfEngine->addOptionPages(&rc);
}
m_engine = 0;
if (Debugger::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << gdbEngine << winEngine << scriptEngine << rc.size();
......
......@@ -65,10 +65,6 @@
#include <QtScript/QScriptValue>
#include <QtScript/QScriptValueIterator>
using namespace Debugger;
using namespace Debugger::Internal;
using namespace Debugger::Constants;
//#define DEBUG_SCRIPT 1
#if DEBUG_SCRIPT
# define SDEBUG(s) qDebug() << s
......@@ -77,13 +73,17 @@ using namespace Debugger::Constants;
#endif
# define XSDEBUG(s) qDebug() << s
namespace Debugger {
namespace Internal {
///////////////////////////////////////////////////////////////////////
//
// ScriptEngine
//
///////////////////////////////////////////////////////////////////////
class Debugger::Internal::ScriptAgent : public QScriptEngineAgent
class ScriptAgent : public QScriptEngineAgent
{
public:
ScriptAgent(ScriptEngine *debugger, QScriptEngine *script);
......@@ -733,8 +733,10 @@ void ScriptEngine::updateSubItem(const WatchData &data0)
QTC_ASSERT(false, return);
}
IDebuggerEngine *createScriptEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *)
IDebuggerEngine *createScriptEngine(DebuggerManager *parent)
{
return new ScriptEngine(parent);
}
} // namespace Internal
} // namespace Debugger
......@@ -57,11 +57,6 @@
#include <QtNetwork/QTcpSocket>
using namespace Debugger;
using namespace Debugger::Internal;
using namespace Debugger::Constants;
#define DEBUG_TCF 1
#if DEBUG_TCF
# define SDEBUG(s) qDebug() << s
......@@ -74,7 +69,9 @@ using namespace Debugger::Constants;
#define STRINGIFY(x) STRINGIFY_INTERNAL(x)
#define CB(callback) &TcfEngine::callback, STRINGIFY(callback)
QByteArray C(const QByteArray &ba1,
//#define USE_CONGESTION_CONTROL
static QByteArray C(const QByteArray &ba1,
const QByteArray &ba2 = QByteArray(),
const QByteArray &ba3 = QByteArray(),
const QByteArray &ba4 = QByteArray(),
......@@ -88,9 +85,8 @@ QByteArray C(const QByteArray &ba1,
return result;
}
//#define USE_CONGESTION_CONTROL
namespace Debugger {
namespace Internal {
///////////////////////////////////////////////////////////////////////
//
......@@ -571,8 +567,10 @@ void TcfEngine::updateSubItem(const WatchData &data0)
QTC_ASSERT(false, return);
}
IDebuggerEngine *createTcfEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *)
IDebuggerEngine *createTcfEngine(DebuggerManager *parent)
{
return new TcfEngine(parent);
}
} // namespace Internal
} // namespace Debugger
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