Skip to content

SpecificationXIII · The engine inside

13.5

Observing execution

Execution can be watched step by step: the engine emits a trace of events, and every event carries what changed in memory.

Markdown version

13.5.1 How it works

A step is the interval between two consecutive trace events: entering a statement, taking a decision, writing, calling, returning. Advancing one step delivers exactly the next event; there is nothing smaller.

The debugger's moves are built on events:

MoveUntil
next statementthe next statement of the same frame or an outer one
step intothe next statement, even inside a call
step outthe return that closes the current frame
Figure 13.5-1.Every trace event is a step. The memory state at any event is rebuilt by adding up the changes from the start.

A line with five events: enter, decision, write, exit and end. An arc between two events marks a step. Below, a state change: n = 3.

ProgramA program to watch

Algorithm Observar
  Define n As Integer <- 3;
  If n > 2 Then
    Write "grande";
  EndIf
EndAlgorithm

Output

grande

The program finishes normally.

Trace

LineEvent
2enters statement
3enters statement
3decision · true branch
4enters statement
4writes · grande

Every event can carry the state change: written variables, created objects, frames pushed or popped. Adding up the changes from the start gives the full state at any event, and asking about a past event again always gives the same answer. Events are delivered in batches of whatever size the host prefers, without losses or duplicates.

In short

  • The trace is the list of events; a step is an event.
  • Next, step into and step out are defined on events.
  • State changes rebuild memory at any point.