Commit 17a2f671 authored by hjk's avatar hjk

debugger: start second shot at Qml debugging

parent 035cfd55
......@@ -109,6 +109,7 @@ include(cdb/cdb.pri)
include(gdb/gdb.pri)
include(script/script.pri)
include(pdb/pdb.pri)
include(qml/qml.pri)
include(tcf/tcf.pri)
include(shared/shared.pri)
......
......@@ -160,6 +160,7 @@ IDebuggerEngine *createGdbEngine(DebuggerManager *parent);
IDebuggerEngine *createScriptEngine(DebuggerManager *parent);
IDebuggerEngine *createPdbEngine(DebuggerManager *parent);
IDebuggerEngine *createTcfEngine(DebuggerManager *parent);
IDebuggerEngine *createQmlEngine(DebuggerManager *parent);
// The createCdbEngine function takes a list of options pages it can add to.
// This allows for having a "enabled" toggle on the page independently
......@@ -254,6 +255,7 @@ static Debugger::Internal::IDebuggerEngine *gdbEngine = 0;
static Debugger::Internal::IDebuggerEngine *scriptEngine = 0;
static Debugger::Internal::IDebuggerEngine *cdbEngine = 0;
static Debugger::Internal::IDebuggerEngine *pdbEngine = 0;
static Debugger::Internal::IDebuggerEngine *qmlEngine = 0;
static Debugger::Internal::IDebuggerEngine *tcfEngine = 0;
struct DebuggerManagerPrivate
......@@ -351,6 +353,7 @@ DebuggerManager::~DebuggerManager()
doDelete(gdbEngine);
doDelete(cdbEngine);
doDelete(tcfEngine);
doDelete(qmlEngine);
doDelete(d->m_breakHandler);
doDelete(d->m_threadsHandler);
......@@ -359,11 +362,6 @@ DebuggerManager::~DebuggerManager()
doDelete(d->m_snapshotHandler);
doDelete(d->m_stackHandler);
doDelete(d->m_watchHandler);
doDelete(gdbEngine);
doDelete(scriptEngine);
doDelete(cdbEngine);
doDelete(tcfEngine);
# undef doDelete
DebuggerManagerPrivate::instance = 0;
delete d;
......@@ -692,6 +690,11 @@ QList<Core::IOptionsPage*> DebuggerManager::initializeEngines(unsigned enabledTy
tcfEngine->addOptionPages(&rc);
}
if (enabledTypeFlags & QmlEngineType) {
qmlEngine = createQmlEngine(this);
//qmlEngine->addOptionPages(&rc);
}
d->m_engine = 0;
STATE_DEBUG(gdbEngine << cdbEngine << scriptEngine
<< pdbEngine << rc.size());
......@@ -976,6 +979,15 @@ static IDebuggerEngine *debuggerEngineForExecutable(const QString &executable,
QString *errorMessage,
QString *settingsIdHint)
{
if (executable.endsWith(_("qmlviewer"))) {
qDebug() << "HERE";
if (!qmlEngine) {
*errorMessage = msgEngineNotAvailable("Qml Engine");
return 0;
}
return qmlEngine;
}
if (executable.endsWith(_(".js"))) {
if (!scriptEngine) {
*errorMessage = msgEngineNotAvailable("Script Engine");
......@@ -1016,7 +1028,8 @@ static IDebuggerEngine *debuggerEngineForExecutable(const QString &executable,
// We need the CDB debugger in order to be able to debug VS
// executables
if (!DebuggerManager::instance()->checkDebugConfiguration(ProjectExplorer::ToolChain::MSVC, errorMessage, 0 , settingsIdHint))
if (!DebuggerManager::instance()->checkDebugConfiguration(
ProjectExplorer::ToolChain::MSVC, errorMessage, 0, settingsIdHint))
return 0;
return cdbEngine;
#endif
......@@ -1049,6 +1062,7 @@ static IDebuggerEngine *debuggerEngineForMode(DebuggerStartMode startMode, QStri
void DebuggerManager::startNewDebugger(const DebuggerStartParametersPtr &sp)
{
qDebug() << "TARGET: " << sp->executable;
if (d->m_state != DebuggerNotReady)
return;
d->m_startParameters = sp;
......@@ -1067,7 +1081,9 @@ void DebuggerManager::startNewDebugger(const DebuggerStartParametersPtr &sp)
// Figure out engine: toolchain, executable, attach or default
const DebuggerStartMode startMode = sp->startMode;
if (sp->executable.endsWith(_(".js")))
if (sp->executable.endsWith(_("qmlviewer")))
d->m_engine = qmlEngine;
else if (sp->executable.endsWith(_(".js")))
d->m_engine = scriptEngine;
else if (sp->executable.endsWith(_(".py")))
d->m_engine = pdbEngine;
......
......@@ -95,6 +95,7 @@ class CdbDumperInitThread;
class CdbExceptionLoggerEventCallback;
class GdbEngine;
class TcfEngine;
class QmlEngine;
class CdbDebugEngine;
class CdbDebugEnginePrivate;
class TrkGdbAdapter;
......@@ -145,11 +146,13 @@ enum DebuggerEngineTypeFlags
CdbEngineType = 0x04,
PdbEngineType = 0x08,
TcfEngineType = 0x10,
QmlEngineType = 0x20,
AllEngineTypes = GdbEngineType
| ScriptEngineType
| CdbEngineType
| PdbEngineType
| TcfEngineType
| QmlEngineType
};
QDebug operator<<(QDebug d, DebuggerState state);
......@@ -178,6 +181,7 @@ public:
friend class Internal::ScriptEngine;
friend class Internal::PdbEngine;
friend class Internal::TcfEngine;
friend class Internal::QmlEngine;
friend class Internal::CdbDebugEngine;
friend class Internal::CdbDebugEnginePrivate;
friend class Internal::TrkGdbAdapter;
......
......@@ -637,11 +637,15 @@ static bool parseArgument(QStringList::const_iterator &it,
*enabledEngines &= ~Debugger::GdbEngineType;
return true;
}
if (option == _("-disable-qmldb")) {
*enabledEngines &= ~Debugger::QmlEngineType;
return true;
}
if (option == _("-disable-sdb")) {
*enabledEngines &= ~Debugger::ScriptEngineType;
return true;
}
if (option == QLatin1String("-disable-tcf")) {
if (option == _("-disable-tcf")) {
*enabledEngines &= ~TcfEngineType;
return true;
}
......@@ -1358,7 +1362,6 @@ void DebuggerPlugin::languageChanged(const QString &language)
m_attachCoreAction->setVisible(debuggerIsCPP);
m_startRemoteAction->setVisible(debuggerIsCPP);
m_detachAction->setVisible(debuggerIsCPP);
}
void DebuggerPlugin::writeSettings() const
......@@ -1398,12 +1401,9 @@ void DebuggerPlugin::onModeChanged(IMode *mode)
if (isCurrentProjectCppBased())
m_uiSwitcher->setActiveLanguage(LANG_CPP);
}
}
void DebuggerPlugin::showSettingsDialog()
{
Core::ICore::instance()->showOptionsDialog(
......
......@@ -48,6 +48,7 @@
namespace Debugger {
namespace Internal {
using ProjectExplorer::BuildConfiguration;
using ProjectExplorer::RunConfiguration;
using ProjectExplorer::RunControl;
using ProjectExplorer::LocalApplicationRunConfiguration;
......@@ -65,6 +66,7 @@ DebuggerRunControlFactory::DebuggerRunControlFactory(DebuggerManager *manager)
bool DebuggerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const
{
// return mode == ProjectExplorer::Constants::DEBUGMODE;
return mode == ProjectExplorer::Constants::DEBUGMODE
&& qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
}
......@@ -130,8 +132,9 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
break;
}
if (runConfiguration->target()->project()) {
m_startParameters->buildDirectory =
runConfiguration->target()->activeBuildConfiguration()->buildDirectory();
BuildConfiguration *bc = runConfiguration->target()->activeBuildConfiguration();
if (bc)
m_startParameters->buildDirectory = bc->buildDirectory();
}
m_startParameters->useTerminal =
runConfiguration->runMode() == LocalApplicationRunConfiguration::Console;
......
HEADERS += \
$$PWD/qmlengine.h \
SOURCES += \
$$PWD/qmlengine.cpp \
FORMS +=
RESOURCES +=
This diff is collapsed.
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef DEBUGGER_QMLENGINE_H
#define DEBUGGER_QMLENGINE_H
#include <QtCore/QByteArray>
#include <QtCore/QHash>
#include <QtCore/QMap>
#include <QtCore/QObject>
#include <QtCore/QPoint>
#include <QtCore/QProcess>
#include <QtCore/QQueue>
#include <QtCore/QSet>
#include <QtCore/QTimer>
#include <QtCore/QVariant>
#include <QtNetwork/QAbstractSocket>
QT_BEGIN_NAMESPACE
class QTcpSocket;
QT_END_NAMESPACE
#include "idebuggerengine.h"
#include "debuggermanager.h"
namespace Debugger {
namespace Internal {
class ScriptAgent;
class WatchData;
class QmlResponse;
class QmlEngine : public IDebuggerEngine
{
Q_OBJECT
public:
explicit QmlEngine(DebuggerManager *parent);
~QmlEngine();
private:
// IDebuggerEngine implementation
void executeStep();
void executeStepOut();
void executeNext();
void executeStepI();
void executeNextI();
void shutdown();
void setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos);
void startDebugger(const DebuggerStartParametersPtr &sp);
void exitDebugger();
void continueInferior();
Q_SLOT void runInferior();
void interruptInferior();
void executeRunToLine(const QString &fileName, int lineNumber);
void executeRunToFunction(const QString &functionName);
void executeJumpToLine(const QString &fileName, int lineNumber);
void activateFrame(int index);
void selectThread(int index);
void attemptBreakpointSynchronization();
void assignValueInDebugger(const QString &expr, const QString &value);
void executeDebuggerCommand(const QString & command);
void loadSymbols(const QString &moduleName);
void loadAllSymbols();
void requestModuleSymbols(const QString &moduleName);
void reloadModules();
void reloadRegisters() {}
void reloadSourceFiles() {}
void reloadFullStack() {}
bool supportsThreads() const { return true; }
void maybeBreakNow(bool byFunction);
void updateWatchData(const WatchData &data);
void updateLocals();
void updateSubItem(const WatchData &data);
Q_SLOT void socketConnected();
Q_SLOT void socketDisconnected();
Q_SLOT void socketError(QAbstractSocket::SocketError);
Q_SLOT void socketReadyRead();
void handleResponse(const QByteArray &ba);
void handleRunControlSuspend(const QmlResponse &response, const QVariant &);
void handleRunControlGetChildren(const QmlResponse &response, const QVariant &);
void handleSysMonitorGetChildren(const QmlResponse &response, const QVariant &);
private:
Q_SLOT void startDebugging();
typedef void (QmlEngine::*QmlCommandCallback)
(const QmlResponse &record, const QVariant &cookie);
struct QmlCommand
{
QmlCommand() : flags(0), token(-1), callback(0), callbackName(0) {}
QString toString() const;
int flags;
int token;
QmlCommandCallback callback;
const char *callbackName;
QByteArray command;
QVariant cookie;
};
void postCommand(const QByteArray &cmd,
QmlCommandCallback callback = 0, const char *callbackName = 0);
void sendCommandNow(const QmlCommand &command);
void debugMessage(const QString &msg);
QHash<int, QmlCommand> m_cookieForToken;
QQueue<QmlCommand> m_sendQueue;
// timer based congestion control. does not seem to work well.
void enqueueCommand(const QmlCommand &command);
Q_SLOT void handleSendTimer();
int m_congestion;
QTimer m_sendTimer;
// synchrounous communication
void acknowledgeResult();
int m_inAir;
QTcpSocket *m_socket;
QByteArray m_inbuffer;
QList<QByteArray> m_services;
};
} // namespace Internal
} // namespace Debugger
#endif // DEBUGGER_QMLENGINE_H
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