Previous Contents Next
Chapter 15 The debugger (ocamldebug)

This chapter describes the Objective Caml source-level replay debugger ocamldebug.

  Unix:
The debugger is available on Unix systems that provides BSD sockets.
  Windows:
The debugger is available under the Cygwin port of Objective Caml, but not under the native Win32 port.
  MacOS:
The debugger is not available.
15.1 Compiling for debugging

Before the debugger can be used, the program must be compiled and linked with the -g option: all .cmo and .cma files that are part of the program should have been created with ocamlc -g, and they must be linked together with ocamlc -g.

Compiling with -g entails no penalty on the running time of programs: object files and bytecode executable files are bigger and take longer to produce, but the executable files run at exactly the same speed as if they had been compiled without -g.

15.2 Invocation

15.2.1 Starting the debugger

The Objective Caml debugger is invoked by running the program ocamldebug with the name of the bytecode executable file as first argument:
        ocamldebug [options] program [arguments]
The arguments following program are optional, and are passed as command-line arguments to the program being debugged. (See also the set arguments command.)

The following command-line options are recognized:
-I directory
Add directory to the list of directories searched for source files and compiled files. (See also the directory command.)

-s socket
Use socket for communicating with the debugged program. See the description of the command set socket (section 15.8.6) for the format of socket.

-c count
Set the maximum number of simultaneously live checkpoints to count.

-cd directory
Run the debugger program from the working directory directory, instead of the current directory. (See also the