52 #include <QtScript/qscriptengine.h> 53 #include <QtScript/qscriptcontextinfo.h> 54 #include <QtScript/qscriptvalueiterator.h> 56 #include <QtCore/qcoreapplication.h> 57 #include <QtCore/qdebug.h> 137 : agent(0), commandExecutor(0),
138 pendingEvaluateContextIndex(-1), pendingEvaluateLineNumber(-1),
139 ignoreExceptions(false),
140 nextScriptValueIteratorId(0), nextScriptObjectSnapshotId(0),
195 scriptId, lineNumber, columnNumber);
214 scriptId, lineNumber, columnNumber);
228 scriptId, lineNumber, columnNumber);
243 scriptId, lineNumber, columnNumber);
273 if (lineNumber == -1) {
275 lineNumber =
info.lineNumber();
276 fileName =
info.fileName();
278 if (lineNumber != -1)
302 self->q_func()->event(e);
358 scriptId, lineNumber, columnNumber);
369 scriptId, lineNumber, columnNumber);
440 if (eng && eng->
agent() ==
d->agent) {
454 d->agent->nullifyBackendPointer();
459 d->pendingEvaluateLineNumber = -1;
460 d->ignoreExceptions =
false;
461 d->nextScriptValueIteratorId = 0;
463 d->scriptValueIterators.clear();
465 d->scriptObjectSnapshots.clear();
479 return d->agent->engine();
490 d->agent->enterStepIntoMode(count);
503 d->agent->enterStepOverMode(count);
516 d->agent->enterStepOutMode();
531 d->agent->enterContinueMode();
544 d->agent->enterInterruptMode();
556 d->agent->enterRunToLocationMode(fileName, lineNumber);
570 d->agent->enterRunToLocationMode(scriptId, lineNumber);
579 d->agent->enterReturnByForceMode(contextIndex, value);
592 d->pendingEvaluateContextIndex = contextIndex;
593 d->pendingEvaluateProgram = program;
595 d->pendingEvaluateLineNumber = lineNumber;
596 if (!
engine()->isEvaluating())
608 QString program =
d->pendingEvaluateProgram;
611 int contextIndex =
d->pendingEvaluateContextIndex;
615 int lineNumber =
d->pendingEvaluateLineNumber;
616 d->pendingEvaluateProgram =
QString();
617 d->pendingEvaluateFileName =
QString();
618 d->pendingEvaluateLineNumber = -1;
619 d->pendingEvaluateContextIndex = -1;
633 d->agent->enterContinueMode();
636 d->ignoreExceptions =
true;
639 d->ignoreExceptions =
false;
640 if (!hadException &&
engine()->hasUncaughtException())
676 return d->agent->setBreakpoint(data);
691 return d->agent->deleteBreakpoint(
id);
701 d->agent->deleteAllBreakpoints();
713 return d->agent->breakpointData(
id);
724 return d->agent->setBreakpointData(
id, data);
738 return d->agent->breakpoints();
751 return d->agent->scripts();
764 return d->agent->scriptData(
id);
776 d->agent->scriptsCheckpoint();
793 return d->agent->scriptsDelta();
801 return d->agent->resolveScript(fileName);
846 return d->agent->contextIds();
854 return d->agent->contextsCheckpoint();
860 int id =
d->nextScriptObjectSnapshotId;
861 ++
d->nextScriptObjectSnapshotId;
869 return d->scriptObjectSnapshots.value(
id);
882 int id =
d->nextScriptValueIteratorId;
883 ++
d->nextScriptValueIteratorId;
891 return d->scriptValueIterators.value(
id);
904 return d->ignoreExceptions;
955 if (
d->commandExecutor)
956 return d->commandExecutor;
965 d->commandExecutor = executor;
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QScriptValue newFunction(FunctionSignature signature, int length=0)
Creates a QScriptValue that wraps a native (C++) function.
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's property with the given name, using the given mode to resolv...
QScriptDebuggerBackendPrivate()
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.
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'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 setScriptId(qint64 id)
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's Global Object.
static bool ignore(const char *test, const char *const *table)
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.
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
void nullifyBackendPointer()
The QString class provides a Unicode character string.
static QScriptValue qsassert(QScriptContext *context, QScriptEngine *engine)
QScriptDebuggerBackend * q_ptr
The QObject class is the base class of all Qt objects.
QScriptValue qScriptValueFromValue(QScriptEngine *, const T &)
QScriptContext * context(int index) const
Returns the context for the frame with the given index.
static QScriptValue fileName(QScriptContext *context, QScriptEngine *engine)
void setThisObject(const QScriptValue &thisObject)
Sets the `this' 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.
~QScriptDebuggerBackendEventReceiver()
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
void setActivationObject(const QScriptValue &activation)
Sets the activation object of this QScriptContext to be the given activation.
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.
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.
static QScriptValue lineNumber(QScriptContext *context, QScriptEngine *engine)
virtual ~QScriptDebuggerBackend()
Destroys this QScriptDebuggerBackend.
int newScriptObjectSnapshot()
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
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.
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...
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.
void agentDestroyed(QScriptDebuggerAgent *)
QScriptDebuggerBackend()
Creates a QScriptDebuggerBackend object.
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
void postEvent(QEvent *e)
virtual void resume()=0
This function is called when control should be returned back to the back-end, i.
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.
virtual bool event(QEvent *e)
void setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
Sets the value of this QScriptValue'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
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)
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.
void setBreakpointId(int id)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
void scriptsCheckpoint()
Makes a checkpoint of the currently loaded scripts.
QObject * parent() const
Returns a pointer to the parent object.
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)
void deleteScriptObjectSnapshot(int id)
QScriptContext * pushContext()
Enters a new execution context and returns the associated QScriptContext object.
void clearExceptions()
Clears any uncaught exceptions in this engine.
virtual ~QScriptDebuggerBackendPrivate()
QList< qint64 > contextIds() const
T takeLast()
Removes the last item in the list and returns it.
bool ignoreExceptions() const
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.
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' object associated with this QScriptContext.
void pushScope(const QScriptValue &object)
Adds the given object to the front of this context's scope chain.
void setCommandExecutor(QScriptDebuggerCommandExecutor *executor)
QScriptDebuggerAgent * agent
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.
Type type() const
Returns the event type.
The QScriptValue class acts as a container for the Qt Script data types.
static QString fileName(const QString &fileUrl)
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
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.
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.
void deleteScriptValueIterator(int id)
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