4.4.4.6 Debug Commands

These debugging commands are only available within a recursive REPL; they do not work at the top level.

REPL Command: backtrace [count] [#:width w] [#:full? f]

Print a backtrace.

Print a backtrace of all stack frames, or innermost count frames. If count is negative, the last count frames will be shown.

REPL Command: up [count]

Select a calling stack frame.

Select and print stack frames that called this one. An argument says how many frames up to go.

REPL Command: down [count]

Select a called stack frame.

Select and print stack frames called by this one. An argument says how many frames down to go.

REPL Command: frame [idx]

Show a frame.

Show the selected frame. With an argument, select a frame by index, then show it.

REPL Command: locals

Show local variables.

Show locally-bound variables in the selected frame.

REPL Command: error-message
REPL Command: error

Show error message.

Display the message associated with the error that started the current debugging REPL.

REPL Command: registers

Show the VM registers associated with the current frame.

See Stack Layout, for more information on VM stack frames.

REPL Command: width [cols]

Sets the number of display columns in the output of ,backtrace and ,locals to cols. If cols is not given, the width of the terminal is used.

The next 3 commands work at any REPL.

REPL Command: break proc

Set a breakpoint at proc.

REPL Command: break-at-source file line

Set a breakpoint at the given source location.

REPL Command: tracepoint proc

Set a tracepoint on the given procedure. This will cause all calls to the procedure to print out a tracing message. See Tracing Traps, for more information.

The rest of the commands in this subsection all apply only when the stack is continuable — in other words when it makes sense for the program that the stack comes from to continue running. Usually this means that the program stopped because of a trap or a breakpoint.

REPL Command: step

Tell the debugged program to step to the next source location.

REPL Command: next

Tell the debugged program to step to the next source location in the same frame. (See Traps for the details of how this works.)

REPL Command: finish

Tell the program being debugged to continue running until the completion of the current stack frame, and at that time to print the result and reenter the REPL.