Qt 4.8
Public Functions | Static Public Functions | Public Variables | List of all members
QScriptDebuggerBackendPrivate Class Reference

#include <qscriptdebuggerbackend_p_p.h>

Inheritance diagram for QScriptDebuggerBackendPrivate:
QScriptEngineDebuggerBackendPrivate

Public Functions

void agentDestroyed (QScriptDebuggerAgent *)
 
virtual void breakpoint (qint64 scriptId, int lineNumber, int columnNumber, int breakpointId)
 The agent calls this function when a breakpoint has been triggered. More...
 
virtual void debuggerInvocationRequest (qint64 scriptId, int lineNumber, int columnNumber)
 The agent calls this function when the engine has reached a "debugger" statement. More...
 
virtual bool event (QEvent *e)
 
virtual void exception (qint64 scriptId, const QScriptValue &exception, bool hasHandler)
 The agent calls this function when an uncaught exception has occurred. More...
 
virtual void forcedReturn (qint64 scriptId, int lineNumber, int columnNumber, const QScriptValue &value)
 
virtual void interrupted (qint64 scriptId, int lineNumber, int columnNumber)
 The agent calls this function when evaluation has been interrupted. More...
 
virtual void locationReached (qint64 scriptId, int lineNumber, int columnNumber)
 The agent calls this function when it has run to a particular location. More...
 
void postEvent (QEvent *e)
 
 QScriptDebuggerBackendPrivate ()
 
virtual void stepped (qint64 scriptId, int lineNumber, int columnNumber, const QScriptValue &result)
 The agent calls this function when it has completed a step operation. More...
 
virtual ~QScriptDebuggerBackendPrivate ()
 

Static Public Functions

static QScriptValue fileName (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue lineNumber (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue qsassert (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue trace (QScriptContext *context, QScriptEngine *engine)
 

Public Variables

QScriptDebuggerAgentagent
 
QScriptDebuggerCommandExecutorcommandExecutor
 
QObjecteventReceiver
 
bool ignoreExceptions
 
int nextScriptObjectSnapshotId
 
int nextScriptValueIteratorId
 
QScriptValue origFileNameFunction
 
QScriptValue origLineNumberFunction
 
QScriptValue origTraceFunction
 
int pendingEvaluateContextIndex
 
QString pendingEvaluateFileName
 
int pendingEvaluateLineNumber
 
QString pendingEvaluateProgram
 
QScriptDebuggerBackendq_ptr
 
QMap< int, QScriptObjectSnapshot * > scriptObjectSnapshots
 
QMap< int, QScriptValueIterator * > scriptValueIterators
 

Detailed Description

Definition at line 76 of file qscriptdebuggerbackend_p_p.h.

Constructors and Destructors

◆ QScriptDebuggerBackendPrivate()

QScriptDebuggerBackendPrivate::QScriptDebuggerBackendPrivate ( )

◆ ~QScriptDebuggerBackendPrivate()

QScriptDebuggerBackendPrivate::~QScriptDebuggerBackendPrivate ( )
virtual

Definition at line 146 of file qscriptdebuggerbackend.cpp.

147 {
148  if (agent)
150  delete commandExecutor;
151  delete eventReceiver;
154 }
QMap< int, QScriptValueIterator * > scriptValueIterators
QScriptDebuggerCommandExecutor * commandExecutor
QMap< int, QScriptObjectSnapshot * > scriptObjectSnapshots
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

Functions

◆ agentDestroyed()

void QScriptDebuggerBackendPrivate::agentDestroyed ( QScriptDebuggerAgent ag)

Definition at line 175 of file qscriptdebuggerbackend.cpp.

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 }

◆ breakpoint()

void QScriptDebuggerBackendPrivate::breakpoint ( qint64  scriptId,
int  lineNumber,
int  columnNumber,
int  breakpointId 
)
virtual

The agent calls this function when a breakpoint has been triggered.

Definition at line 236 of file qscriptdebuggerbackend.cpp.

240 {
243  scriptId, lineNumber, columnNumber);
244  e.setFileName(agent->scriptData(scriptId).fileName());
245  e.setBreakpointId(breakpointId);
246  q->event(e);
247 }
QScriptScriptData scriptData(qint64 id) const
Returns the data associated with the script with the given id.
#define Q_Q(Class)
Definition: qglobal.h:2483
static QScriptValue lineNumber(QScriptContext *context, QScriptEngine *engine)
The QScriptDebuggerBackend class is the base class of debugger back-ends.
QString fileName() const

◆ debuggerInvocationRequest()

void QScriptDebuggerBackendPrivate::debuggerInvocationRequest ( qint64  scriptId,
int  lineNumber,
int  columnNumber 
)
virtual

The agent calls this function when the engine has reached a "debugger" statement.

Definition at line 353 of file qscriptdebuggerbackend.cpp.

355 {
358  scriptId, lineNumber, columnNumber);
359  e.setFileName(agent->scriptData(scriptId).fileName());
360  q->event(e);
361 }
QScriptScriptData scriptData(qint64 id) const
Returns the data associated with the script with the given id.
#define Q_Q(Class)
Definition: qglobal.h:2483
static QScriptValue lineNumber(QScriptContext *context, QScriptEngine *engine)
The QScriptDebuggerBackend class is the base class of debugger back-ends.
QString fileName() const

