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-07 16:25:12 +0000
commiteae5a20b099450985442c70186fd7a7be442f133 (patch)
treee7be003e4ed86ef69ad334eebfd8689cdb1e25b3 /src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h
parent881bb537c92684d25fae4fec9ac2dd61e1f9723c (diff)
V4 Debugger: Allow expression evaluation without pausing
We can schedule jobs into the GUI thread just fine, even if the debugger is running. They will run in global scope then. The only restriction is that we need exactly one engine to be running in order to do that, as otherwise we cannot decide which engine to use. To avoid interaction with the engine from the debugger thread we move the value lookup functionality into the data collector, and drop the RefHolder. Change-Id: Ifae124d70f42e488ed9a1b6794baef638992ddb1 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.h67
1 files changed, 37 insertions, 30 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h
index bfa3bd2fe1..d1ff98f9b0 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h
@@ -38,6 +38,9 @@
#include <private/qv4engine_p.h>
#include <private/qv4persistent_p.h>
+#include <QtCore/QJsonObject>
+#include <QtCore/QJsonArray>
+
QT_BEGIN_NAMESPACE
class QV4DataCollector
@@ -45,6 +48,7 @@ class QV4DataCollector
public:
typedef uint Ref;
typedef QVector<uint> Refs;
+ static const Ref s_invalidRef;
static QV4::CallContext *findContext(QV4::ExecutionEngine *engine, int frame);
static QV4::Heap::CallContext *findScope(QV4::ExecutionContext *ctxt, int scope);
@@ -52,22 +56,21 @@ public:
QV4::ExecutionEngine *engine, int frame);
QV4DataCollector(QV4::ExecutionEngine *engine);
- ~QV4DataCollector();
-
- void collect(const QV4::ScopedValue &value);
-
- QJsonObject lookupRef(Ref ref);
+ Ref collect(const QV4::ScopedValue &value);
Ref addFunctionRef(const QString &functionName);
Ref addScriptRef(const QString &scriptName);
+ bool isValidRef(Ref ref) const;
+ QJsonObject lookupRef(Ref ref);
+
void collectScope(QJsonObject *dict, QV4Debugger *debugger, int frameNr, int scopeNr);
QV4::ExecutionEngine *engine() const { return m_engine; }
+ QJsonArray flushCollectedRefs();
+ void clear();
private:
- friend class RefHolder;
-
Ref addRef(QV4::Value value, bool deduplicate = true);
QV4::ReturnedValue getValue(Ref ref);
bool lookupSpecialRef(Ref ref, QJsonObject *dict);
@@ -77,40 +80,43 @@ private:
void collectArgumentsInContext();
QV4::ExecutionEngine *m_engine;
- Refs *m_collectedRefs;
- QV4::PersistentValue values;
+ Refs m_collectedRefs;
+ QV4::PersistentValue m_values;
typedef QHash<Ref, QJsonObject> SpecialRefs;
- SpecialRefs specialRefs;
+ SpecialRefs m_specialRefs;
};
-class RefHolder {
-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);
- }
+class ValueLookupJob: public QV4Debugger::Job
+{
+ QV4DataCollector *collector;
+ const QJsonArray handles;
+ QJsonObject result;
+ QJsonArray collectedRefs;
+ QString exception;
-private:
- QV4DataCollector *m_collector;
- QV4DataCollector::Refs *m_previousRefs;
+public:
+ ValueLookupJob(const QJsonArray &handles, QV4DataCollector *collector) :
+ collector(collector), handles(handles) {}
+ void run();
+ const QString &exceptionMessage() const;
+ const QJsonObject &returnValue() const;
+ const QJsonArray &refs() const;
};
class ExpressionEvalJob: public QV4Debugger::JavaScriptJob
{
QV4DataCollector *collector;
QString exception;
+ QJsonObject result;
+ QJsonArray collectedRefs;
public:
ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr, const QString &expression,
QV4DataCollector *collector);
- virtual void handleResult(QV4::ScopedValue &result);
+ virtual void handleResult(QV4::ScopedValue &value);
const QString &exceptionMessage() const;
+ const QJsonObject &returnValue() const;
+ const QJsonArray &refs() const;
};
class GatherSourcesJob: public QV4Debugger::Job
@@ -157,23 +163,24 @@ class ThisCollectJob: public QV4Debugger::Job
QV4::ExecutionEngine *engine;
QV4DataCollector *collector;
int frameNr;
- bool *foundThis;
+ QV4DataCollector::Ref thisRef;
public:
- ThisCollectJob(QV4::ExecutionEngine *engine, QV4DataCollector *collector, int frameNr,
- bool *foundThis);
+ ThisCollectJob(QV4::ExecutionEngine *engine, QV4DataCollector *collector, int frameNr);
void run();
- bool myRun();
+ QV4DataCollector::Ref foundRef() const;
};
class ExceptionCollectJob: public QV4Debugger::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