Qt 4.8
Public Functions | Protected Functions | Protected Variables | List of all members
QScriptDebuggerBackend Class Referenceabstract

The QScriptDebuggerBackend class is the base class of debugger back-ends. More...

#include <qscriptdebuggerbackend_p.h>

Inheritance diagram for QScriptDebuggerBackend:
QScriptEngineDebuggerBackend

Public Functions

QScriptValue assertFunction () const
 
void attachTo (QScriptEngine *engine)
 Attaches this backend to the given engine. More...
 
QStringList backtrace () const
 Returns a backtrace of the current execution. More...
 
QScriptBreakpointData breakpointData (int id) const
 Returns the data associated with the breakpoint identified by the given id. More...
 
QScriptBreakpointMap breakpoints () const
 Returns this backend's breakpoints. More...
 
QScriptDebuggerCommandExecutorcommandExecutor () const
 
QScriptContextcontext (int index) const
 Returns the context for the frame with the given index. More...
 
int contextCount () const
 Returns the number of contexts (frames). More...
 
QList< qint64contextIds () const
 
QScriptContextsDelta contextsCheckpoint ()
 
void continueEvalution ()
 Continues script evaluation. More...
 
void deleteAllBreakpoints ()
 Deletes all breakpoints. More...
 
bool deleteBreakpoint (int id)
 Deletes the breakpoint identified by the given id. More...
 
void deleteScriptObjectSnapshot (int id)
 
void deleteScriptValueIterator (int id)
 
void detach ()
 Detaches this backend from the current script engine. More...
 
void doPendingEvaluate (bool postEvent)
 Executes the pending evaluate, if any. More...
 
QScriptEngineengine () const
 Returns the script engine that this backend is attached to, or 0 if the backend is not attached to an engine. More...
 
void evaluate (int contextIndex, const QString &program, const QString &fileName, int lineNumber)
 Evaluates the given program. More...
 
QScriptValue fileNameFunction () const
 
bool ignoreExceptions () const
 
void interruptEvaluation ()
 Interrupts script evaluation. More...
 
QScriptValue lineNumberFunction () const
 
int newScriptObjectSnapshot ()
 
int newScriptValueIterator (const QScriptValue &object)
 
 QScriptDebuggerBackend ()
 Creates a QScriptDebuggerBackend object. More...
 
qint64 resolveScript (const QString &fileName) const
 
virtual void resume ()=0
 This function is called when control should be returned back to the back-end, i. More...
 
void returnToCaller (int contextIndex, const QScriptValue &value)
 
void runToLocation (const QString &fileName, int lineNumber)
 Continues evaluation until the location defined by the given fileName and lineNumber is reached. More...
 
void runToLocation (qint64 scriptId, int lineNumber)
 Continues evaluation until the location defined by the given scriptId and lineNumber is reached. More...
 
QScriptScriptData scriptData (qint64 id) const
 Returns the data for the script identified by the given id. More...
 
QScriptObjectSnapshotscriptObjectSnapshot (int id) const
 
QScriptScriptMap scripts () const
 Returns the scripts that this backend knows about. More...
 
void scriptsCheckpoint ()
 Makes a checkpoint of the currently loaded scripts. More...
 
QScriptScriptsDelta scriptsDelta () const
 Returns the difference between the latest scripts checkpoint and the previous checkpoint. More...
 
QScriptValueIteratorscriptValueIterator (int id) const
 
int setBreakpoint (const QScriptBreakpointData &data)
 Sets a breakpoint defined by the given data, and returns a unique identifier for the new breakpoint. More...
 
bool setBreakpointData (int id, const QScriptBreakpointData &data)
 Sets the data associated with the breakpoint identified by the given id. More...
 
void setCommandExecutor (QScriptDebuggerCommandExecutor *executor)
 
void setIgnoreExceptions (bool ignore)
 
void stepInto (int count=1)
 Steps into the next script statement. More...
 
void stepOut ()
 Steps out of the current script function. More...
 
void stepOver (int count=1)
 Steps over the next script statement. More...
 
QScriptValue traceFunction () const
 Returns a trace function. More...
 
virtual ~QScriptDebuggerBackend ()
 Destroys this QScriptDebuggerBackend. More...
 