◆ event()

bool QScriptDebuggerBackendPrivate::event ( QEvent e)
virtual

Reimplemented in QScriptEngineDebuggerBackendPrivate.

Definition at line 165 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerBackendEventReceiver::event(), and QScriptEngineDebuggerBackendPrivate::event().

166 {
167  if (e->type() == QEvent::User+1) {
169  q_func()->event(de->event());
170  return true;
171  }
172  return false;
173 }
const QScriptDebuggerEvent & event() const
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ exception()

void QScriptDebuggerBackendPrivate::exception ( qint64  scriptId,
const QScriptValue exception,
bool  hasHandler 
)
virtual

The agent calls this function when an uncaught exception has occurred.

Definition at line 253 of file qscriptdebuggerbackend.cpp.

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 }
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...
static mach_timebase_info_data_t info
QScriptScriptData scriptData(qint64 id) const
Returns the data associated with the script with the given id.
qint32 toInt32() const
Returns the signed 32-bit integer value of this QScriptValue, using the conversion rules described in...
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QScriptValue fileName(QScriptContext *context, QScriptEngine *engine)
#define Q_Q(Class)
Definition: qglobal.h:2483
static QScriptValue lineNumber(QScriptContext *context, QScriptEngine *engine)
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...
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
The QScriptDebuggerValue class represents a script 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...
The QScriptDebuggerBackend class is the base class of debugger back-ends.
QString fileName() const

◆ fileName()

QScriptValue QScriptDebuggerBackendPrivate::fileName ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 332 of file qscriptdebuggerbackend.cpp.

Referenced by exception(), QScriptDebuggerBackend::fileNameFunction(), and qsassert().

334 {
336  QString fn = info.fileName();
337  if (fn.isEmpty())
338  return engine->undefinedValue();
339  return QScriptValue(engine, fn);
340 }
static mach_timebase_info_data_t info
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QScriptContextInfo class provides additional information about a QScriptContext.
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptContext * parentContext() const
Returns the parent context of this QScriptContext.

◆ forcedReturn()

void QScriptDebuggerBackendPrivate::forcedReturn ( qint64  scriptId,
int  lineNumber,
int  columnNumber,
const QScriptValue value 
)
virtual

Definition at line 363 of file qscriptdebuggerbackend.cpp.

