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

Public Functions

void continueExec ()
 
QScriptEngineengine ()
 
QList< JSAgentWatchDatagetLocals (QScriptContext *)
 
void positionChange (qint64 scriptId, int lineNumber, int columnNumber)
 
 QJSDebuggerAgentPrivate (QJSDebuggerAgent *q)
 
void recordKnownObjects (const QList< JSAgentWatchData > &)
 
void stopped ()
 

Public Variables

JSAgentBreakpoints breakpoints
 
bool coverageEnabled
 
QHash< qint64, QStringfilenames
 
QHash< QString, JSAgentBreakpointDatafileNameToBreakpoints
 
bool isInitialized
 
QSet< qint64knownObjectIds
 
QEventLoop loop
 
QJSDebuggerAgentq
 
JSDebuggerState state
 
int stepCount
 
int stepDepth
 
QStringList watchExpressions
 

Detailed Description

Definition at line 56 of file qjsdebuggeragent.cpp.

Constructors and Destructors

◆ QJSDebuggerAgentPrivate()

QJSDebuggerAgentPrivate::QJSDebuggerAgentPrivate ( QJSDebuggerAgent q)
inline

Definition at line 59 of file qjsdebuggeragent.cpp.

Functions

◆ continueExec()

void QJSDebuggerAgentPrivate::continueExec ( )

◆ engine()

QScriptEngine* QJSDebuggerAgentPrivate::engine ( )
inline

Definition at line 67 of file qjsdebuggeragent.cpp.

Referenced by getLocals(), and QJSDebugService::statusChanged().

67 { return q->engine(); }
QScriptEngine * engine() const
Returns the QScriptEngine that this agent is associated with.

◆ getLocals()

QList< JSAgentWatchData > QJSDebuggerAgentPrivate::getLocals ( QScriptContext ctx)

Definition at line 211 of file qjsdebuggeragent.cpp.

Referenced by QJSDebuggerAgent::locals(), QJSDebuggerAgent::localsAtFrame(), and QJSDebuggerAgentPrivate().

212 {
214  if (ctx) {
215  QScriptValue activationObject = ctx->activationObject();
216  QScriptValue thisObject = ctx->thisObject();
217  locals = expandObject(activationObject);
218  if (thisObject.isObject()
219  && thisObject.objectId() != engine()->globalObject().objectId()
220  && QScriptValueIterator(thisObject).hasNext())
221  locals.prepend(fromScriptValue(QLatin1String("this"), thisObject));
222  recordKnownObjects(locals);
223  knownObjectIds << activationObject.objectId();
224  }
225  return locals;
226 }
QScriptValue globalObject() const
Returns this engine&#39;s Global Object.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void recordKnownObjects(const QList< JSAgentWatchData > &)
qint64 objectId() const
Returns the ID of this object, or -1 if this QScriptValue is not an object.
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
QScriptEngine * engine()
static QList< JSAgentWatchData > expandObject(const QScriptValue &object)
The QScriptValueIterator class provides a Java-style iterator for QScriptValue.
static JSAgentWatchData fromScriptValue(const QString &expression, const QScriptValue &value)
QScriptValue activationObject() const
Returns the activation object of this QScriptContext.
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
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.
Definition: qdatastream.h:62

◆ positionChange()

void QJSDebuggerAgentPrivate::positionChange ( qint64  scriptId,
int  lineNumber,
int  columnNumber 
)

Definition at line 505 of file qjsdebuggeragent.cpp.

Referenced by QJSDebuggerAgent::positionChange(), and QJSDebuggerAgentPrivate().

