diff options
Diffstat (limited to 'src/declarative/debugger')
-rw-r--r-- | src/declarative/debugger/debugger.pri | 6 | ||||
-rw-r--r-- | src/declarative/debugger/qdeclarativedebug.cpp | 5 | ||||
-rw-r--r-- | src/declarative/debugger/qdeclarativedebug_p.h | 3 | ||||
-rw-r--r-- | src/declarative/debugger/qdeclarativeinspectorinterface_p.h (renamed from src/declarative/debugger/qdeclarativeobserverinterface_p.h) | 8 | ||||
-rw-r--r-- | src/declarative/debugger/qdeclarativeinspectorservice.cpp (renamed from src/declarative/debugger/qdeclarativeobserverservice.cpp) | 46 | ||||
-rw-r--r-- | src/declarative/debugger/qdeclarativeinspectorservice_p.h (renamed from src/declarative/debugger/qdeclarativeobserverservice_p.h) | 12 | ||||
-rw-r--r-- | src/declarative/debugger/qjsdebuggeragent.cpp | 13 | ||||
-rw-r--r-- | src/declarative/debugger/qjsdebuggeragent_p.h | 2 | ||||
-rw-r--r-- | src/declarative/debugger/qjsdebugservice.cpp | 10 | ||||
-rw-r--r-- | src/declarative/debugger/qpacketprotocol.cpp | 78 |
10 files changed, 103 insertions, 80 deletions
diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri index 044db3c..3134c79 100644 --- a/src/declarative/debugger/debugger.pri +++ b/src/declarative/debugger/debugger.pri @@ -9,7 +9,7 @@ SOURCES += \ $$PWD/qdeclarativedebugtrace.cpp \ $$PWD/qdeclarativedebughelper.cpp \ $$PWD/qdeclarativedebugserver.cpp \ - $$PWD/qdeclarativeobserverservice.cpp \ + $$PWD/qdeclarativeinspectorservice.cpp \ $$PWD/qjsdebuggeragent.cpp \ $$PWD/qjsdebugservice.cpp @@ -24,7 +24,7 @@ HEADERS += \ $$PWD/qdeclarativedebughelper_p.h \ $$PWD/qdeclarativedebugserver_p.h \ $$PWD/qdeclarativedebugserverconnection_p.h \ - $$PWD/qdeclarativeobserverservice_p.h \ - $$PWD/qdeclarativeobserverinterface_p.h \ + $$PWD/qdeclarativeinspectorservice_p.h \ + $$PWD/qdeclarativeinspectorinterface_p.h \ $$PWD/qjsdebuggeragent_p.h \ $$PWD/qjsdebugservice_p.h diff --git a/src/declarative/debugger/qdeclarativedebug.cpp b/src/declarative/debugger/qdeclarativedebug.cpp index 32c2b47..620ee1d 100644 --- a/src/declarative/debugger/qdeclarativedebug.cpp +++ b/src/declarative/debugger/qdeclarativedebug.cpp @@ -638,14 +638,15 @@ QDeclarativeDebugExpressionQuery *QDeclarativeEngineDebug::queryExpressionResult bool QDeclarativeEngineDebug::setBindingForObject(int objectDebugId, const QString &propertyName, const QVariant &bindingExpression, - bool isLiteralValue) + bool isLiteralValue, + QString source, int line) { Q_D(QDeclarativeEngineDebug); if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_BINDING") << objectDebugId << propertyName << bindingExpression << isLiteralValue; + ds << QByteArray("SET_BINDING") << objectDebugId << propertyName << bindingExpression << isLiteralValue << source << line; d->client->sendMessage(message); return true; } else { diff --git a/src/declarative/debugger/qdeclarativedebug_p.h b/src/declarative/debugger/qdeclarativedebug_p.h index ae92d6a..f822637 100644 --- a/src/declarative/debugger/qdeclarativedebug_p.h +++ b/src/declarative/debugger/qdeclarativedebug_p.h @@ -101,7 +101,8 @@ public: const QString &expr, QObject *parent = 0); bool setBindingForObject(int objectDebugId, const QString &propertyName, - const QVariant &bindingExpression, bool isLiteralValue); + const QVariant &bindingExpression, bool isLiteralValue, + QString source = QString(), int line = -1); bool resetBindingForObject(int objectDebugId, const QString &propertyName); bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody); diff --git a/src/declarative/debugger/qdeclarativeobserverinterface_p.h b/src/declarative/debugger/qdeclarativeinspectorinterface_p.h index efb47fa..aa29d68 100644 --- a/src/declarative/debugger/qdeclarativeobserverinterface_p.h +++ b/src/declarative/debugger/qdeclarativeinspectorinterface_p.h @@ -50,17 +50,17 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_DECLARATIVE_EXPORT QDeclarativeObserverInterface +class Q_DECLARATIVE_EXPORT QDeclarativeInspectorInterface { public: - QDeclarativeObserverInterface() {} - virtual ~QDeclarativeObserverInterface() {} + QDeclarativeInspectorInterface() {} + virtual ~QDeclarativeInspectorInterface() {} virtual void activate() = 0; virtual void deactivate() = 0; }; -Q_DECLARE_INTERFACE(QDeclarativeObserverInterface, "com.trolltech.Qt.QDeclarativeObserverInterface/1.0") +Q_DECLARE_INTERFACE(QDeclarativeInspectorInterface, "com.trolltech.Qt.QDeclarativeInspectorInterface/1.0") QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativeobserverservice.cpp b/src/declarative/debugger/qdeclarativeinspectorservice.cpp index 43d9281..9fec006 100644 --- a/src/declarative/debugger/qdeclarativeobserverservice.cpp +++ b/src/declarative/debugger/qdeclarativeinspectorservice.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "private/qdeclarativeobserverservice_p.h" -#include "private/qdeclarativeobserverinterface_p.h" +#include "private/qdeclarativeinspectorservice_p.h" +#include "private/qdeclarativeinspectorinterface_p.h" #include <QtCore/QCoreApplication> #include <QtCore/QDebug> @@ -51,30 +51,30 @@ QT_BEGIN_NAMESPACE -Q_GLOBAL_STATIC(QDeclarativeObserverService, serviceInstance) +Q_GLOBAL_STATIC(QDeclarativeInspectorService, serviceInstance) -QDeclarativeObserverService::QDeclarativeObserverService() +QDeclarativeInspectorService::QDeclarativeInspectorService() : QDeclarativeDebugService(QLatin1String("QDeclarativeObserverMode")) - , m_observer(0) + , m_inspectorPlugin(0) { } -QDeclarativeObserverService *QDeclarativeObserverService::instance() +QDeclarativeInspectorService *QDeclarativeInspectorService::instance() { return serviceInstance(); } -void QDeclarativeObserverService::addView(QDeclarativeView *view) +void QDeclarativeInspectorService::addView(QDeclarativeView *view) { m_views.append(view); } -void QDeclarativeObserverService::removeView(QDeclarativeView *view) +void QDeclarativeInspectorService::removeView(QDeclarativeView *view) { m_views.removeAll(view); } -void QDeclarativeObserverService::sendMessage(const QByteArray &message) +void QDeclarativeInspectorService::sendMessage(const QByteArray &message) { if (status() != Enabled) return; @@ -82,33 +82,33 @@ void QDeclarativeObserverService::sendMessage(const QByteArray &message) QDeclarativeDebugService::sendMessage(message); } -void QDeclarativeObserverService::statusChanged(Status status) +void QDeclarativeInspectorService::statusChanged(Status status) { if (m_views.isEmpty()) return; if (status == Enabled) { - if (!m_observer) - m_observer = loadObserverPlugin(); + if (!m_inspectorPlugin) + m_inspectorPlugin = loadInspectorPlugin(); - if (!m_observer) { - qWarning() << "Error while loading observer plugin"; + if (!m_inspectorPlugin) { + qWarning() << "Error while loading inspector plugin"; return; } - m_observer->activate(); + m_inspectorPlugin->activate(); } else { - if (m_observer) - m_observer->deactivate(); + if (m_inspectorPlugin) + m_inspectorPlugin->deactivate(); } } -void QDeclarativeObserverService::messageReceived(const QByteArray &message) +void QDeclarativeInspectorService::messageReceived(const QByteArray &message) { emit gotMessage(message); } -QDeclarativeObserverInterface *QDeclarativeObserverService::loadObserverPlugin() +QDeclarativeInspectorInterface *QDeclarativeInspectorService::loadInspectorPlugin() { QStringList pluginCandidates; const QStringList paths = QCoreApplication::libraryPaths(); @@ -124,11 +124,11 @@ QDeclarativeObserverInterface *QDeclarativeObserverService::loadObserverPlugin() if (!loader.load()) continue; - QDeclarativeObserverInterface *observer = - qobject_cast<QDeclarativeObserverInterface*>(loader.instance()); + QDeclarativeInspectorInterface *inspector = + qobject_cast<QDeclarativeInspectorInterface*>(loader.instance()); - if (observer) - return observer; + if (inspector) + return inspector; loader.unload(); } return 0; diff --git a/src/declarative/debugger/qdeclarativeobserverservice_p.h b/src/declarative/debugger/qdeclarativeinspectorservice_p.h index c883d4b..9fe0d601f 100644 --- a/src/declarative/debugger/qdeclarativeobserverservice_p.h +++ b/src/declarative/debugger/qdeclarativeinspectorservice_p.h @@ -54,15 +54,15 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QDeclarativeView; -class QDeclarativeObserverInterface; +class QDeclarativeInspectorInterface; -class Q_DECLARATIVE_EXPORT QDeclarativeObserverService : public QDeclarativeDebugService +class Q_DECLARATIVE_EXPORT QDeclarativeInspectorService : public QDeclarativeDebugService { Q_OBJECT public: - QDeclarativeObserverService(); - static QDeclarativeObserverService *instance(); + QDeclarativeInspectorService(); + static QDeclarativeInspectorService *instance(); void addView(QDeclarativeView *); void removeView(QDeclarativeView *); @@ -78,10 +78,10 @@ protected: virtual void messageReceived(const QByteArray &); private: - static QDeclarativeObserverInterface *loadObserverPlugin(); + static QDeclarativeInspectorInterface *loadInspectorPlugin(); QList<QDeclarativeView*> m_views; - QDeclarativeObserverInterface *m_observer; + QDeclarativeInspectorInterface *m_inspectorPlugin; }; QT_END_NAMESPACE diff --git a/src/declarative/debugger/qjsdebuggeragent.cpp b/src/declarative/debugger/qjsdebuggeragent.cpp index 9b76592..dff637b 100644 --- a/src/declarative/debugger/qjsdebuggeragent.cpp +++ b/src/declarative/debugger/qjsdebuggeragent.cpp @@ -56,7 +56,7 @@ class QJSDebuggerAgentPrivate { public: QJSDebuggerAgentPrivate(QJSDebuggerAgent *q) - : q(q), state(NoState) + : q(q), state(NoState), isInitialized(false) {} void continueExec(); @@ -79,6 +79,7 @@ public: QHash<QString, JSAgentBreakpointData> fileNameToBreakpoints; QStringList watchExpressions; QSet<qint64> knownObjectIds; + bool isInitialized; }; namespace { @@ -252,6 +253,14 @@ QJSDebuggerAgent::~QJSDebuggerAgent() delete d; } +/*! + Indicates whether the agent got the list of breakpoints. + */ +bool QJSDebuggerAgent::isInitialized() const +{ + return d->isInitialized; +} + void QJSDebuggerAgent::setBreakpoints(const JSAgentBreakpoints &breakpoints) { d->breakpoints = breakpoints; @@ -259,6 +268,8 @@ void QJSDebuggerAgent::setBreakpoints(const JSAgentBreakpoints &breakpoints) d->fileNameToBreakpoints.clear(); foreach (const JSAgentBreakpointData &bp, breakpoints) d->fileNameToBreakpoints.insertMulti(fileName(QString::fromUtf8(bp.fileUrl)), bp); + + d->isInitialized = true; } void QJSDebuggerAgent::setWatchExpressions(const QStringList &watchExpressions) diff --git a/src/declarative/debugger/qjsdebuggeragent_p.h b/src/declarative/debugger/qjsdebuggeragent_p.h index 5aa3c9c..309588e 100644 --- a/src/declarative/debugger/qjsdebuggeragent_p.h +++ b/src/declarative/debugger/qjsdebuggeragent_p.h @@ -145,6 +145,8 @@ public: QJSDebuggerAgent(QDeclarativeEngine *engine, QObject *parent = 0); ~QJSDebuggerAgent(); + bool isInitialized() const; + void setBreakpoints(const JSAgentBreakpoints &); void setWatchExpressions(const QStringList &); diff --git a/src/declarative/debugger/qjsdebugservice.cpp b/src/declarative/debugger/qjsdebugservice.cpp index 4ce2c90..ad84f65 100644 --- a/src/declarative/debugger/qjsdebugservice.cpp +++ b/src/declarative/debugger/qjsdebugservice.cpp @@ -71,6 +71,16 @@ void QJSDebugService::addEngine(QDeclarativeEngine *engine) Q_ASSERT(!m_engines.contains(engine)); m_engines.append(engine); + + if (status() == Enabled && !m_engines.isEmpty() && !m_agent) { + m_agent = new QJSDebuggerAgent(engine, engine); + connect(m_agent, SIGNAL(stopped(bool,QString)), + this, SLOT(executionStopped(bool,QString))); + + while (!m_agent->isInitialized()) { + waitForMessage(); + } + } } void QJSDebugService::removeEngine(QDeclarativeEngine *engine) diff --git a/src/declarative/debugger/qpacketprotocol.cpp b/src/declarative/debugger/qpacketprotocol.cpp index c24df61..9caaa79 100644 --- a/src/declarative/debugger/qpacketprotocol.cpp +++ b/src/declarative/debugger/qpacketprotocol.cpp @@ -164,47 +164,45 @@ public Q_SLOTS: void readyToRead() { - if(-1 == inProgressSize) { - // We need a size header of sizeof(qint32) - if(sizeof(qint32) > (uint)dev->bytesAvailable()) - return; - - // Read size header - int read = dev->read((char *)&inProgressSize, sizeof(qint32)); - Q_ASSERT(read == sizeof(qint32)); - Q_UNUSED(read); - - // Check sizing constraints - if(inProgressSize > maxPacketSize) { - QObject::disconnect(dev, SIGNAL(readyRead()), - this, SLOT(readyToRead())); - QObject::disconnect(dev, SIGNAL(aboutToClose()), - this, SLOT(aboutToClose())); - QObject::disconnect(dev, SIGNAL(bytesWritten(qint64)), - this, SLOT(bytesWritten(qint64))); - dev = 0; - emit invalidPacket(); - return; - } - - inProgressSize -= sizeof(qint32); - + while (true) { // Need to get trailing data - readyToRead(); - } else { - inProgress.append(dev->read(inProgressSize - inProgress.size())); - - if(inProgressSize == inProgress.size()) { - // Packet has arrived! - packets.append(inProgress); - inProgressSize = -1; - inProgress.clear(); - - emit readyRead(); - waitingForPacket = false; - - // Need to get trailing data - readyToRead(); + if (-1 == inProgressSize) { + // We need a size header of sizeof(qint32) + if (sizeof(qint32) > (uint)dev->bytesAvailable()) + return; + + // Read size header + int read = dev->read((char *)&inProgressSize, sizeof(qint32)); + Q_ASSERT(read == sizeof(qint32)); + Q_UNUSED(read); + + // Check sizing constraints + if (inProgressSize > maxPacketSize) { + QObject::disconnect(dev, SIGNAL(readyRead()), + this, SLOT(readyToRead())); + QObject::disconnect(dev, SIGNAL(aboutToClose()), + this, SLOT(aboutToClose())); + QObject::disconnect(dev, SIGNAL(bytesWritten(qint64)), + this, SLOT(bytesWritten(qint64))); + dev = 0; + emit invalidPacket(); + return; + } + + inProgressSize -= sizeof(qint32); + } else { + inProgress.append(dev->read(inProgressSize - inProgress.size())); + + if (inProgressSize == inProgress.size()) { + // Packet has arrived! + packets.append(inProgress); + inProgressSize = -1; + inProgress.clear(); + + waitingForPacket = false; + emit readyRead(); + } else + return; } } } |