Qt 4.8
qscriptdebuggerbackend.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtSCriptTools module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
44 #include "qscriptdebuggeragent_p.h"
46 #include "qscriptdebuggerevent_p.h"
47 #include "qscriptdebuggervalue_p.h"
48 #include "qscriptscriptdata_p.h"
51 
52 #include <QtScript/qscriptengine.h>
53 #include <QtScript/qscriptcontextinfo.h>
54 #include <QtScript/qscriptvalueiterator.h>
55 
56 #include <QtCore/qcoreapplication.h>
57 #include <QtCore/qdebug.h>
58 
61 
63 
117 // helper class that's used to handle our custom Qt events
119 {
120 public:
122  QObject *parent = 0)
123  : QObject(parent), m_backend(backend) {}
125 
126  bool event(QEvent *e)
127  {
128  return m_backend->event(e);
129  }
130 
131 private:
133 };
134 
135 
137  : agent(0), commandExecutor(0),
138  pendingEvaluateContextIndex(-1), pendingEvaluateLineNumber(-1),
139  ignoreExceptions(false),
140  nextScriptValueIteratorId(0), nextScriptObjectSnapshotId(0),
141  eventReceiver(0),
142  q_ptr(0) // q_ptr will be set later by QScriptDebuggerBackend constructor
143 {
144 }
145 
147 {
148  if (agent)
150  delete commandExecutor;
151  delete eventReceiver;
154 }
155 
157 {
158  if (!eventReceiver) {
161  }
163 }
164 
166 {
167  if (e->type() == QEvent::User+1) {
169  q_func()->event(de->event());
170  return true;
171  }
172  return false;
173 }
174 
176 {
177  // Since agents are owned by the script engine, this in practice means
178  // that the engine has been destroyed. Invalidate our pointer so we
179  // don't crash later.
180  if (agent == ag)
181  agent = 0;
182 }
183 
189  int lineNumber,
190  int columnNumber,
191  const QScriptValue &result)
192 {
195  scriptId, lineNumber, columnNumber);
196  e.setFileName(agent->scriptData(scriptId).fileName());
197  QScriptDebuggerValue value(result);
198  e.setScriptValue(value);
199  if (!result.isUndefined())
200  e.setMessage(result.toString()); // for convenience -- we always need it
201  q->event(e);
202 }
203 
209  int lineNumber,
210  int columnNumber)
211 {
214  scriptId, lineNumber, columnNumber);
215  e.setFileName(agent->scriptData(scriptId).fileName());
216  q->event(e);
217 }
218 
223  int lineNumber,
224  int columnNumber)
225 {
228  scriptId, lineNumber, columnNumber);
229  e.setFileName(agent->scriptData(scriptId).fileName());
230  q->event(e);
231 }
232 
237  int lineNumber,
238  int columnNumber,
239  int breakpointId)
240 {
243  scriptId, lineNumber, columnNumber);
244  e.setFileName(agent->scriptData(scriptId).fileName());
245  e.setBreakpointId(breakpointId);
246  q->event(e);
247 }
248 
254  const QScriptValue &exception,
255  bool hasHandler)
256 {
258  if (ignoreExceptions) {
259  // don't care (it's caught by us)
260  return;
261  }
263  e.setScriptId(scriptId);
264  e.setFileName(agent->scriptData(scriptId).fileName());
265  e.setMessage(exception.toString());
266  e.setHasExceptionHandler(hasHandler);
267  int lineNumber = -1;
269  if (exception.property(QLatin1String("lineNumber")).isNumber())
270  lineNumber = exception.property(QLatin1String("lineNumber")).toInt32();
271  if (exception.property(QLatin1String("fileName")).isString())
272  fileName = exception.property(QLatin1String("fileName")).toString();
273  if (lineNumber == -1) {
274  QScriptContextInfo info(q->engine()->currentContext());
275  lineNumber = info.lineNumber();
276  fileName = info.fileName();
277  }
278  if (lineNumber != -1)
279  e.setLineNumber(lineNumber);
280  if (!fileName.isEmpty())
281  e.setFileName(fileName);
282  QScriptDebuggerValue value(exception);
283  e.setScriptValue(value);
284  q->event(e);
285 }
286 
288  QScriptEngine *engine)
289 {
290  QScriptValue data = context->callee().data();
292  if (!self)
293  return engine->undefinedValue();
294  QString str;
295  for (int i = 0; i < context->argumentCount(); ++i) {
296  if (i > 0)
297  str.append(QLatin1Char(' '));
298  str.append(context->argument(i).toString());
299  }
301  e.setMessage(str);
302  self->q_func()->event(e);
303  return engine->undefinedValue();
304 }
305 
307  QScriptEngine *engine)
308 {
309  QScriptValue arg = context->argument(0);
310  if (arg.toBoolean())
311  return arg;
313  QString msg;
314  QString fileName = info.fileName();
315  if (fileName.isEmpty())
316  fileName = QString::fromLatin1("<anonymous script, id=%0>").arg(info.scriptId());
317  msg.append(fileName);
318  msg.append(QLatin1Char(':'));
319  msg.append(QString::number(info.lineNumber()));
320  msg.append(QString::fromLatin1(": Assertion failed"));
321  for (int i = 1; i < context->argumentCount(); ++i) {
322  if (i == 1)
323  msg.append(QLatin1Char(':'));
324  msg.append(QLatin1Char(' '));
325  msg.append(context->argument(i).toString());
326  }
327  QScriptValue err = context->throwError(msg);
328  err.setProperty(QString::fromLatin1("name"), QScriptValue(engine, QString::fromLatin1("AssertionError")));
329  return err;
330 }
331 
333  QScriptEngine *engine)
334 {
336  QString fn = info.fileName();
337  if (fn.isEmpty())
338  return engine->undefinedValue();
339  return QScriptValue(engine, fn);
340 }
341 
343  QScriptEngine *engine)
344 {
346  return QScriptValue(engine, info.lineNumber());
347 }
348 
354  qint64 scriptId, int lineNumber, int columnNumber)
355 {
358  scriptId, lineNumber, columnNumber);
359  e.setFileName(agent->scriptData(scriptId).fileName());
360  q->event(e);
361 }
362 
364  qint64 scriptId, int lineNumber, int columnNumber,
365  const QScriptValue &value)
366 {
369  scriptId, lineNumber, columnNumber);
370  e.setFileName(agent->scriptData(scriptId).fileName());
372  q->event(e);
373 }
374 
379  : d_ptr(new QScriptDebuggerBackendPrivate)
380 {
381  d_ptr->q_ptr = this;
382 }
383 
388 {
389  detach();
390 }
391 
396  : d_ptr(&dd)
397 {
398  d_ptr->q_ptr = this;
399 }
400 
411 {
413  detach();
414  d->agent = new QScriptDebuggerAgent(d, engine);
415  QScriptValue global = engine->globalObject();
416  d->origTraceFunction = global.property(QString::fromLatin1("print"));
417  global.setProperty(QString::fromLatin1("print"), traceFunction());
418 // global.setProperty(QString::fromLatin1("qAssert"), assertFunction());
419  d->origFileNameFunction = global.property(QString::fromLatin1("__FILE__"));
420  global.setProperty(QString::fromLatin1("__FILE__"), fileNameFunction(),
422  d->origLineNumberFunction = global.property(QString::fromLatin1("__LINE__"));
423  global.setProperty(QString::fromLatin1("__LINE__"), lineNumberFunction(),
425  engine->setAgent(d->agent);
426 }
427 
436 {
438  if (d->agent) {
439  QScriptEngine *eng = d->agent->engine();
440  if (eng && eng->agent() == d->agent) {
441  eng->setAgent(0);
442  QScriptValue global = eng->globalObject();
443  global.setProperty(QString::fromLatin1("print"), d->origTraceFunction);
444  d->origTraceFunction = QScriptValue();
445 // global.setProperty(QString::fromLatin1("qAssert"), QScriptValue());
446  global.setProperty(QString::fromLatin1("__FILE__"), QScriptValue(),
448  global.setProperty(QString::fromLatin1("__FILE__"), d->origFileNameFunction);
449  d->origFileNameFunction = QScriptValue();
450  global.setProperty(QString::fromLatin1("__LINE__"), QScriptValue(),
452  global.setProperty(QString::fromLatin1("__LINE__"), d->origLineNumberFunction);
453  d->origLineNumberFunction = QScriptValue();
454  d->agent->nullifyBackendPointer();
455  d->agent = 0; // agent is owned by engine
456  }
457  }
458 
459  d->pendingEvaluateLineNumber = -1;
460  d->ignoreExceptions = false;
461  d->nextScriptValueIteratorId = 0;
462  qDeleteAll(d->scriptValueIterators);
463  d->scriptValueIterators.clear();
464  qDeleteAll(d->scriptObjectSnapshots);
465  d->scriptObjectSnapshots.clear();
466 }
467 
475 {
477  if (!d->agent)
478  return 0;
479  return d->agent->engine();
480 }
481 
487 {
489  if (d->agent) {
490  d->agent->enterStepIntoMode(count);
491  resume();
492  }
493 }
494 
500 {
502  if (d->agent) {
503  d->agent->enterStepOverMode(count);
504  resume();
505  }
506 }
507 
513 {
515  if (d->agent) {
516  d->agent->enterStepOutMode();
517  resume();
518  }
519 }
520 
528 {
530  if (d->agent) {
531  d->agent->enterContinueMode();
532  resume();
533  }
534 }
535 
541 {
543  if (d->agent)
544  d->agent->enterInterruptMode();
545 }
546 
553 {
555  if (d->agent) {
556  d->agent->enterRunToLocationMode(fileName, lineNumber);
557  resume();
558  }
559 }
560 
566 void QScriptDebuggerBackend::runToLocation(qint64 scriptId, int lineNumber)
567 {
569  if (d->agent) {
570  d->agent->enterRunToLocationMode(scriptId, lineNumber);
571  resume();
572  }
573 }
574 
575 void QScriptDebuggerBackend::returnToCaller(int contextIndex, const QScriptValue &value)
576 {
578  if (d->agent) {
579  d->agent->enterReturnByForceMode(contextIndex, value);
580  resume();
581  }
582 }
583 
588 void QScriptDebuggerBackend::evaluate(int contextIndex, const QString &program,
589  const QString &fileName, int lineNumber)
590 {
592  d->pendingEvaluateContextIndex = contextIndex;
593  d->pendingEvaluateProgram = program;
594  d->pendingEvaluateFileName = fileName;
595  d->pendingEvaluateLineNumber = lineNumber;
596  if (!engine()->isEvaluating())
597  doPendingEvaluate(/*postEvent=*/true);
598  else
599  resume();
600 }
601 
606 {
608  QString program = d->pendingEvaluateProgram;
609  if (program.isEmpty())
610  return;
611  int contextIndex = d->pendingEvaluateContextIndex;
612  QScriptContext *ctx = context(contextIndex);
613  Q_ASSERT(ctx != 0);
614  QString fileName = d->pendingEvaluateFileName;
615  int lineNumber = d->pendingEvaluateLineNumber;
616  d->pendingEvaluateProgram = QString();
617  d->pendingEvaluateFileName = QString();
618  d->pendingEvaluateLineNumber = -1;
619  d->pendingEvaluateContextIndex = -1;
620 
621  // push a new context and initialize its scope chain etc.
622  {
623  QScriptContext *evalContext = engine()->pushContext();
624  QScriptValueList scopeChain = ctx->scopeChain();
625  if (scopeChain.isEmpty())
626  scopeChain.append(engine()->globalObject());
627  while (!scopeChain.isEmpty())
628  evalContext->pushScope(scopeChain.takeLast());
629  evalContext->setActivationObject(ctx->activationObject());
630  evalContext->setThisObject(ctx->thisObject());
631  }
632 
633  d->agent->enterContinueMode();
634  // set a flag so that any exception that happens in
635  // the evaluate() is not sent to the debugger
636  d->ignoreExceptions = true;
637  bool hadException = engine()->hasUncaughtException();
638  QScriptValue ret = engine()->evaluate(program, fileName, lineNumber);
639  d->ignoreExceptions = false;
640  if (!hadException && engine()->hasUncaughtException())
641  engine()->clearExceptions();
642  engine()->popContext();
643 
644  QScriptDebuggerValue retret(ret);
646  e.setScriptValue(retret);
647  if (!ret.isUndefined())
648  e.setMessage(ret.toString()); // for convenience -- we always need it
649 
650  e.setNestedEvaluate(engine()->isEvaluating());
651 
652  if (postEvent) {
654  d->postEvent(de);
655  } else {
656  event(e);
657  }
658 }
659 
670 {
672  if (!d->agent)
673  return -1;
674  if (!data.isValid())
675  return -1;
676  return d->agent->setBreakpoint(data);
677 }
678 
687 {
689  if (!d->agent)
690  return false;
691  return d->agent->deleteBreakpoint(id);
692 }
693 
698 {
700  if (d->agent)
701  d->agent->deleteAllBreakpoints();
702 }
703 
709 {
711  if (!d->agent)
712  return QScriptBreakpointData();
713  return d->agent->breakpointData(id);
714 }
715 
721 {
723  if (d->agent)
724  return d->agent->setBreakpointData(id, data);
725  return false;
726 }
727 
734 {
736  if (!d->agent)
737  return QScriptBreakpointMap();
738  return d->agent->breakpoints();
739 }
740 
747 {
749  if (!d->agent)
750  return QScriptScriptMap();
751  return d->agent->scripts();
752 }
753 
760 {
762  if (!d->agent)
763  return QScriptScriptData();
764  return d->agent->scriptData(id);
765 }
766 
773 {
775  if (d->agent)
776  d->agent->scriptsCheckpoint();
777 }
778 
789 {
791  if (!d->agent)
793  return d->agent->scriptsDelta();
794 }
795 
797 {
799  if (!d->agent)
800  return -1;
801  return d->agent->resolveScript(fileName);
802 }
803 
808 {
809  if (!engine())
810  return 0;
811  return contextIds().count();
812 }
813 
818 {
819  if (index < 0)
820  return 0;
822  while (ctx) {
823  if (index == 0)
824  return ctx;
825  ctx = ctx->parentContext();
826  --index;
827  }
828  return 0;
829 }
830 
835 {
836  if (!engine())
837  return QStringList();
838  return engine()->currentContext()->backtrace();
839 }
840 
842 {
844  if (!d->agent)
845  return QList<qint64>();
846  return d->agent->contextIds();
847 }
848 
850 {
852  if (!d->agent)
853  return QScriptContextsDelta();
854  return d->agent->contextsCheckpoint();
855 }
856 
858 {
860  int id = d->nextScriptObjectSnapshotId;
861  ++d->nextScriptObjectSnapshotId;
862  d->scriptObjectSnapshots[id] = new QScriptObjectSnapshot();
863  return id;
864 }
865 
867 {
869  return d->scriptObjectSnapshots.value(id);
870 }
871 
873 {
875  QScriptObjectSnapshot *snap = d->scriptObjectSnapshots.take(id);
876  delete snap;
877 }
878 
880 {
882  int id = d->nextScriptValueIteratorId;
883  ++d->nextScriptValueIteratorId;
884  d->scriptValueIterators[id] = new QScriptValueIterator(object);
885  return id;
886 }
887 
889 {
891  return d->scriptValueIterators.value(id);
892 }
893 
895 {
897  QScriptValueIterator *it = d->scriptValueIterators.take(id);
898  delete it;
899 }
900 
902 {
904  return d->ignoreExceptions;
905 }
906 
908 {
910  d->ignoreExceptions = ignore;
911 }
912 
919 {
921  if (!engine())
922  return QScriptValue();
924  fun.setData(qScriptValueFromValue(engine(), const_cast<QScriptDebuggerBackendPrivate*>(d)));
925  return fun;
926 }
927 
929 {
930  if (!engine())
931  return QScriptValue();
933  return fun;
934 }
935 
937 {
938  if (!engine())
939  return QScriptValue();
941  return fun;
942 }
943 
945 {
946  if (!engine())
947  return QScriptValue();
949  return fun;
950 }
951 
953 {
955  if (d->commandExecutor)
956  return d->commandExecutor;
959  return dd->commandExecutor;
960 }
961 
963 {
965  d->commandExecutor = executor;
966 }
967 
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
QScriptValue newFunction(FunctionSignature signature, int length=0)
Creates a QScriptValue that wraps a native (C++) function.
double d
Definition: qnumeric_p.h:62
The QScriptContext class represents a Qt Script function invocation.
bool isUndefined() const
Returns true if this QScriptValue is of the primitive type Undefined; otherwise returns false...
void stepOut()
Steps out of the current script function.
QScriptDebuggerCommandExecutor * commandExecutor() const
QScriptObjectSnapshot * scriptObjectSnapshot(int id) const
QMap< int, QScriptValueIterator * > scriptValueIterators
QScriptValue evaluate(const QString &program, const QString &fileName=QString(), int lineNumber=1)
Evaluates program, using lineNumber as the base line number, and returns the result of the evaluation...
QScriptValue property(const QString &name, const ResolveFlags &mode=ResolvePrototype) const
Returns the value of this QScriptValue&#39;s property with the given name, using the given mode to resolv...
virtual void forcedReturn(qint64 scriptId, int lineNumber, int columnNumber, const QScriptValue &value)
static mach_timebase_info_data_t info
T qscriptvalue_cast(const QScriptValue &)
QScriptContextsDelta contextsCheckpoint()
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QScriptScriptData scriptData(qint64 id) const
Returns the data associated with the script with the given id.
#define it(className, varName)
QScriptEngine * engine() const
Returns the QScriptEngine that this agent is associated with.
QScriptValue callee() const
Returns the callee.
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
bool event(QEvent *e)
This virtual function receives events to an object and should return true if the event e was recogniz...
QScriptValueList scopeChain() const
Returns the scope chain of this QScriptContext.
void stepInto(int count=1)
Steps into the next script statement.
QPair< QList< qint64 >, QList< qint64 > > QScriptContextsDelta
qint32 toInt32() const
Returns the signed 32-bit integer value of this QScriptValue, using the conversion rules described in...
QScriptBreakpointMap breakpoints() const
Returns this backend&#39;s breakpoints.
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
void setLineNumber(int lineNumber)
void setNestedEvaluate(bool nested)
void interruptEvaluation()
Interrupts script evaluation.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
QScriptValue globalObject() const
Returns this engine&#39;s Global Object.
static bool ignore(const char *test, const char *const *table)
Definition: qaxserver.cpp:660
void deleteAllBreakpoints()
Deletes all breakpoints.
QScriptValue traceFunction() const
Returns a trace function.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
qint64 resolveScript(const QString &fileName) const
void returnToCaller(int contextIndex, const QScriptValue &value)
void popContext()
Pops the current execution context and restores the previous one.
void runToLocation(const QString &fileName, int lineNumber)
Continues evaluation until the location defined by the given fileName and lineNumber is reached...
QScriptValueIterator * scriptValueIterator(int id) const
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QScriptValue qsassert(QScriptContext *context, QScriptEngine *engine)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QScriptValue qScriptValueFromValue(QScriptEngine *, const T &)
QScriptContext * context(int index) const
Returns the context for the frame with the given index.
#define Q_D(Class)
Definition: qglobal.h:2482
static QScriptValue fileName(QScriptContext *context, QScriptEngine *engine)
void setThisObject(const QScriptValue &thisObject)
Sets the `this&#39; object associated with this QScriptContext to be thisObject.
QScriptEngine * engine() const
Returns the script engine that this backend is attached to, or 0 if the backend is not attached to an...
void continueEvalution()
Continues script evaluation.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void setActivationObject(const QScriptValue &activation)
Sets the activation object of this QScriptContext to be the given activation.
#define Q_Q(Class)
Definition: qglobal.h:2483
QScriptValue fileNameFunction() const
int contextCount() const
Returns the number of contexts (frames).
The QScriptScriptData class holds data associated with a script.
QMap< int, QScriptBreakpointData > QScriptBreakpointMap
QScriptBreakpointData breakpointData(int id) const
Returns the data associated with the breakpoint identified by the given id.
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QScriptEngine class provides an environment for evaluating Qt Script code.
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
void evaluate(int contextIndex, const QString &program, const QString &fileName, int lineNumber)
Evaluates the given program.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static QScriptValue lineNumber(QScriptContext *context, QScriptEngine *engine)
virtual ~QScriptDebuggerBackend()
Destroys this QScriptDebuggerBackend.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
bool isString() const
Returns true if this QScriptValue is of the primitive type String; otherwise returns false...
QScriptScriptsDelta scriptsDelta() const
Returns the difference between the latest scripts checkpoint and the previous checkpoint.
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QStringList backtrace() const
Returns a human-readable backtrace of this QScriptContext.
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
void attachTo(QScriptEngine *engine)
Attaches this backend to the given engine.
void moveToThread(QThread *thread)
Changes the thread affinity for this object and its children.
Definition: qobject.cpp:1458
void agentDestroyed(QScriptDebuggerAgent *)
QScriptDebuggerBackend()
Creates a QScriptDebuggerBackend object.
__int64 qint64
Definition: qglobal.h:942
The QScriptBreakpointData class contains data associated with a breakpoint.
void setIgnoreExceptions(bool ignore)
bool toBoolean() const
Use toBool() instead.
void stepOver(int count=1)
Steps over the next script statement.
bool setBreakpointData(int id, const QScriptBreakpointData &data)
Sets the data associated with the breakpoint identified by the given id.
virtual void interrupted(qint64 scriptId, int lineNumber, int columnNumber)
The agent calls this function when evaluation has been interrupted.
QStringList backtrace() const
Returns a backtrace of the current execution.
void doPendingEvaluate(bool postEvent)
Executes the pending evaluate, if any.
static QScriptValue trace(QScriptContext *context, QScriptEngine *engine)
QScopedPointer< QScriptDebuggerBackendPrivate > d_ptr
virtual void resume()=0
This function is called when control should be returned back to the back-end, i.
#define Q_DECLARE_METATYPE(TYPE)
This macro makes the type Type known to QMetaType as long as it provides a public default constructor...
Definition: qmetatype.h:265
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
void setScriptValue(const QScriptDebuggerValue &value)
QScriptDebuggerBackendEventReceiver(QScriptDebuggerBackendPrivate *backend, QObject *parent=0)
QScriptValue data() const
Returns the internal data of this QScriptValue object.
virtual void exception(qint64 scriptId, const QScriptValue &exception, bool hasHandler)
The agent calls this function when an uncaught exception has occurred.
The QScriptDebuggerValue class represents a script value.
void setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
Sets the value of this QScriptValue&#39;s property with the given name to the given value.
The QScriptContextInfo class provides additional information about a QScriptContext.
bool isNumber() const
Returns true if this QScriptValue is of the primitive type Number; otherwise returns false...
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
virtual void breakpoint(qint64 scriptId, int lineNumber, int columnNumber, int breakpointId)
The agent calls this function when a breakpoint has been triggered.
const QScriptDebuggerEvent & event() const
QScriptScriptMap scripts() const
Returns the scripts that this backend knows about.
void detach()
Detaches this backend from the current script engine.
QString & append(QChar c)
Definition: qstring.cpp:1777
The QScriptValueIterator class provides a Java-style iterator for QScriptValue.
The QScriptDebuggerBackend class is the base class of debugger back-ends.
The QScriptDebuggerCommandExecutor applies debugger commands to a back-end.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
void scriptsCheckpoint()
Makes a checkpoint of the currently loaded scripts.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
#define ctx
Definition: qgl.cpp:6094
QScriptDebuggerCommandExecutor * commandExecutor
virtual void locationReached(qint64 scriptId, int lineNumber, int columnNumber)
The agent calls this function when it has run to a particular location.
QScriptContext * currentContext() const
Returns the current context.
void setHasExceptionHandler(bool hasHandler)
QScriptContext * pushContext()
Enters a new execution context and returns the associated QScriptContext object.
void clearExceptions()
Clears any uncaught exceptions in this engine.
quint16 index
QList< qint64 > contextIds() const
T takeLast()
Removes the last item in the list and returns it.
Definition: qlist.h:492
QScriptEngineAgent * agent() const
Returns the agent currently installed on this engine, or 0 if no agent is installed.
virtual void debuggerInvocationRequest(qint64 scriptId, int lineNumber, int columnNumber)
The agent calls this function when the engine has reached a "debugger" statement. ...
QScriptValue lineNumberFunction() const
virtual void stepped(qint64 scriptId, int lineNumber, int columnNumber, const QScriptValue &result)
The agent calls this function when it has completed a step operation.
QScriptValue activationObject() const
Returns the activation object of this QScriptContext.
QMap< int, QScriptObjectSnapshot * > scriptObjectSnapshots
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
QScriptScriptData scriptData(qint64 id) const
Returns the data for the script identified by the given id.
int newScriptValueIterator(const QScriptValue &object)
QScriptValue assertFunction() const
QThread * thread() const
Returns the thread in which the object lives.
Definition: qobject.cpp:1419
bool deleteBreakpoint(int id)
Deletes the breakpoint identified by the given id.
void setAgent(QScriptEngineAgent *agent)
Installs the given agent on this engine.
void setMessage(const QString &message)
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
void pushScope(const QScriptValue &object)
Adds the given object to the front of this context&#39;s scope chain.
void setCommandExecutor(QScriptDebuggerCommandExecutor *executor)
bool hasUncaughtException() const
Returns true if the last script evaluation resulted in an uncaught exception; otherwise returns false...
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
static QString fileName(const QString &fileUrl)
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319
virtual void event(const QScriptDebuggerEvent &event)=0
This function is called when the back-end has generated the given event.
QScriptValue argument(int index) const
Returns the function argument at the given index.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QString fileName() const
QScriptContext * parentContext() const
Returns the parent context of this QScriptContext.
QMap< qint64, QScriptScriptData > QScriptScriptMap
void setFileName(const QString &fileName)
void setData(const QScriptValue &data)
Sets the internal data of this QScriptValue object.
int setBreakpoint(const QScriptBreakpointData &data)
Sets a breakpoint defined by the given data, and returns a unique identifier for the new breakpoint...
QScriptDebuggerBackendPrivate * m_backend