Qt 4.8
Public Functions | Properties | List of all members
QScriptDebuggerAgent Class Reference

This class implements a state machine that uses the low-level events reported by the QScriptEngineAgent interface to implement debugging- specific functionality such as stepping and breakpoints. More...

#include <qscriptdebuggeragent_p.h>

Inheritance diagram for QScriptDebuggerAgent:
QScriptEngineAgent

Public Functions

QScriptBreakpointData breakpointData (int id) const
 Returns the data associated with the breakpoint with the given id. More...
 
QScriptBreakpointMap breakpoints () const
 Returns all breakpoints. More...
 
QList< qint64contextIds () const
 
void contextPop ()
 Reimplemented Function More...
 
void contextPush ()
 Reimplemented Function More...
 
QPair< QList< qint64 >, QList< qint64 > > contextsCheckpoint ()
 
void deleteAllBreakpoints ()
 Deletes all breakpoints. More...
 
bool deleteBreakpoint (int id)
 Deletes the breakpoint with the given id. More...
 
void enterContinueMode ()
 Instructs the agent to continue evaluation. More...
 
void enterInterruptMode ()
 Instructs the agent to interrupt evaluation. More...
 
void enterReturnByForceMode (int contextIndex, const QScriptValue &value)
 
void enterRunToLocationMode (const QString &fileName, int lineNumber)
 Instructs the agent to continue evaluation until the location described by fileName and lineNumber is reached. More...
 
void enterRunToLocationMode (qint64 scriptId, int lineNumber)
 Instructs the agent to continue evaluation until the location described by scriptId and lineNumber is reached. More...
 
void enterStepIntoMode (int count=1)
 Instructs the agent to perform a "step into" operation. More...
 
void enterStepOutMode ()
 Instructs the agent to perform a "step out" operation. More...
 
void enterStepOverMode (int count=1)
 Instructs the agent to perform a "step over" operation. More...
 
void exceptionCatch (qint64 scriptId, const QScriptValue &exception)
 Reimplemented Function More...
 
void exceptionThrow (qint64 scriptId, const QScriptValue &exception, bool hasHandler)
 Reimplemented Function More...
 
QVariant extension (Extension extension, const QVariant &argument=QVariant())
 Reimplemented Function More...
 
void functionEntry (qint64 scriptId)
 Reimplemented Function More...
 
void functionExit (qint64 scriptId, const QScriptValue &returnValue)
 Reimplemented Function More...
 
void nullifyBackendPointer ()
 
void positionChange (qint64 scriptId, int lineNumber, int columnNumber)
 Reimplemented Function More...
 
 QScriptDebuggerAgent (QScriptDebuggerBackendPrivate *backend, QScriptEngine *engine)
 Constructs a new agent for the given engine. More...
 
qint64 resolveScript (const QString &fileName) const
 Returns the identifier of the script that has the given fileName, or -1 if there is no such script. More...
 
QScriptScriptData scriptData (qint64 id) const
 Returns the data associated with the script with the given id. More...
 
void scriptLoad (qint64 id, const QString &program, const QString &fileName, int baseLineNumber)
 Reimplemented Function More...
 
QScriptScriptMap scripts () const
 Returns all scripts. More...
 
void scriptsCheckpoint ()
 Checkpoints the current scripts. More...
 
QPair< QList< qint64 >, QList< qint64 > > scriptsDelta () const
 Returns the difference between the current checkpoint and the previous checkpoint. More...
 
void scriptUnload (qint64 id)
 Reimplemented Function More...
 
int setBreakpoint (const QScriptBreakpointData &data)
 Sets a breakpoint defined by the given data. More...
 
bool setBreakpointData (int id, const QScriptBreakpointData &data)
 Sets the data associated with the breakpoint with the given id. More...
 
bool supportsExtension (Extension extension) const
 Reimplemented Function More...
 
 ~QScriptDebuggerAgent ()
 Destroys this QScriptDebuggerAgent. More...
 
- Public Functions inherited from QScriptEngineAgent
QScriptEngineengine () const
 Returns the QScriptEngine that this agent is associated with. More...
 
 QScriptEngineAgent (QScriptEngine *engine)
 Constructs a QScriptEngineAgent object for the given engine. More...
 
virtual ~QScriptEngineAgent ()
 Destroys this QScriptEngineAgent. More...
 

Properties

QScriptDebuggerAgentPrivated_ptr
 