Protected Functions

virtual void event (const QScriptDebuggerEvent &event)=0
 This function is called when the back-end has generated the given event. More...
 
 QScriptDebuggerBackend (QScriptDebuggerBackendPrivate &dd)
 

Protected Variables

QScopedPointer< QScriptDebuggerBackendPrivated_ptr
 

Detailed Description

The QScriptDebuggerBackend class is the base class of debugger back-ends.

Since
4.5
Warning
This function is not part of the public interface.

QScriptDebuggerBackend builds on the QScriptDebuggerAgent class.

This class is usually used together with the QScriptDebuggerFrontend class, in order to form a (front-end, back-end) pair.

Call attachTo() to attach to a QScriptEngine object. Call detach() to detach from the current engine.

Call stepInto() to step into the next script statement; call stepOver() to step over the next script statement; and call stepOut() to step out of the currently executing script function. An event() will be generated when the stepping is completed.

Call runToLocation() to execute script statements until a certain location has been reached. An event() will be generated when the location has been reached.

Call interruptEvaluation() to request that evaluation should be interrupted. An event() will be generated upon the next script statement that is reached.

Call continueEvalution() to allow script evaluation to continue.

Call setBreakpoint() to set a breakpoint. A breakpoint event() will be generated when a breakpoint is hit. Call deleteBreakpoint() to delete a breakpoint. Call modifyBreakpoint() to change the state of an existing breakpoint.

Call contextCount() to obtain the number of active contexts (frames). Call context() to obtain a pointer to a QScriptContext.

Subclassing

When subclassing QScriptDebuggerBackend, you must implement the pure virtual event() function. This function typically forwards the event to a QScriptDebuggerFrontend object. For most type of events, event() should block until the back-end is instructed to resume execution (e.g. until continueEvalution() is called). You must implement resume(), which is responsible for making event() return.

See also
QScriptDebuggerFrontend, QScriptDebuggerEvent

Definition at line 78 of file qscriptdebuggerbackend_p.h.

Constructors and Destructors

◆ QScriptDebuggerBackend() [1/2]

QScriptDebuggerBackend::QScriptDebuggerBackend ( )

Creates a QScriptDebuggerBackend object.

Definition at line 378 of file qscriptdebuggerbackend.cpp.

380 {
381  d_ptr->q_ptr = this;
382 }
QScopedPointer< QScriptDebuggerBackendPrivate > d_ptr

◆ ~QScriptDebuggerBackend()

QScriptDebuggerBackend::~QScriptDebuggerBackend ( )
virtual

Destroys this QScriptDebuggerBackend.

Definition at line 387 of file qscriptdebuggerbackend.cpp.

388 {
389  detach();
390 }
void detach()
Detaches this backend from the current script engine.

◆ QScriptDebuggerBackend() [2/2]

QScriptDebuggerBackend::QScriptDebuggerBackend ( QScriptDebuggerBackendPrivate dd)
protected
Warning
This function is not part of the public interface.

Definition at line 395 of file qscriptdebuggerbackend.cpp.

396  : d_ptr(&dd)
397 {
398  d_ptr->q_ptr = this;
399 }
QScopedPointer< QScriptDebuggerBackendPrivate > d_ptr

Functions

◆ assertFunction()

QScriptValue QScriptDebuggerBackend::assertFunction ( ) const

Definition at line 928 of file qscriptdebuggerbackend.cpp.

929 {
930  if (!engine())
931  return QScriptValue();
933  return fun;
934 }
QScriptValue newFunction(FunctionSignature signature, int length=0)
Creates a QScriptValue that wraps a native (C++) function.
static QScriptValue qsassert(QScriptContext *context, QScriptEngine *engine)
QScriptEngine * engine() const
Returns the script engine that this backend is attached to, or 0 if the backend is not attached to an...
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ attachTo()

void QScriptDebuggerBackend::attachTo ( QScriptEngine engine)

Attaches this backend to the given engine.

The backend automatically detaches from the old engine, if any.

This function installs its own agent on the engine using QScriptEngine::setAgent(); any existing agent will be replaced.

See also
detach(). engine()