366 {
369  scriptId, lineNumber, columnNumber);
370  e.setFileName(agent->scriptData(scriptId).fileName());
371  e.setScriptValue(QScriptDebuggerValue(value));
372  q->event(e);
373 }
QScriptScriptData scriptData(qint64 id) const
Returns the data associated with the script with the given id.
#define Q_Q(Class)
Definition: qglobal.h:2483
static QScriptValue lineNumber(QScriptContext *context, QScriptEngine *engine)
The QScriptDebuggerValue class represents a script value.
The QScriptDebuggerBackend class is the base class of debugger back-ends.
QString fileName() const

◆ interrupted()

void QScriptDebuggerBackendPrivate::interrupted ( qint64  scriptId,
int  lineNumber,
int  columnNumber 
)
virtual

The agent calls this function when evaluation has been interrupted.

Definition at line 222 of file qscriptdebuggerbackend.cpp.

225 {
228  scriptId, lineNumber, columnNumber);
229  e.setFileName(agent->scriptData(scriptId).fileName());
230  q->event(e);
231 }
QScriptScriptData scriptData(qint64 id) const
Returns the data associated with the script with the given id.
#define Q_Q(Class)
Definition: qglobal.h:2483
static QScriptValue lineNumber(QScriptContext *context, QScriptEngine *engine)
The QScriptDebuggerBackend class is the base class of debugger back-ends.
QString fileName() const

◆ lineNumber()

QScriptValue QScriptDebuggerBackendPrivate::lineNumber ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 342 of file qscriptdebuggerbackend.cpp.

Referenced by exception(), and QScriptDebuggerBackend::lineNumberFunction().

344 {
346  return QScriptValue(engine, info.lineNumber());
347 }
static mach_timebase_info_data_t info
The QScriptContextInfo class provides additional information about a QScriptContext.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptContext * parentContext() const
Returns the parent context of this QScriptContext.

◆ locationReached()

void QScriptDebuggerBackendPrivate::locationReached ( qint64  scriptId,
int  lineNumber,
int  columnNumber 
)
virtual

The agent calls this function when it has run to a particular location.

Definition at line 208 of file qscriptdebuggerbackend.cpp.

211 {
214  scriptId, lineNumber, columnNumber);
215  e.setFileName(agent->scriptData(scriptId).fileName());
216  q->event(e);
217 }
QScriptScriptData scriptData(qint64 id) const
Returns the data associated with the script with the given id.
#define Q_Q(Class)
Definition: qglobal.h:2483
static QScriptValue lineNumber(QScriptContext *context, QScriptEngine *engine)
The QScriptDebuggerBackend class is the base class of debugger back-ends.
QString fileName() const

◆ postEvent()

void QScriptDebuggerBackendPrivate::postEvent ( QEvent e)

Definition at line 156 of file qscriptdebuggerbackend.cpp.

157 {
158  if (!eventReceiver) {
161  }
163 }
QScriptEngine * engine() const
Returns the QScriptEngine that this agent is associated with.
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...
void moveToThread(QThread *thread)
Changes the thread affinity for this object and its children.
Definition: qobject.cpp:1458
QThread * thread() const
Returns the thread in which the object lives.
Definition: qobject.cpp:1419

◆ qsassert()

QScriptValue QScriptDebuggerBackendPrivate::qsassert ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 306 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerBackend::assertFunction().

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 }
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
static mach_timebase_info_data_t info
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QScriptValue fileName(QScriptContext *context, QScriptEngine *engine)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
bool toBoolean() const
Use toBool() instead.
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
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.
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
QString & append(QChar c)
Definition: qstring.cpp:1777
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
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
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
QScriptContext * parentContext() const
Returns the parent context of this QScriptContext.

◆ stepped()

void QScriptDebuggerBackendPrivate::stepped ( qint64  scriptId,
int  lineNumber,
int  columnNumber,
const QScriptValue result 
)
virtual

The agent calls this function when it has completed a step operation.

Definition at line 188 of file qscriptdebuggerbackend.cpp.

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 }
bool isUndefined() const
Returns true if this QScriptValue is of the primitive type Undefined; otherwise returns false...
QScriptScriptData scriptData(qint64 id) const
Returns the data associated with the script with the given id.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
#define Q_Q(Class)
Definition: qglobal.h:2483
static QScriptValue lineNumber(QScriptContext *context, QScriptEngine *engine)
The QScriptDebuggerValue class represents a script value.
The QScriptDebuggerBackend class is the base class of debugger back-ends.
QString fileName() const