506 {
507  Q_UNUSED(columnNumber);
508 
509  if (state == StoppedState)
510  return; //no re-entrency
511 
512  // check breakpoints
513  if (!breakpoints.isEmpty()) {
514  const QScriptContext *ctx = engine()->currentContext();
515  const QScriptContextInfo info(ctx);
516 
517  if (info.functionType() == QScriptContextInfo::ScriptFunction) {
519  // It is possible that the scripts are loaded before the agent is attached
520  if (it == filenames.constEnd()) {
521  it = filenames.insert(scriptId, info.fileName());
522  }
523 
524  const QString filePath = it.value();
525  const JSAgentBreakpoints bps = fileNameToBreakpoints.values(fileName(filePath)).toSet();
526 
527  foreach (const JSAgentBreakpointData &bp, bps) {
528  if (bp.lineNumber == lineNumber) {
529  stopped();
530  return;
531  }
532  }
533  }
534  }
535 
536  switch (state) {
537  case NoState:
538  case StoppedState:
539  // Do nothing
540  break;
541  case SteppingOutState:
542  if (stepDepth >= 0)
543  break;
544  //fallthough
545  case SteppingOverState:
546  if (stepDepth > 0)
547  break;
548  //fallthough
549  case SteppingIntoState:
550  stopped();
551  break;
552  }
553 
554 }
The QScriptContext class represents a Qt Script function invocation.
static mach_timebase_info_data_t info
#define it(className, varName)
bool isEmpty() const
Definition: qset.h:77
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
QHash< QString, JSAgentBreakpointData > fileNameToBreakpoints
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
JSAgentBreakpoints breakpoints
QHash< qint64, QString > filenames
QScriptEngine * engine()
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:859
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
The QScriptContextInfo class provides additional information about a QScriptContext.
QList< T > values() const
Returns a list containing all the values in the hash, in an arbitrary order.
Definition: qhash.h:693
#define ctx
Definition: qgl.cpp:6094
QScriptContext * currentContext() const
Returns the current context.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
static QString fileName(const QString &fileUrl)

◆ recordKnownObjects()

void QJSDebuggerAgentPrivate::recordKnownObjects ( const QList< JSAgentWatchData > &  list)

Definition at line 205 of file qjsdebuggeragent.cpp.

Referenced by QJSDebuggerAgent::expandObjectById(), getLocals(), QJSDebuggerAgentPrivate(), and QJSDebuggerAgent::watches().

206 {
207  foreach (const JSAgentWatchData &data, list)
208  knownObjectIds << data.objectId;
209 }
static const char * data(const QByteArray &arr)

◆ stopped()

void QJSDebuggerAgentPrivate::stopped ( )

Definition at line 596 of file qjsdebuggeragent.cpp.

Referenced by QJSDebugService::addEngine(), engine(), QJSDebuggerAgent::extension(), and QJSDebugService::statusChanged().

597 {
598  bool becauseOfException = false;
599  const QScriptValue &exception = QScriptValue();
600 
603 
604  emit q->stopped(becauseOfException, exception.toString());
605 
607 }
void stopped(bool becauseOfException, const QString &exception)
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
#define emit
Definition: qobjectdefs.h:76
void clear()
Definition: qset.h:87
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
Definition: qeventloop.cpp:181

Properties

◆ breakpoints

JSAgentBreakpoints QJSDebuggerAgentPrivate::breakpoints

◆ coverageEnabled

bool QJSDebuggerAgentPrivate::coverageEnabled

◆ filenames

QHash<qint64, QString> QJSDebuggerAgentPrivate::filenames

◆ fileNameToBreakpoints

QHash<QString, JSAgentBreakpointData> QJSDebuggerAgentPrivate::fileNameToBreakpoints

Definition at line 80 of file qjsdebuggeragent.cpp.

Referenced by QJSDebuggerAgent::setBreakpoints().

◆ isInitialized

bool QJSDebuggerAgentPrivate::isInitialized

◆ knownObjectIds

QSet<qint64> QJSDebuggerAgentPrivate::knownObjectIds

◆ loop

QEventLoop QJSDebuggerAgentPrivate::loop

Definition at line 76 of file qjsdebuggeragent.cpp.

◆ q

QJSDebuggerAgent* QJSDebuggerAgentPrivate::q

Definition at line 71 of file qjsdebuggeragent.cpp.

Referenced by engine().

◆ state

JSDebuggerState QJSDebuggerAgentPrivate::state

◆ stepCount

int QJSDebuggerAgentPrivate::stepCount

Definition at line 74 of file qjsdebuggeragent.cpp.

◆ stepDepth

int QJSDebuggerAgentPrivate::stepDepth

◆ watchExpressions

QStringList QJSDebuggerAgentPrivate::watchExpressions

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