class ExpressionEvalJob: public QV4::Debugging::Debugger::JavaScriptJob
{
QV4DataCollector *collector;
+ QString exception;
public:
ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr, const QString &expression,
QV4DataCollector *collector);
virtual void handleResult(QV4::ScopedValue &result);
+ const QString &exceptionMessage() const;
};
class GatherSourcesJob: public QV4::Debugging::Debugger::Job
virtual void handleRequest()
{
- //decypher the payload:
- QJsonObject arguments = req.value(QStringLiteral("arguments")).toObject();
- QString expression = arguments.value(QStringLiteral("expression")).toString();
- const int frame = arguments.value(QStringLiteral("frame")).toInt(0);
-
QV4::Debugging::Debugger *debugger = debugService->debuggerAgent.firstDebugger();
- Q_ASSERT(debugger->state() == QV4::Debugging::Debugger::Paused);
-
- QV4DataCollector *collector = debugService->collector();
- QV4DataCollector::Refs refs;
- RefHolder holder(collector, &refs);
- Q_ASSERT(debugger->state() == QV4::Debugging::Debugger::Paused);
-
- ExpressionEvalJob job(debugger->engine(), frame, expression, collector);
- debugger->runInEngine(&job);
-
- Q_ASSERT(refs.size() == 1);
-
- // response:
- addCommand();
- addRequestSequence();
- addSuccess(true);
- addRunning();
- addBody(collector->lookupRef(refs.first()));
- addRefs();
+ if (debugger->state() == QV4::Debugging::Debugger::Paused) {
+ QJsonObject arguments = req.value(QStringLiteral("arguments")).toObject();
+ QString expression = arguments.value(QStringLiteral("expression")).toString();
+ const int frame = arguments.value(QStringLiteral("frame")).toInt(0);
+
+ QV4DataCollector *collector = debugService->collector();
+ RefHolder holder(collector, debugService->refs());
+ ExpressionEvalJob job(debugger->engine(), frame, expression, collector);
+ debugger->runInEngine(&job);
+ if (job.hasExeption()) {
+ createErrorResponse(job.exceptionMessage());
+ } else {
+ addCommand();
+ addRequestSequence();
+ addSuccess(true);
+ addRunning();
+ addBody(collector->lookupRef(debugService->refs()->last()));
+ addRefs();
+ }
+ } else {
+ createErrorResponse(QStringLiteral("Debugger has to be paused for evaluate to work."));
+ }
}
};
} // anonymous namespace
return theCollector.data();
}
+QV4DataCollector::Refs *QV4DebugServiceImpl::refs()
+{
+ return &collectedRefs;
+}
+
void QV4DebugServiceImpl::selectFrame(int frameNr)
{
theSelectedFrame = frameNr;
: engine(engine)
, frameNr(frameNr)
, script(script)
+ , resultIsException(false)
{}
void Debugger::JavaScriptJob::run()
QV4::ScopedValue result(scope);
if (!scope.engine->hasException)
result = script.run();
- if (scope.engine->hasException)
+ if (scope.engine->hasException) {
result = scope.engine->catchException();
+ resultIsException = true;
+ }
handleResult(result);
}
+bool Debugger::JavaScriptJob::hasExeption() const
+{
+ return resultIsException;
+}
+
class EvalJob: public Debugger::JavaScriptJob
{
bool result;