Additional Inherited Members

- Public Types inherited from QScriptEngineAgent
enum  Extension { DebuggerInvocationRequest }
 This enum specifies the possible extensions to a QScriptEngineAgent. More...
 
- Protected Functions inherited from QScriptEngineAgent
 QScriptEngineAgent (QScriptEngineAgentPrivate &dd, QScriptEngine *engine)
 
- Protected Variables inherited from QScriptEngineAgent
QScopedPointer< QScriptEngineAgentPrivated_ptr
 

Detailed Description

This class implements a state machine that uses the low-level events reported by the QScriptEngineAgent interface to implement debugging- specific functionality such as stepping and breakpoints.

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

It is used internally by the QScriptDebuggerBackend class.

Definition at line 68 of file qscriptdebuggeragent_p.h.

Constructors and Destructors

◆ QScriptDebuggerAgent()

QScriptDebuggerAgent::QScriptDebuggerAgent ( QScriptDebuggerBackendPrivate backend,
QScriptEngine engine 
)

Constructs a new agent for the given engine.

The agent will report debugging-related events (e.g. step completion) to the given backend.

Definition at line 92 of file qscriptdebuggeragent.cpp.

95 {
97  d->backend = backend;
98 
99  QScriptContext *ctx = engine->currentContext();
100  while (ctx) {
101  d->scriptIdStack.append(QList<qint64>());
102  d->contextIdStack.append(d->nextContextId);
103  ++d->nextContextId;
104  ctx = ctx->parentContext();
105  }
106 }
double d
Definition: qnumeric_p.h:62
The QScriptContext class represents a Qt Script function invocation.
QScriptEngineAgent(QScriptEngine *engine)
Constructs a QScriptEngineAgent object for the given engine.
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
QScriptDebuggerAgentPrivate * d_ptr
#define ctx
Definition: qgl.cpp:6094
QScriptContext * currentContext() const
Returns the current context.
QScriptContext * parentContext() const
Returns the parent context of this QScriptContext.

◆ ~QScriptDebuggerAgent()

QScriptDebuggerAgent::~QScriptDebuggerAgent ( )

Destroys this QScriptDebuggerAgent.

Definition at line 111 of file qscriptdebuggeragent.cpp.

