16.7 Examining variable values

The debugger can print the current value of simple expressions. The expressions can involve program variables: all the identifiers that are in scope at the selected program point can be accessed.

Expressions that can be printed are a subset of Objective Caml expressions, as described by the following grammar:

simple-expr ::= lowercase-ident
| { capitalized-ident . } lowercase-ident
| *
| $ integer
| simple-expr . lowercase-ident
| simple-expr .( integer )
| simple-expr .[ integer ]
| ! simple-expr
| ( simple-expr )

The first two cases refer to a value identifier, either unqualified or qualified by the path to the structure that define it. * refers to the result just computed (typically, the value of a function application), and is valid only if the selected event is an "after" event (typically, a function application). $ integer refer to a previously printed value. The remaining four forms select part of an expression: respectively, a record field, an array element, a string element, and the current contents of a reference.

print variables

Print the values of the given variables. print can be abbreviated as p.

display variables

Same as print, but limit the depth of printing to 1. Useful to browse large data structures without printing them in full. display can be abbreviated as d.

When printing a complex expression, a name of the form $integer is automatically assigned to its value. Such names are also assigned to parts of the value that cannot be printed because the maximal printing depth is exceeded. Named values can be printed later on with the commands p $integer or d $integer. Named values are valid only as long as the program is stopped. They are forgotten as soon as the program resumes execution.

set print_depth d

Limit the printing of values to a maximal depth of d.

set print_length l

Limit the printing of values to at most l nodes printed.