aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-11-30 12:04:59 +0100
committerUlf Hermann <ulf.hermann@theqtcompany.com>2016-01-22 09:51:37 +0000
commit5537027094d26e517fc4ad3173ea84d254dd3013 (patch)
tree3457ba913c542447d2492ed32049ffb0f63bdf5b /src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h
parent872a05475721ad771bd347d1526035e6e7479d30 (diff)
V4 Debugger: Avoid looking up values in debugger thread
To avoid interaction with the engine from the debugger thread we move the value lookup functionality into the data collector, and drop the RefHolder. Also, we define some more debugger jobs to move the work the request handlers do into the GUI thread. Task-number: QTBUG-50481 Change-Id: Ia73ebd01e715f13110ef010a766e9b0a1e202df9 Reviewed-by: Nils Jeisecke <jeisecke@saltation.de> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h')
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h114
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