42 #include "private/qjsdebuggeragent_p.h" 43 #include "private/qdeclarativedebughelper_p.h" 44 #include "private/qjsdebugservice_p.h" 46 #include <QtCore/qdatetime.h> 47 #include <QtCore/qcoreapplication.h> 48 #include <QtCore/qset.h> 49 #include <QtCore/qurl.h> 50 #include <QtScript/qscriptcontextinfo.h> 51 #include <QtScript/qscriptengine.h> 52 #include <QtScript/qscriptvalueiterator.h> 94 previousState(a->
state),
102 if (!hadException && agent->engine()->hasUncaughtException())
103 agent->engine()->clearExceptions();
104 agent->state = previousState;
119 (
"Debugger::JSAgentWatchData",
"[Array of length %1]");
121 (
"Debugger::JSAgentWatchData",
"<undefined>");
133 }
else if (value.
isBool()) {
136 }
else if (value.
isDate()) {
142 data.
type =
"Function";
146 data.
type =
"Number";
148 data.
type =
"RegExp";
150 data.
type =
"String";
152 data.
type =
"Variant";
155 data.
type =
"Object";
161 data.
type =
"Object";
163 data.
value =
"[Object]";
164 }
else if (value.
isNull()) {
165 data.
type =
"<null>";
167 data.
type =
"<unknown>";
190 data.
name =
"<no initialized data>";
202 return fileUrl.
mid(lastDelimiterPos, fileUrl.
size() - lastDelimiterPos);
317 SetupExecEnv execEnv(
d);
326 SetupExecEnv execEnv(
d);
339 SetupExecEnv execEnv(
d);
345 SetupExecEnv execEnv(
d);
349 while (ctx && deep < frameId) {
359 SetupExecEnv execEnv(
d);
369 if (
ctx->parentContext()) {
400 SetupExecEnv execEnv(
d);
413 SetupExecEnv execEnv(
d);
417 if (
object.isObject()) {
434 id, program, fileName, baseLineNumber,
513 if (!breakpoints.isEmpty()) {
567 #if 0 //sometimes, we get exceptions that we should just ignore. 598 bool becauseOfException =
false;
601 knownObjectIds.clear();
604 emit q->stopped(becauseOfException, exception.
toString());
The QVariant class acts like a union for the most common Qt data types.
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 stopped(bool becauseOfException, const QString &exception)
bool isNull() const
Returns true if this QScriptValue is of the primitive type Null; 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...
JSAgentWatchData executeExpression(const QString &expr)
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...
static mach_timebase_info_data_t info
#define QT_END_NAMESPACE
This macro expands to.
QList< JSAgentWatchData > getLocals(QScriptContext *)
void clear()
Removes all items from the hash.
bool isBool() const
Returns true if this QScriptValue is of the primitive type Boolean; otherwise returns false...
void exceptionThrow(qint64 scriptId, const QScriptValue &exception, bool hasHandler)
Reimplemented Function
int remove(const Key &key)
Removes all the items that have the key from the hash.
bool isFunction() const
Returns true if this QScriptValue is a function; otherwise returns false.
void setProperty(qint64 objectId, const QString &property, const QString &value)
QDateTime toDateTime() const
Returns a QDateTime representation of this value, in local time.
bool supportsExtension(Extension extension) const
Returns true if the QScriptEngineAgent supports the given extension; otherwise, false is returned...
#define it(className, varName)
QScriptEngine * engine() const
Returns the QScriptEngine that this agent is associated with.
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
~QJSDebuggerAgent()
Destroys this QJSDebuggerAgent.
bool isError() const
Returns true if this QScriptValue is an object of the Error class; otherwise returns false...
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.
QScriptValue objectById(qint64 id) const
Returns the object with the given id, or an invalid QScriptValue if there is no object with that id...
QList< JSAgentWatchData > watches()
QString name() const
Returns the name of the last property that was jumped over using next() or previous().
void exceptionCatch(qint64 scriptId, const QScriptValue &exception)
Reimplemented Function
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
long ASN1_INTEGER_get ASN1_INTEGER * a
QObject * toQObject() const
If this QScriptValue is a QObject, returns the QObject pointer that the QScriptValue represents; othe...
The QString class provides a Unicode character string.
The QObject class is the base class of all Qt objects.
QVariant extension(Extension extension, const QVariant &argument=QVariant())
This virtual function can be reimplemented in a QScriptEngineAgent subclass to provide support for ex...
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the datetime as a string in the format given.
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
void recordKnownObjects(const QList< JSAgentWatchData > &)
const T value(const Key &key) const
Returns the value associated with the key.
void positionChange(qint64 scriptId, int lineNumber, int columnNumber)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
QHash< QString, JSAgentBreakpointData > fileNameToBreakpoints
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
void processMessage(const JSAgentCoverageData &message)
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
QString fileName() const
Returns the name of the file where the code being executed was defined, if available; otherwise retur...
void append(const T &t)
Inserts value at the end of the list.
qint64 objectId() const
Returns the ID of this object, or -1 if this QScriptValue is not an object.
QList< JSAgentWatchData > locals()
The QScriptEngine class provides an environment for evaluating Qt Script code.
JSAgentBreakpoints breakpoints
#define QT_BEGIN_NAMESPACE
This macro expands to.
virtual QVariant extension(Extension extension, const QVariant &argument=QVariant())
This virtual function can be reimplemented in a QScriptEngineAgent subclass to provide support for ex...
qint64 restart()
Restarts the timer and returns the time elapsed since the previous start.
The QEventLoop class provides a means of entering and leaving an event loop.
int lineNumber() const
Returns the line number corresponding to the statement being executed, or -1 if the line number is no...
QJSDebuggerAgentPrivate(QJSDebuggerAgent *q)
QHash< qint64, QString > filenames
bool contains(const T &value) const
int size() const
Returns the number of characters in this string.
QSet< qint64 > knownObjectIds
bool isString() const
Returns true if this QScriptValue is of the primitive type String; otherwise returns false...
void prepend(const T &t)
Inserts value at the beginning of the list.
The QStringList class provides a list of strings.
void contextPop()
Reimplemented Function
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
QList< JSAgentWatchData > localsAtFrame(int frameId)
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
void setBreakpoints(const JSAgentBreakpoints &)
void setCoverageEnabled(bool enabled)
bool isVariant() const
Returns true if this QScriptValue is a variant value; otherwise returns false.
static QList< JSAgentWatchData > expandObject(const QScriptValue &object)
void setWatchExpressions(const QStringList &)
QJSDebuggerAgentPrivate * d
int functionStartLineNumber() const
Returns the line number where the definition of the called function starts, or -1 if the line number ...
QList< JSAgentStackData > backtrace()
QScriptValue::PropertyFlags flags() const
Returns the flags of the last property that was jumped over using next() or previous().
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
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
The QScriptValueIterator class provides a Java-style iterator for QScriptValue.
void functionEntry(qint64 scriptId)
Reimplemented Function
The QDeclarativeEngine class provides an environment for instantiating QML components.
bool isRegExp() const
Returns true if this QScriptValue is an object of the RegExp class; otherwise returns false...
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QObject * parent() const
Returns a pointer to the parent object.
QScriptValue value() const
Returns the value of the last property that was jumped over using next() or previous().
QJSDebuggerAgent(QScriptEngine *engine, QObject *parent=0)
Constructs a new agent for the given engine.
QScriptContext * currentContext() const
Returns the current context.
QList< JSAgentWatchData > expandObjectById(quint64 objectId)
static JSAgentWatchData fromScriptValue(const QString &expression, const QScriptValue &value)
QStringList watchExpressions
bool isQObject() const
Returns true if this QScriptValue is a QObject; otherwise returns false.
QVariant property(const char *name) const
Returns the value of the object's name property.
FunctionType functionType() const
Returns the type of the called function.
bool isDate() const
Returns true if this QScriptValue is an object of the Date class; otherwise returns false...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
QScriptValue activationObject() const
Returns the activation object of this QScriptContext.
QList< T > values() const
iterator insertMulti(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
void setAgent(QScriptEngineAgent *agent)
Installs the given agent on this engine.
bool isArray() const
Returns true if this QScriptValue is an object of the Array class; otherwise returns false...
QScriptValue thisObject() const
Returns the `this' object associated with this QScriptContext.
static QJSDebugService * instance()
void contextPush()
Reimplemented Function
bool hasUncaughtException() const
Returns true if the last script evaluation resulted in an uncaught exception; otherwise returns false...
Extension
This enum specifies the possible extensions to a QScriptEngineAgent.
void functionExit(qint64 scriptId, const QScriptValue &returnValue)
Reimplemented Function
The QScriptValue class acts as a container for the Qt Script data types.
bool isInitialized() const
Indicates whether the agent got the list of breakpoints.
void scriptUnload(qint64 id)
Reimplemented Function
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static QString fileName(const QString &fileUrl)
void positionChange(qint64 scriptId, int lineNumber, int columnNumber)
Reimplemented Function
The QScriptEngineAgent class provides an interface to report events pertaining to QScriptEngine execu...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
void next()
Advances the iterator by one position.
void scriptLoad(qint64 id, const QString &program, const QString &fileName, int baseLineNumber)
Reimplemented Function
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QScriptContext * parentContext() const
Returns the parent context of this QScriptContext.
bool isObject() const
Returns true if this QScriptValue is of the Object type; otherwise returns false. ...
bool hasNext() const
Returns true if there is at least one item ahead of the iterator (i.e.
The QList class is a template class that provides lists.
QString functionName() const
Returns the name of the called function, or an empty string if the name is not available.