Events are "interesting" locations in the source code, corresponding to the beginning or end of evaluation of "interesting" sub-expressions. Events are the unit of single-stepping (stepping goes to the next or previous event encountered in the program execution). Also, breakpoints can only be set at events. Thus, events play the role of line numbers in debuggers for conventional languages.
During program execution, a counter is incremented at each event encountered. The value of this counter is referred as the current time. Thanks to reverse execution, it is possible to jump back and forth to any time of the execution.
Here is where the debugger events (written §§) are located in the source code:
fun x y z -> §§ ...
function pat1 -> §§ expr1 | ... | patN -> §§ exprN
expr1; §§ expr2; §§ ...; §§ exprN
if cond then §§ expr1 else §§ expr2
while cond do §§ body done for i = a to b do §§ body done
Exceptions: A function application followed by a function return is replaced by the compiler by a jump (tail-call optimization). In this case, no event is put after the function application.
The debugger starts executing the debugged program only when needed. This allows setting breapoints or assigning debugger variables before execution starts. There are several ways to start execution:
Run the program until a breakpoint is hit, or the program terminates.
Load the program and stop on the first event.
Load the program and execute it until the given time. Useful when you already know approximately at what time the problem appears. Also useful to set breakpoints on function values that have not been computed at time 0 (see section 16.5).
The execution of a program is affected by certain information it receives when the debugger starts it, such as the command-line arguments to the program and its working directory. The debugger provides commands to specify this information (set arguments and cd). These commands must be used before program execution starts. If you try to change the arguments or the working directory after starting your program, the debugger will kill the program (after asking for confirmation).
The following commands execute the program forward or backward, starting at the current time. The execution will stop either when specified by the command or when a breakpoint is encountered.
Execute the program forward from current time. Stops at next breakpoint or when the program terminates.
Execute the program backward from current time. Mostly useful to go to the last breakpoint encountered before the current time.
Run the program and stop at the next event. With an argument, do it count times.
Run the program backward and stop at the previous event. With an argument, do it count times.
Run the program and stop at the next event, skipping over function calls. With an argument, do it count times.
Run the program backward and stop at the previous event, skipping over function calls. With an argument, do it count times.
Run the program until the current function returns.
Run the program backward and stop at the first event before the current function invocation.
You can jump directly to a given time, without stopping on breakpoints, using the goto command.
As you move through the program, the debugger maintains an history of the successive times you stop at. The last command can be used to revisit these times: each last command moves one step back through the history. That is useful mainly to undo commands such as step and next.
Jump to the given time.
Go back to the latest time recorded in the execution history. With an argument, do it count times.
Set the size of the execution history.