Definition at line 410 of file qscriptdebuggerbackend.cpp.

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 }
double d
Definition: qnumeric_p.h:62
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...
QScriptValue globalObject() const
Returns this engine&#39;s Global Object.
QScriptValue traceFunction() const
Returns a trace function.
#define Q_D(Class)
Definition: qglobal.h:2482
QScriptValue fileNameFunction() const
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
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.
void detach()
Detaches this backend from the current script engine.
The QScriptDebuggerBackend class is the base class of debugger back-ends.
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
QScriptValue lineNumberFunction() const
void setAgent(QScriptEngineAgent *agent)
Installs the given agent on this engine.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ backtrace()

QStringList QScriptDebuggerBackend::backtrace ( ) const

Returns a backtrace of the current execution.

Definition at line 834 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

835 {
836  if (!engine())
837  return QStringList();
838  return engine()->currentContext()->backtrace();
839 }
QScriptEngine * engine() const
Returns the script engine that this backend is attached to, or 0 if the backend is not attached to an...
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QStringList backtrace() const
Returns a human-readable backtrace of this QScriptContext.
QScriptContext * currentContext() const
Returns the current context.

◆ breakpointData()

QScriptBreakpointData QScriptDebuggerBackend::breakpointData ( int  id) const

Returns the data associated with the breakpoint identified by the given id.

Definition at line 708 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