◆ trace()

QScriptValue QScriptDebuggerBackendPrivate::trace ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 287 of file qscriptdebuggerbackend.cpp.

Referenced by QScriptDebuggerBackend::traceFunction().

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 }
T qscriptvalue_cast(const QScriptValue &)
QScriptValue callee() const
Returns the callee.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
The QString class provides a Unicode character string.
Definition: qstring.h:83
static const char * data(const QByteArray &arr)
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
QScriptValue data() const
Returns the internal data of this QScriptValue object.
QString & append(QChar c)
Definition: qstring.cpp:1777
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
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

Properties

◆ agent

QScriptDebuggerAgent* QScriptDebuggerBackendPrivate::agent

◆ commandExecutor

QScriptDebuggerCommandExecutor* QScriptDebuggerBackendPrivate::commandExecutor

◆ eventReceiver

QObject* QScriptDebuggerBackendPrivate::eventReceiver

Definition at line 126 of file qscriptdebuggerbackend_p_p.h.

Referenced by postEvent(), and ~QScriptDebuggerBackendPrivate().

◆ ignoreExceptions

bool QScriptDebuggerBackendPrivate::ignoreExceptions

Definition at line 118 of file qscriptdebuggerbackend_p_p.h.

Referenced by exception().

◆ nextScriptObjectSnapshotId

int QScriptDebuggerBackendPrivate::nextScriptObjectSnapshotId

Definition at line 123 of file qscriptdebuggerbackend_p_p.h.

◆ nextScriptValueIteratorId

int QScriptDebuggerBackendPrivate::nextScriptValueIteratorId

Definition at line 120 of file qscriptdebuggerbackend_p_p.h.

◆ origFileNameFunction

QScriptValue QScriptDebuggerBackendPrivate::origFileNameFunction

Definition at line 131 of file qscriptdebuggerbackend_p_p.h.

◆ origLineNumberFunction

QScriptValue QScriptDebuggerBackendPrivate::origLineNumberFunction

Definition at line 132 of file qscriptdebuggerbackend_p_p.h.

◆ origTraceFunction

QScriptValue QScriptDebuggerBackendPrivate::origTraceFunction

Definition at line 130 of file qscriptdebuggerbackend_p_p.h.

◆ pendingEvaluateContextIndex

int QScriptDebuggerBackendPrivate::pendingEvaluateContextIndex

Definition at line 114 of file qscriptdebuggerbackend_p_p.h.

◆ pendingEvaluateFileName

QString QScriptDebuggerBackendPrivate::pendingEvaluateFileName

Definition at line 116 of file qscriptdebuggerbackend_p_p.h.

◆ pendingEvaluateLineNumber

int QScriptDebuggerBackendPrivate::pendingEvaluateLineNumber

Definition at line 117 of file qscriptdebuggerbackend_p_p.h.

◆ pendingEvaluateProgram

QString QScriptDebuggerBackendPrivate::pendingEvaluateProgram

Definition at line 115 of file qscriptdebuggerbackend_p_p.h.

◆ q_ptr

QScriptDebuggerBackend* QScriptDebuggerBackendPrivate::q_ptr

◆ scriptObjectSnapshots

QMap<int, QScriptObjectSnapshot*> QScriptDebuggerBackendPrivate::scriptObjectSnapshots

Definition at line 124 of file qscriptdebuggerbackend_p_p.h.

Referenced by ~QScriptDebuggerBackendPrivate().

◆ scriptValueIterators

QMap<int, QScriptValueIterator*> QScriptDebuggerBackendPrivate::scriptValueIterators

Definition at line 121 of file qscriptdebuggerbackend_p_p.h.

Referenced by ~QScriptDebuggerBackendPrivate().


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