diff options
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h | 114 |
1 files changed, 60 insertions, 54 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h index d0e4a4ad18..5a2c8ff33b 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h @@ -37,6 +37,9 @@ #include <private/qv4engine_p.h> #include <private/qv4debugging_p.h> +#include <QtCore/QJsonObject> +#include <QtCore/QJsonArray> + QT_BEGIN_NAMESPACE class QV4DataCollector @@ -49,25 +52,27 @@ public: static QV4::Heap::CallContext *findScope(QV4::ExecutionContext *ctxt, int scope); static QVector<QV4::Heap::ExecutionContext::ContextType> getScopeTypes( QV4::ExecutionEngine *engine, int frame); + static int encodeScopeType(QV4::Heap::ExecutionContext::ContextType scopeType); QV4DataCollector(QV4::ExecutionEngine *engine); ~QV4DataCollector(); - void collect(const QV4::ScopedValue &value); - + Ref collect(const QV4::ScopedValue &value); + bool isValidRef(Ref ref) const; QJsonObject lookupRef(Ref ref); Ref addFunctionRef(const QString &functionName); Ref addScriptRef(const QString &scriptName); - void collectScope(QJsonObject *dict, QV4::Debugging::V4Debugger *debugger, int frameNr, + bool collectScope(QJsonObject *dict, QV4::Debugging::V4Debugger *debugger, int frameNr, int scopeNr); + QJsonObject buildFrame(const QV4::StackFrame &stackFrame, int frameNr, + QV4::Debugging::V4Debugger *debugger); QV4::ExecutionEngine *engine() const { return m_engine; } + QJsonArray flushCollectedRefs(); private: - friend class RefHolder; - Ref addRef(QV4::Value value, bool deduplicate = true); QV4::ReturnedValue getValue(Ref ref); bool lookupSpecialRef(Ref ref, QJsonObject *dict); @@ -77,102 +82,103 @@ private: void collectArgumentsInContext(); QV4::ExecutionEngine *m_engine; - Refs *m_collectedRefs; + Refs collectedRefs; QV4::PersistentValue values; typedef QHash<Ref, QJsonObject> SpecialRefs; SpecialRefs specialRefs; }; -class RefHolder { +class CollectJob : public QV4::Debugging::V4Debugger::Job +{ +protected: + QV4DataCollector *collector; + QJsonObject result; + QJsonArray collectedRefs; public: - RefHolder(QV4DataCollector *collector, QV4DataCollector::Refs *target) : - m_collector(collector), m_previousRefs(collector->m_collectedRefs) - { - m_collector->m_collectedRefs = target; - } - - ~RefHolder() - { - std::swap(m_collector->m_collectedRefs, m_previousRefs); - } - -private: - QV4DataCollector *m_collector; - QV4DataCollector::Refs *m_previousRefs; + CollectJob(QV4DataCollector *collector) : collector(collector) {} + const QJsonObject &returnValue() const { return result; } + const QJsonArray &refs() const { return collectedRefs; } }; -class ExpressionEvalJob: public QV4::Debugging::V4Debugger::JavaScriptJob +class BacktraceJob: public CollectJob { - QV4DataCollector *collector; - QString exception; - + int fromFrame; + int toFrame; public: - ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr, const QString &expression, - QV4DataCollector *collector); - virtual void handleResult(QV4::ScopedValue &result); - const QString &exceptionMessage() const; + BacktraceJob(QV4DataCollector *collector, int fromFrame, int toFrame); + void run(); }; -class GatherSourcesJob: public QV4::Debugging::V4Debugger::Job +class FrameJob: public CollectJob { - QV4::ExecutionEngine *engine; - const int seq; + int frameNr; + bool success; public: - GatherSourcesJob(QV4::ExecutionEngine *engine, int seq); + FrameJob(QV4DataCollector *collector, int frameNr); void run(); + bool wasSuccessful() const; }; -class ArgumentCollectJob: public QV4::Debugging::V4Debugger::Job +class ScopeJob: public CollectJob { - QV4::ExecutionEngine *engine; - QV4DataCollector *collector; - QStringList *names; int frameNr; int scopeNr; + bool success; public: - ArgumentCollectJob(QV4::ExecutionEngine *engine, QV4DataCollector *collector, - QStringList *names, int frameNr, int scopeNr); + ScopeJob(QV4DataCollector *collector, int frameNr, int scopeNr); void run(); + bool wasSuccessful() const; }; -class LocalCollectJob: public QV4::Debugging::V4Debugger::Job +class ValueLookupJob: public CollectJob { - QV4::ExecutionEngine *engine; - QV4DataCollector *collector; - QStringList *names; - int frameNr; - int scopeNr; + const QJsonArray handles; + QString exception; public: - LocalCollectJob(QV4::ExecutionEngine *engine, QV4DataCollector *collector, QStringList *names, - int frameNr, int scopeNr); + ValueLookupJob(const QJsonArray &handles, QV4DataCollector *collector); void run(); + const QString &exceptionMessage() const; }; -class ThisCollectJob: public QV4::Debugging::V4Debugger::Job +class ExpressionEvalJob: public QV4::Debugging::V4Debugger::JavaScriptJob { - QV4::ExecutionEngine *engine; QV4DataCollector *collector; - int frameNr; - bool *foundThis; + QString exception; + QJsonObject value; + QJsonArray collectedRefs; public: - ThisCollectJob(QV4::ExecutionEngine *engine, QV4DataCollector *collector, int frameNr, - bool *foundThis); + ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr, const QString &expression, + QV4DataCollector *collector); + virtual void handleResult(QV4::ScopedValue &result); + const QString &exceptionMessage() const; + const QJsonObject &returnValue() const; + const QJsonArray &refs() const; +}; + +class GatherSourcesJob: public QV4::Debugging::V4Debugger::Job +{ + QV4::ExecutionEngine *engine; + const int seq; + +public: + GatherSourcesJob(QV4::ExecutionEngine *engine, int seq); void run(); - bool myRun(); }; class ExceptionCollectJob: public QV4::Debugging::V4Debugger::Job { QV4::ExecutionEngine *engine; QV4DataCollector *collector; + QV4DataCollector::Ref exception; public: ExceptionCollectJob(QV4::ExecutionEngine *engine, QV4DataCollector *collector); void run(); + QV4DataCollector::Ref exceptionValue() const; }; QT_END_NAMESPACE |