709 {
711  if (!d->agent)
712  return QScriptBreakpointData();
713  return d->agent->breakpointData(id);
714 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptBreakpointData class contains data associated with a breakpoint.
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ breakpoints()

QScriptBreakpointMap QScriptDebuggerBackend::breakpoints ( ) const

Returns this backend's breakpoints.

See also
setBreakpoint()

Definition at line 733 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

734 {
736  if (!d->agent)
737  return QScriptBreakpointMap();
738  return d->agent->breakpoints();
739 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QMap< int, QScriptBreakpointData > QScriptBreakpointMap
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ commandExecutor()

QScriptDebuggerCommandExecutor * QScriptDebuggerBackend::commandExecutor ( ) const

Definition at line 952 of file qscriptdebuggerbackend.cpp.

953 {
955  if (d->commandExecutor)
956  return d->commandExecutor;
959  return dd->commandExecutor;
960 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.
The QScriptDebuggerCommandExecutor applies debugger commands to a back-end.
QScriptDebuggerCommandExecutor * commandExecutor

◆ context()

QScriptContext * QScriptDebuggerBackend::context ( int  index) const

Returns the context for the frame with the given index.

Definition at line 817 of file qscriptdebuggerbackend.cpp.

Referenced by doPendingEvaluate(), and QScriptDebuggerCommandExecutor::execute().

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 }
The QScriptContext class represents a Qt Script function invocation.
QScriptEngine * engine() const
Returns the script engine that this backend is attached to, or 0 if the backend is not attached to an...
#define ctx
Definition: qgl.cpp:6094
QScriptContext * currentContext() const
Returns the current context.
quint16 index
QScriptContext * parentContext() const
Returns the parent context of this QScriptContext.

◆ contextCount()

int QScriptDebuggerBackend::contextCount ( ) const

Returns the number of contexts (frames).

Definition at line 807 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

808 {
809  if (!engine())
810  return 0;
811  return contextIds().count();
812 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QScriptEngine * engine() const
Returns the script engine that this backend is attached to, or 0 if the backend is not attached to an...
QList< qint64 > contextIds() const

◆ contextIds()

QList< qint64 > QScriptDebuggerBackend::contextIds ( ) const

Definition at line 841 of file qscriptdebuggerbackend.cpp.

Referenced by contextCount(), and QScriptDebuggerCommandExecutor::execute().

842 {
844  if (!d->agent)
845  return QList<qint64>();
846  return d->agent->contextIds();
847 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ contextsCheckpoint()

QScriptContextsDelta QScriptDebuggerBackend::contextsCheckpoint ( )

Definition at line 849 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

850 {
852  if (!d->agent)
853  return QScriptContextsDelta();
854  return d->agent->contextsCheckpoint();
855 }
double d
Definition: qnumeric_p.h:62
QPair< QList< qint64 >, QList< qint64 > > QScriptContextsDelta
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ continueEvalution()

void QScriptDebuggerBackend::continueEvalution ( )

Continues script evaluation.

Evaluation will proceed without interruption until either 1) an uncaught exception occurs, 2) a breakpoint is triggered, or 3) interruptEvaluation() is called. In each case, a proper event() will be generated.

Definition at line 527 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

528 {
530  if (d->agent) {
531  d->agent->enterContinueMode();
532  resume();
533  }
534 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void resume()=0
This function is called when control should be returned back to the back-end, i.
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ deleteAllBreakpoints()

void QScriptDebuggerBackend::deleteAllBreakpoints ( )

Deletes all breakpoints.

Definition at line 697 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

698 {
700  if (d->agent)
701  d->agent->deleteAllBreakpoints();
702 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ deleteBreakpoint()

bool QScriptDebuggerBackend::deleteBreakpoint ( int  id)

Deletes the breakpoint identified by the given id.

Returns true if the breakpoint was deleted (i.e. the id was valid), otherwise returns false.

See also
setBreakpoint()

Definition at line 686 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

687 {
689  if (!d->agent)
690  return false;
691  return d->agent->deleteBreakpoint(id);
692 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ deleteScriptObjectSnapshot()

void QScriptDebuggerBackend::deleteScriptObjectSnapshot ( int  id)

Definition at line 872 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

873 {
875  QScriptObjectSnapshot *snap = d->scriptObjectSnapshots.take(id);
876  delete snap;
877 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ deleteScriptValueIterator()

void QScriptDebuggerBackend::deleteScriptValueIterator ( int  id)

Definition at line 894 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

895 {
897  QScriptValueIterator *it = d->scriptValueIterators.take(id);
898  delete it;
899 }
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptValueIterator class provides a Java-style iterator for QScriptValue.
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ detach()

void QScriptDebuggerBackend::detach ( )

Detaches this backend from the current script engine.

The backend's state (including breakpoints and information on loaded scripts) will be invalidated.

See also
attach()

Definition at line 435 of file qscriptdebuggerbackend.cpp.

Referenced by attachTo(), and ~QScriptDebuggerBackend().

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 }
double d
Definition: qnumeric_p.h:62
QScriptValue globalObject() const
Returns this engine&#39;s Global Object.
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptEngine class provides an environment for evaluating Qt Script code.
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 QScriptDebuggerBackend class is the base class of debugger back-ends.
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
QScriptEngineAgent * agent() const
Returns the agent currently installed on this engine, or 0 if no agent is installed.
void setAgent(QScriptEngineAgent *agent)
Installs the given agent on this engine.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

◆ doPendingEvaluate()

void QScriptDebuggerBackend::doPendingEvaluate ( bool  postEvent)

Executes the pending evaluate, if any.

Definition at line 605 of file qscriptdebuggerbackend.cpp.

Referenced by evaluate(), and QScriptEngineDebuggerBackend::event().

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 }
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...
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...
QScriptValueList scopeChain() const
Returns the scope chain of this QScriptContext.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
void popContext()
Pops the current execution context and restores the previous one.
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QScriptContext * context(int index) const
Returns the context for the frame with the given index.
#define Q_D(Class)
Definition: qglobal.h:2482
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...
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.
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
The QScriptDebuggerValue class represents a script value.
The QScriptDebuggerBackend class is the base class of debugger back-ends.
#define ctx
Definition: qgl.cpp:6094
QScriptContext * pushContext()
Enters a new execution context and returns the associated QScriptContext object.
void clearExceptions()
Clears any uncaught exceptions in this engine.
T takeLast()
Removes the last item in the list and returns it.
Definition: qlist.h:492
QScriptValue activationObject() const
Returns the activation object of this QScriptContext.
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.
bool hasUncaughtException() const
Returns true if the last script evaluation resulted in an uncaught exception; otherwise returns false...
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
static QString fileName(const QString &fileUrl)
virtual void event(const QScriptDebuggerEvent &event)=0
This function is called when the back-end has generated the given event.

◆ engine()

QScriptEngine * QScriptDebuggerBackend::engine ( ) const

Returns the script engine that this backend is attached to, or 0 if the backend is not attached to an engine.

See also
attachTo()

Definition at line 474 of file qscriptdebuggerbackend.cpp.

Referenced by assertFunction(), backtrace(), context(), contextCount(), doPendingEvaluate(), evaluate(), QScriptDebuggerCommandExecutor::execute(), fileNameFunction(), lineNumberFunction(), and traceFunction().

475 {
477  if (!d->agent)
478  return 0;
479  return d->agent->engine();
480 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ evaluate()

void QScriptDebuggerBackend::evaluate ( int  contextIndex,
const QString program,
const QString fileName,
int  lineNumber 
)

Evaluates the given program.

When evaluation is complete, an event() is generated.

Definition at line 588 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

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 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QScriptEngine * engine() const
Returns the script engine that this backend is attached to, or 0 if the backend is not attached to an...
void doPendingEvaluate(bool postEvent)
Executes the pending evaluate, if any.
virtual void resume()=0
This function is called when control should be returned back to the back-end, i.
The QScriptDebuggerBackend class is the base class of debugger back-ends.
static QString fileName(const QString &fileUrl)

◆ event()

void QScriptDebuggerBackend::event ( const QScriptDebuggerEvent event)
protectedpure virtual

This function is called when the back-end has generated the given event.

Subclasses must reimplement this function to handle the event. Typically the event is forwarded to a QScriptDebuggerFrontend, which will in turn forward it to its QScriptDebuggerClient. The client may then query the front-end for information about the execution state, and call e.g. continueEvalution() to resume execution. This function should block until resume() is called.

See also
resume()

Implemented in QScriptEngineDebuggerBackend.

Referenced by doPendingEvaluate().

◆ fileNameFunction()

QScriptValue QScriptDebuggerBackend::fileNameFunction ( ) const

Definition at line 936 of file qscriptdebuggerbackend.cpp.

Referenced by attachTo().

937 {
938  if (!engine())
939  return QScriptValue();
941  return fun;
942 }
QScriptValue newFunction(FunctionSignature signature, int length=0)
Creates a QScriptValue that wraps a native (C++) function.
static QScriptValue fileName(QScriptContext *context, QScriptEngine *engine)
QScriptEngine * engine() const
Returns the script engine that this backend is attached to, or 0 if the backend is not attached to an...
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ ignoreExceptions()

bool QScriptDebuggerBackend::ignoreExceptions ( ) const

Definition at line 901 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

902 {
904  return d->ignoreExceptions;
905 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ interruptEvaluation()

void QScriptDebuggerBackend::interruptEvaluation ( )

Interrupts script evaluation.

When the next script statement is reached, an event() will be generated.

Definition at line 540 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

541 {
543  if (d->agent)
544  d->agent->enterInterruptMode();
545 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ lineNumberFunction()

QScriptValue QScriptDebuggerBackend::lineNumberFunction ( ) const

Definition at line 944 of file qscriptdebuggerbackend.cpp.

Referenced by attachTo().

945 {
946  if (!engine())
947  return QScriptValue();
949  return fun;
950 }
QScriptValue newFunction(FunctionSignature signature, int length=0)
Creates a QScriptValue that wraps a native (C++) function.
QScriptEngine * engine() const
Returns the script engine that this backend is attached to, or 0 if the backend is not attached to an...
static QScriptValue lineNumber(QScriptContext *context, QScriptEngine *engine)
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ newScriptObjectSnapshot()

int QScriptDebuggerBackend::newScriptObjectSnapshot ( )

Definition at line 857 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

858 {
860  int id = d->nextScriptObjectSnapshotId;
861  ++d->nextScriptObjectSnapshotId;
862  d->scriptObjectSnapshots[id] = new QScriptObjectSnapshot();
863  return id;
864 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ newScriptValueIterator()

int QScriptDebuggerBackend::newScriptValueIterator ( const QScriptValue object)

Definition at line 879 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

880 {
882  int id = d->nextScriptValueIteratorId;
883  ++d->nextScriptValueIteratorId;
884  d->scriptValueIterators[id] = new QScriptValueIterator(object);
885  return id;
886 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptValueIterator class provides a Java-style iterator for QScriptValue.
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ resolveScript()

qint64 QScriptDebuggerBackend::resolveScript ( const QString fileName) const

Definition at line 796 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

797 {
799  if (!d->agent)
800  return -1;
801  return d->agent->resolveScript(fileName);
802 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ resume()

void QScriptDebuggerBackend::resume ( )
pure virtual

This function is called when control should be returned back to the back-end, i.

e. when script evaluation should be resumed after an event has been delivered.

Subclasses must reimplement this function to make event() return.

See also
event()

Implemented in QScriptEngineDebuggerBackend.

Referenced by continueEvalution(), evaluate(), QScriptDebuggerCommandExecutor::execute(), returnToCaller(), runToLocation(), stepInto(), stepOut(), and stepOver().

◆ returnToCaller()

void QScriptDebuggerBackend::returnToCaller ( int  contextIndex,
const QScriptValue value 
)

Definition at line 575 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

576 {
578  if (d->agent) {
579  d->agent->enterReturnByForceMode(contextIndex, value);
580  resume();
581  }
582 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void resume()=0
This function is called when control should be returned back to the back-end, i.
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ runToLocation() [1/2]

void QScriptDebuggerBackend::runToLocation ( const QString fileName,
int  lineNumber 
)

Continues evaluation until the location defined by the given fileName and lineNumber is reached.

When the location is reached, an event() will be generated.

Definition at line 552 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

553 {
555  if (d->agent) {
556  d->agent->enterRunToLocationMode(fileName, lineNumber);
557  resume();
558  }
559 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void resume()=0
This function is called when control should be returned back to the back-end, i.
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ runToLocation() [2/2]

void QScriptDebuggerBackend::runToLocation ( qint64  scriptId,
int  lineNumber 
)

Continues evaluation until the location defined by the given scriptId and lineNumber is reached.

When the location is reached, an event() will be generated.

Definition at line 566 of file qscriptdebuggerbackend.cpp.

567 {
569  if (d->agent) {
570  d->agent->enterRunToLocationMode(scriptId, lineNumber);
571  resume();
572  }
573 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void resume()=0
This function is called when control should be returned back to the back-end, i.
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ scriptData()

QScriptScriptData QScriptDebuggerBackend::scriptData ( qint64  id) const

Returns the data for the script identified by the given id.

See also
scripts()

Definition at line 759 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

760 {
762  if (!d->agent)
763  return QScriptScriptData();
764  return d->agent->scriptData(id);
765 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptScriptData class holds data associated with a script.
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ scriptObjectSnapshot()

QScriptObjectSnapshot * QScriptDebuggerBackend::scriptObjectSnapshot ( int  id) const

Definition at line 866 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

867 {
869  return d->scriptObjectSnapshots.value(id);
870 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ scripts()

QScriptScriptMap QScriptDebuggerBackend::scripts ( ) const

Returns the scripts that this backend knows about.

See also
scriptData()

Definition at line 746 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

747 {
749  if (!d->agent)
750  return QScriptScriptMap();
751  return d->agent->scripts();
752 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.
QMap< qint64, QScriptScriptData > QScriptScriptMap

◆ scriptsCheckpoint()

void QScriptDebuggerBackend::scriptsCheckpoint ( )

Makes a checkpoint of the currently loaded scripts.

See also
scriptsDelta()

Definition at line 772 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

773 {
775  if (d->agent)
776  d->agent->scriptsCheckpoint();
777 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ scriptsDelta()

QScriptScriptsDelta QScriptDebuggerBackend::scriptsDelta ( ) const

Returns the difference between the latest scripts checkpoint and the previous checkpoint.

The first item in the pair is a list containing the identifiers of the scripts that were added. The second item in the pair is a list containing the identifiers of the scripts that were removed.

See also
scriptsCheckpoint()

Definition at line 788 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

789 {
791  if (!d->agent)
793  return d->agent->scriptsDelta();
794 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ scriptValueIterator()

QScriptValueIterator * QScriptDebuggerBackend::scriptValueIterator ( int  id) const

Definition at line 888 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

889 {
891  return d->scriptValueIterators.value(id);
892 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ setBreakpoint()

int QScriptDebuggerBackend::setBreakpoint ( const QScriptBreakpointData data)

Sets a breakpoint defined by the given data, and returns a unique identifier for the new breakpoint.

If the conditions of the breakpoint is satisfied at some point during script evaluation, a breakpoint event() will be generated.

See also
deleteBreakpoint(), breakpoints()

Definition at line 669 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

670 {
672  if (!d->agent)
673  return -1;
674  if (!data.isValid())
675  return -1;
676  return d->agent->setBreakpoint(data);
677 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ setBreakpointData()

bool QScriptDebuggerBackend::setBreakpointData ( int  id,
const QScriptBreakpointData data 
)

Sets the data associated with the breakpoint identified by the given id.

Definition at line 720 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

721 {
723  if (d->agent)
724  return d->agent->setBreakpointData(id, data);
725  return false;
726 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ setCommandExecutor()

void QScriptDebuggerBackend::setCommandExecutor ( QScriptDebuggerCommandExecutor executor)

Definition at line 962 of file qscriptdebuggerbackend.cpp.

963 {
965  d->commandExecutor = executor;
966 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ setIgnoreExceptions()

void QScriptDebuggerBackend::setIgnoreExceptions ( bool  ignore)

Definition at line 907 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

908 {
910  d->ignoreExceptions = ignore;
911 }
double d
Definition: qnumeric_p.h:62
static bool ignore(const char *test, const char *const *table)
Definition: qaxserver.cpp:660
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ stepInto()

void QScriptDebuggerBackend::stepInto ( int  count = 1)

Steps into the next script statement.

When stepping is complete, an event() will be generated.

Definition at line 486 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

487 {
489  if (d->agent) {
490  d->agent->enterStepIntoMode(count);
491  resume();
492  }
493 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void resume()=0
This function is called when control should be returned back to the back-end, i.
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ stepOut()

void QScriptDebuggerBackend::stepOut ( )

Steps out of the current script function.

When stepping is complete, an event() will be generated.

Definition at line 512 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

513 {
515  if (d->agent) {
516  d->agent->enterStepOutMode();
517  resume();
518  }
519 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void resume()=0
This function is called when control should be returned back to the back-end, i.
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ stepOver()

void QScriptDebuggerBackend::stepOver ( int  count = 1)

Steps over the next script statement.

When stepping is complete, an event() will be generated.

Definition at line 499 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

500 {
502  if (d->agent) {
503  d->agent->enterStepOverMode(count);
504  resume();
505  }
506 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void resume()=0
This function is called when control should be returned back to the back-end, i.
The QScriptDebuggerBackend class is the base class of debugger back-ends.

◆ traceFunction()

QScriptValue QScriptDebuggerBackend::traceFunction ( ) const

Returns a trace function.

The trace function has similar semantics to the built-in print() function; however, instead of writing text to standard output, it generates a trace event containing the text.

Definition at line 918 of file qscriptdebuggerbackend.cpp.

Referenced by attachTo().

919 {
921  if (!engine())
922  return QScriptValue();
924  fun.setData(qScriptValueFromValue(engine(), const_cast<QScriptDebuggerBackendPrivate*>(d)));
925  return fun;
926 }
QScriptValue newFunction(FunctionSignature signature, int length=0)
Creates a QScriptValue that wraps a native (C++) function.
double d
Definition: qnumeric_p.h:62
QScriptValue qScriptValueFromValue(QScriptEngine *, const T &)
#define Q_D(Class)
Definition: qglobal.h:2482
QScriptEngine * engine() const
Returns the script engine that this backend is attached to, or 0 if the backend is not attached to an...
static QScriptValue trace(QScriptContext *context, QScriptEngine *engine)
The QScriptDebuggerBackend class is the base class of debugger back-ends.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
void setData(const QScriptValue &data)
Sets the internal data of this QScriptValue object.

Properties

◆ d_ptr

QScopedPointer<QScriptDebuggerBackendPrivate> QScriptDebuggerBackend::d_ptr
protected

Definition at line 147 of file qscriptdebuggerbackend_p.h.

Referenced by QScriptDebuggerBackend().


The documentation for this class was generated from the following files: