16.10 Running the debugger under Emacs

The most user-friendly way to use the debugger is to run it under Emacs. See the file emacs/README in the distribution for information on how to load the Emacs Lisp files for Caml support.

The Caml debugger is started under Emacs by the command M-x camldebug, with argument the name of the executable file progname to debug. Communication with the debugger takes place in an Emacs buffer named *camldebug-progname*. The editing and history facilities of Shell mode are available for interacting with the debugger.

In addition, Emacs displays the source files containing the current event (the current position in the program execution) and highlights the location of the event. This display is updated synchronously with the debugger action.

The following bindings for the most common debugger commands are available in the *camldebug-progname* buffer:

C-c C-s

(command step): execute the program one step forward.

C-c C-k

(command backstep): execute the program one step backward.

C-c C-n

(command next): execute the program one step forward, skipping over function calls.

Middle mouse button

(command display): display named value. $n under mouse cursor (support incremental browsing of large data structures).

C-c C-p

(command print): print value of identifier at point.

C-c C-d

(command display): display value of identifier at point.

C-c C-r

(command run): execute the program forward to next breakpoint.

C-c C-v

(command reverse): execute the program backward to latest breakpoint.

C-c C-l

(command last): go back one step in the command history.

C-c C-t

(command backtrace): display backtrace of function calls.

C-c C-f

(command finish): run forward till the current function returns.

C-c <

(command up): select the stack frame below the current frame.

C-c >

(command down): select the stack frame above the current frame.

In all buffers in Caml editing mode, the following debugger commands are also available:

C-x C-a C-b

(command break): set a breakpoint at event closest to point

C-x C-a C-p

(command print): print value of identifier at point

C-x C-a C-d

(command display): display value of identifier at point