112 {
114  if (d->backend)
115  d->backend->agentDestroyed(this);
116  delete d;
117 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

Functions

◆ breakpointData()

QScriptBreakpointData QScriptDebuggerAgent::breakpointData ( int  id) const

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

Definition at line 335 of file qscriptdebuggeragent.cpp.

336 {
337  Q_D(const QScriptDebuggerAgent);
338  return d->breakpoints.value(id);
339 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ breakpoints()

QScriptBreakpointMap QScriptDebuggerAgent::breakpoints ( ) const

Returns all breakpoints.

Definition at line 358 of file qscriptdebuggeragent.cpp.

359 {
360  Q_D(const QScriptDebuggerAgent);
361  return d->breakpoints;
362 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ contextIds()

QList< qint64 > QScriptDebuggerAgent::contextIds ( ) const

Definition at line 424 of file qscriptdebuggeragent.cpp.

425 {
426  Q_D(const QScriptDebuggerAgent);
427  return d->contextIdStack;
428 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ contextPop()

void QScriptDebuggerAgent::contextPop ( )
virtual

Reimplemented Function

Reimplemented from QScriptEngineAgent.

Definition at line 510 of file qscriptdebuggeragent.cpp.

511 {
513  d->scriptIdStack.removeLast();
514  d->contextIdStack.removeFirst();
515 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ contextPush()

void QScriptDebuggerAgent::contextPush ( )
virtual

Reimplemented Function

Reimplemented from QScriptEngineAgent.

Definition at line 499 of file qscriptdebuggeragent.cpp.

500 {
502  d->scriptIdStack.append(QList<qint64>());
503  d->contextIdStack.prepend(d->nextContextId);
504  ++d->nextContextId;
505 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ contextsCheckpoint()

QPair< QList< qint64 >, QList< qint64 > > QScriptDebuggerAgent::contextsCheckpoint ( )

Definition at line 430 of file qscriptdebuggeragent.cpp.

431 {
433  int i = d->checkpointContextIdStack.size() - 1;
434  int j = d->contextIdStack.size() - 1;
435  for ( ; (i >= 0) && (j >= 0); --i, --j) {
436  if (d->checkpointContextIdStack.at(i) != d->contextIdStack.at(j))
437  break;
438  }
439  QList<qint64> removed = d->checkpointContextIdStack.mid(0, i+1);
440  QList<qint64> added = d->contextIdStack.mid(0, j+1);
441  d->checkpointContextIdStack = d->contextIdStack;
442  return qMakePair(removed, added);
443 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102

◆ deleteAllBreakpoints()

void QScriptDebuggerAgent::deleteAllBreakpoints ( )

Deletes all breakpoints.

Definition at line 323 of file qscriptdebuggeragent.cpp.

324 {
326  d->breakpoints.clear();
327  d->resolvedBreakpoints.clear();
328  d->unresolvedBreakpoints.clear();
329 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ deleteBreakpoint()

bool QScriptDebuggerAgent::deleteBreakpoint ( int  id)

Deletes the breakpoint with the given id.

Returns true if the breakpoint was deleted, false if no such breakpoint exists.

Definition at line 272 of file qscriptdebuggeragent.cpp.

Referenced by positionChange().

273 {
275  if (!d->breakpoints.contains(id))
276  return false;
277  d->breakpoints.remove(id);
278  bool found = false;
279  {
280  QHash<qint64, QList<int> >::iterator it;
281  it = d->resolvedBreakpoints.begin();
282  for ( ; !found && (it != d->resolvedBreakpoints.end()); ) {
283  QList<int> &lst = it.value();
284  Q_ASSERT(!lst.isEmpty());
285  for (int i = 0; i < lst.size(); ++i) {
286  if (lst.at(i) == id) {
287  lst.removeAt(i);
288  found = true;
289  break;
290  }
291  }
292  if (lst.isEmpty())
293  it = d->resolvedBreakpoints.erase(it);
294  else
295  ++it;
296  }
297  }
298  if (!found) {
299  QHash<QString, QList<int> >::iterator it;
300  it = d->unresolvedBreakpoints.begin();
301  for ( ; !found && (it != d->unresolvedBreakpoints.end()); ) {
302  QList<int> &lst = it.value();
303  Q_ASSERT(!lst.isEmpty());
304  for (int i = 0; i < lst.size(); ++i) {
305  if (lst.at(i) == id) {
306  lst.removeAt(i);
307  found = true;
308  break;
309  }
310  }
311  if (lst.isEmpty())
312  it = d->unresolvedBreakpoints.erase(it);
313  else
314  ++it;
315  }
316  }
317  return found;
318 }
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ enterContinueMode()

void QScriptDebuggerAgent::enterContinueMode ( )

Instructs the agent to continue evaluation.

This function returns immediately.

Definition at line 168 of file qscriptdebuggeragent.cpp.

169 {
172 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ enterInterruptMode()

void QScriptDebuggerAgent::enterInterruptMode ( )

Instructs the agent to interrupt evaluation.

This function returns immediately.

Definition at line 178 of file qscriptdebuggeragent.cpp.

179 {
182 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ enterReturnByForceMode()

void QScriptDebuggerAgent::enterReturnByForceMode ( int  contextIndex,
const QScriptValue value 
)

Definition at line 212 of file qscriptdebuggeragent.cpp.

213 {
215  d->returnCounter = contextIndex + 1;
216  d->returnValue = QScriptValue();
218  // throw an exception; we will catch it when the proper frame is popped
219  engine()->currentContext()->throwValue(value);
220 }
double d
Definition: qnumeric_p.h:62
QScriptEngine * engine() const
Returns the QScriptEngine that this agent is associated with.
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
QScriptContext * currentContext() const
Returns the current context.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptValue throwValue(const QScriptValue &value)
Throws an exception with the given value.

◆ enterRunToLocationMode() [1/2]

void QScriptDebuggerAgent::enterRunToLocationMode ( const QString fileName,
int  lineNumber 
)

Instructs the agent to continue evaluation until the location described by fileName and lineNumber is reached.

This function returns immediately.

Definition at line 189 of file qscriptdebuggeragent.cpp.

190 {
192  d->targetFileName = fileName;
193  d->targetLineNumber = lineNumber;
194  d->targetScriptId = resolveScript(fileName);
196 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
qint64 resolveScript(const QString &fileName) const
Returns the identifier of the script that has the given fileName, or -1 if there is no such script...
static QString fileName(const QString &fileUrl)

◆ enterRunToLocationMode() [2/2]

void QScriptDebuggerAgent::enterRunToLocationMode ( qint64  scriptId,
int  lineNumber 
)

Instructs the agent to continue evaluation until the location described by scriptId and lineNumber is reached.

This function returns immediately.

Definition at line 203 of file qscriptdebuggeragent.cpp.

204 {
206  d->targetScriptId = scriptId;
207  d->targetFileName = QString();
208  d->targetLineNumber = lineNumber;
210 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ enterStepIntoMode()

void QScriptDebuggerAgent::enterStepIntoMode ( int  count = 1)

Instructs the agent to perform a "step into" operation.

This function returns immediately. The agent will report step completion at a later time, i.e. when script statements are evaluated.

Definition at line 124 of file qscriptdebuggeragent.cpp.

125 {
128  d->stepCount = count;
129  d->stepResult = QScriptValue();
130 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ enterStepOutMode()

void QScriptDebuggerAgent::enterStepOutMode ( )

Instructs the agent to perform a "step out" operation.

This function returns immediately. The agent will report step completion at a later time, i.e. when script statements are evaluated.

Definition at line 154 of file qscriptdebuggeragent.cpp.

155 {
158  if (engine()->isEvaluating())
159  d->stepDepth = 0;
160  else
161  d->stepDepth = -1;
162 }
double d
Definition: qnumeric_p.h:62
QScriptEngine * engine() const
Returns the QScriptEngine that this agent is associated with.
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ enterStepOverMode()

void QScriptDebuggerAgent::enterStepOverMode ( int  count = 1)

Instructs the agent to perform a "step over" operation.

This function returns immediately. The agent will report step completion at a later time, i.e. when script statements are evaluated.

Definition at line 137 of file qscriptdebuggeragent.cpp.

138 {
141  if (engine()->isEvaluating())
142  d->stepDepth = 0;
143  else
144  d->stepDepth = -1;
145  d->stepCount = count;
146  d->stepResult = QScriptValue();
147 }
double d
Definition: qnumeric_p.h:62
QScriptEngine * engine() const
Returns the QScriptEngine that this agent is associated with.
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ exceptionCatch()

void QScriptDebuggerAgent::exceptionCatch ( qint64  scriptId,
const QScriptValue exception 
)
virtual

Reimplemented Function

Reimplemented from QScriptEngineAgent.

Definition at line 697 of file qscriptdebuggeragent.cpp.

699 {
700  Q_UNUSED(scriptId);
701  Q_UNUSED(exception);
702 }
#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

◆ exceptionThrow()

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

Reimplemented Function

Reimplemented from QScriptEngineAgent.

Definition at line 680 of file qscriptdebuggeragent.cpp.

683 {
686  // we threw this exception ourselves, so ignore it for now
687  // (see functionExit()).
688  return;
689  }
690  if (d->backend)
691  d->backend->exception(scriptId, exception, hasHandler);
692 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ extension()

QVariant QScriptDebuggerAgent::extension ( Extension  extension,
const QVariant argument = QVariant() 
)
virtual

Reimplemented Function

Reimplemented from QScriptEngineAgent.

Definition at line 715 of file qscriptdebuggeragent.cpp.

717 {
721  QVariantList lst = argument.toList();
722  qint64 scriptId = lst.at(0).toLongLong();
723  int lineNumber = lst.at(1).toInt();
724  int columnNumber = lst.at(2).toInt();
726  if (d->backend) {
727  d->backend->debuggerInvocationRequest(
728  scriptId, lineNumber, columnNumber);
729  }
730  return QVariant();
731 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
Definition: qvariant.cpp:2751
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
QVariant extension(Extension extension, const QVariant &argument=QVariant())
Reimplemented Function
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
qlonglong toLongLong(bool *ok=0) const
Returns the variant as a long long int if the variant has type() LongLong , Bool , ByteArray , Char , Double , Int , String , UInt , or ULongLong ; otherwise returns 0.
Definition: qvariant.cpp:2659
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
__int64 qint64
Definition: qglobal.h:942
#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

◆ functionEntry()

void QScriptDebuggerAgent::functionEntry ( qint64  scriptId)
virtual

Reimplemented Function

Reimplemented from QScriptEngineAgent.

Definition at line 520 of file qscriptdebuggeragent.cpp.

521 {
523  QList<qint64> &ids = d->scriptIdStack.last();
524  ids.append(scriptId);
527  ++d->stepDepth;
528  }
529 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ functionExit()

void QScriptDebuggerAgent::functionExit ( qint64  scriptId,
const QScriptValue returnValue 
)
virtual

Reimplemented Function

Reimplemented from QScriptEngineAgent.

Definition at line 534 of file qscriptdebuggeragent.cpp.

536 {
537  Q_UNUSED(scriptId);
539  QList<qint64> &ids = d->scriptIdStack.last();
540  ids.removeLast();
542  --d->stepDepth;
543  } else if (d->state == QScriptDebuggerAgentPrivate::SteppingOutState) {
544  if (--d->stepDepth < 0) {
545  d->stepResult = returnValue;
547  }
549  if (--d->returnCounter == 0) {
550  d->returnValue = returnValue;
552  engine()->clearExceptions();
553  }
554  }
555 }
double d
Definition: qnumeric_p.h:62
QScriptEngine * engine() const
Returns the QScriptEngine that this agent is associated with.
void removeLast()
Removes the last item in the list.
Definition: qlist.h:287
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
void clearExceptions()
Clears any uncaught exceptions in this engine.
#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

◆ nullifyBackendPointer()

void QScriptDebuggerAgent::nullifyBackendPointer ( )

Definition at line 445 of file qscriptdebuggeragent.cpp.

Referenced by QScriptDebuggerBackendPrivate::~QScriptDebuggerBackendPrivate().

446 {
448  d->backend = 0;
449 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ positionChange()

void QScriptDebuggerAgent::positionChange ( qint64  scriptId,
int  lineNumber,
int  columnNumber 
)
virtual

Reimplemented Function

Reimplemented from QScriptEngineAgent.

Definition at line 560 of file qscriptdebuggeragent.cpp.

562 {
564  if (engine()->processEventsInterval() == -1) {
565  // see if it's time to call processEvents()
566  if ((++d->statementCounter % 25000) == 0) {
567  if (!d->processEventsTimer.isNull()) {
568  if (d->processEventsTimer.elapsed() > 30) {
570  d->processEventsTimer.restart();
571  }
572  } else {
573  d->processEventsTimer.start();
574  }
575  }
576  }
577 
578  // check breakpoints
579  {
580  QList<int> lst = d->resolvedBreakpoints.value(scriptId);
581  for (int i = 0; i < lst.size(); ++i) {
582  int id = lst.at(i);
583  QScriptBreakpointData &data = d->breakpoints[id];
584  if (!data.isEnabled())
585  continue;
586  if (data.lineNumber() != lineNumber)
587  continue;
588  if (!data.condition().isEmpty()) {
589  // ### careful, evaluate() can cause an exception
590  // ### disable callbacks in nested evaluate?
593  QScriptValue ret = engine()->evaluate(
594  data.condition(),
595  QString::fromLatin1("Breakpoint %0 condition checker").arg(id));
596  if (!ret.isError())
597  d->state = was;
598  if (!ret.toBoolean())
599  continue;
600  }
601  if (!data.hit())
602  continue;
603  d->hitBreakpointId = id;
605  }
606  }
607 
608  switch (d->state) {
612  // Do nothing
613  break;
614 
616  if (--d->stepCount == 0) {
618  if (d->backend)
619  d->backend->stepped(scriptId, lineNumber, columnNumber, QScriptValue());
620  }
621  break;
622 
624  if ((d->stepDepth > 0) || (--d->stepCount != 0))
625  break;
626  // fallthrough
629  if (d->backend)
630  d->backend->stepped(scriptId, lineNumber, columnNumber, d->stepResult);
631  break;
632 
635  if (d->backend)
636  d->backend->stepped(scriptId, lineNumber, columnNumber, d->stepResult);
637  break;
638 
640  if (((lineNumber == d->targetLineNumber) || (d->targetLineNumber == -1))
641  && (scriptId == d->targetScriptId)) {
643  if (d->backend)
644  d->backend->locationReached(scriptId, lineNumber, columnNumber);
645  }
646  break;
647 
650  if (d->backend)
651  d->backend->interrupted(scriptId, lineNumber, columnNumber);
652  break;
653 
656  if (d->backend)
657  d->backend->breakpoint(scriptId, lineNumber, columnNumber, d->hitBreakpointId);
658  if (d->breakpoints.value(d->hitBreakpointId).isSingleShot())
659  deleteBreakpoint(d->hitBreakpointId);
660  break;
661 
664  if (d->backend)
665  d->backend->forcedReturn(scriptId, lineNumber, columnNumber, d->returnValue);
666  break;
667 
671 // ### deal with the case when code is evaluated while we're already paused
672 // Q_ASSERT(false);
673  break;
674  }
675 }
double d
Definition: qnumeric_p.h:62
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...
QScriptEngine * engine() const
Returns the QScriptEngine that this agent is associated with.
bool isError() const
Returns true if this QScriptValue is an object of the Error class; otherwise returns false...
#define Q_D(Class)
Definition: qglobal.h:2482
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Processes all pending events for the calling thread according to the specified flags until there are ...
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static const char * data(const QByteArray &arr)
The QScriptBreakpointData class contains data associated with a breakpoint.
bool toBoolean() const
Use toBool() instead.
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
bool isEnabled() const
Returns true if the breakpoint is enabled, false otherwise.
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
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
if(void) toggleToolbarShown
bool deleteBreakpoint(int id)
Deletes the breakpoint with the given id.
QString condition() const
Returns the condition of the breakpoint.
bool hit()
If the ignore count is 0, this function increments the hit count and returns true.
int lineNumber() const
Returns the breakpoint line number.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ resolveScript()

qint64 QScriptDebuggerAgent::resolveScript ( const QString fileName) const

Returns the identifier of the script that has the given fileName, or -1 if there is no such script.

Definition at line 413 of file qscriptdebuggeragent.cpp.

Referenced by enterRunToLocationMode().

414 {
415  Q_D(const QScriptDebuggerAgent);
417  for (it = d->scripts.constBegin(); it != d->scripts.constEnd(); ++it) {
418  if (it.value().fileName() == fileName)
419  return it.key();
420  }
421  return -1;
422 }
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
static QString fileName(const QString &fileUrl)

◆ scriptData()

QScriptScriptData QScriptDebuggerAgent::scriptData ( qint64  id) const

Returns the data associated with the script with the given id.

Definition at line 376 of file qscriptdebuggeragent.cpp.

Referenced by QScriptDebuggerBackendPrivate::breakpoint(), QScriptDebuggerBackendPrivate::debuggerInvocationRequest(), QScriptDebuggerBackendPrivate::exception(), QScriptDebuggerBackendPrivate::forcedReturn(), QScriptDebuggerBackendPrivate::interrupted(), QScriptDebuggerBackendPrivate::locationReached(), and QScriptDebuggerBackendPrivate::stepped().

377 {
378  Q_D(const QScriptDebuggerAgent);
379  return d->scripts.value(id);
380 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ scriptLoad()

void QScriptDebuggerAgent::scriptLoad ( qint64  id,
const QString program,
const QString fileName,
int  baseLineNumber 
)
virtual

Reimplemented Function

Reimplemented from QScriptEngineAgent.

Definition at line 454 of file qscriptdebuggeragent.cpp.

456 {
458  QScriptScriptData data = QScriptScriptData(program, fileName, baseLineNumber);
459  d->scripts.insert(id, data);
460 
462  && (d->targetScriptId == -1)
463  && ((d->targetFileName == fileName) || d->targetFileName.isEmpty())) {
464  d->targetScriptId = id;
465  }
466 
467  if (!fileName.isEmpty()) {
468  QList<int> lst = d->unresolvedBreakpoints.take(fileName);
469  if (!lst.isEmpty())
470  d->resolvedBreakpoints.insert(id, lst);
471  }
472 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
The QScriptScriptData class holds data associated with a script.
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static const char * data(const QByteArray &arr)

◆ scripts()

QScriptScriptMap QScriptDebuggerAgent::scripts ( ) const

Returns all scripts.

Definition at line 367 of file qscriptdebuggeragent.cpp.

368 {
369  Q_D(const QScriptDebuggerAgent);
370  return d->scripts;
371 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ scriptsCheckpoint()

void QScriptDebuggerAgent::scriptsCheckpoint ( )

Checkpoints the current scripts.

Definition at line 385 of file qscriptdebuggeragent.cpp.

386 {
388  d->previousCheckpointScripts = d->checkpointScripts;
389  d->checkpointScripts = d->scripts;
390 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...

◆ scriptsDelta()

QPair< QList< qint64 >, QList< qint64 > > QScriptDebuggerAgent::scriptsDelta ( ) const

Returns the difference between the current 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.

Definition at line 399 of file qscriptdebuggeragent.cpp.

400 {
401  Q_D(const QScriptDebuggerAgent);
402  QSet<qint64> prevSet = d->previousCheckpointScripts.keys().toSet();
403  QSet<qint64> currSet = d->checkpointScripts.keys().toSet();
404  QSet<qint64> addedScriptIds = currSet - prevSet;
405  QSet<qint64> removedScriptIds = prevSet - currSet;
406  return qMakePair(addedScriptIds.toList(), removedScriptIds.toList());
407 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
QList< T > toList() const
Definition: qset.h:296
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102

◆ scriptUnload()

void QScriptDebuggerAgent::scriptUnload ( qint64  id)
virtual

Reimplemented Function

Reimplemented from QScriptEngineAgent.

Definition at line 477 of file qscriptdebuggeragent.cpp.

478 {
480  QScriptScriptData data = d->scripts.take(id);
481  QString fileName = data.fileName();
482 
484  && (d->targetScriptId == id)) {
485  d->targetScriptId = -1;
486  d->targetFileName = fileName;
487  }
488 
489  if (!fileName.isEmpty()) {
490  QList<int> lst = d->resolvedBreakpoints.take(id);
491  if (!lst.isEmpty())
492  d->unresolvedBreakpoints.insert(fileName, lst);
493  }
494 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
The QScriptScriptData class holds data associated with a script.
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static const char * data(const QByteArray &arr)
static QString fileName(const QString &fileUrl)
QString fileName() const

◆ setBreakpoint()

int QScriptDebuggerAgent::setBreakpoint ( const QScriptBreakpointData data)

Sets a breakpoint defined by the given data.

Returns an integer that uniquely identifies the new breakpoint, or -1 if setting the breakpoint failed.

Definition at line 227 of file qscriptdebuggeragent.cpp.

228 {
230  qint64 scriptId = data.scriptId();
231  if (scriptId != -1) {
232  if (!d->scripts.contains(scriptId)) {
233  // that script has been unloaded, so invalidate the ID
234  scriptId = -1;
235  const_cast<QScriptBreakpointData&>(data).setScriptId(-1);
236  } else if (data.fileName().isEmpty()) {
237  QString fileName = d->scripts[scriptId].fileName();
238  const_cast<QScriptBreakpointData&>(data).setFileName(fileName);
239  }
240  }
241 
242  int id = d->nextBreakpointId;
243  ++d->nextBreakpointId;
244 
245  if (scriptId != -1) {
246  d->resolvedBreakpoints[scriptId].append(id);
247  } else {
248  QString fileName = data.fileName();
249  bool resolved = false;
251  for (it = d->scripts.constBegin(); it != d->scripts.constEnd(); ++it) {
252  if (it.value().fileName() == fileName) {
253  d->resolvedBreakpoints[it.key()].append(id);
254  resolved = true;
255  break;
256  }
257  }
258  if (!resolved)
259  d->unresolvedBreakpoints[fileName].append(id);
260  }
261 
262  d->breakpoints.insert(id, data);
263 
264  return id;
265 }
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static const char * data(const QByteArray &arr)
__int64 qint64
Definition: qglobal.h:942
The QScriptBreakpointData class contains data associated with a breakpoint.
static QString fileName(const QString &fileUrl)

◆ setBreakpointData()

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

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

Definition at line 345 of file qscriptdebuggeragent.cpp.

347 {
349  if (!d->breakpoints.contains(id))
350  return false;
351  d->breakpoints[id] = data;
352  return true;
353 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
This class implements a state machine that uses the low-level events reported by the QScriptEngineAge...
static const char * data(const QByteArray &arr)

◆ supportsExtension()

bool QScriptDebuggerAgent::supportsExtension ( Extension  extension) const
virtual

Reimplemented Function

Reimplemented from QScriptEngineAgent.

Definition at line 707 of file qscriptdebuggeragent.cpp.

708 {
710 }
QVariant extension(Extension extension, const QVariant &argument=QVariant())
Reimplemented Function

Properties

◆ d_ptr

QScriptDebuggerAgentPrivate* QScriptDebuggerAgent::d_ptr
private

Definition at line 128 of file qscriptdebuggeragent_p.h.


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