voglerr
voglerr

Reputation: 943

Tracing and debugging in OCaml

What do you use for tracing and debugging in OCaml?

For debugging I tried ocamldebug and the Emacs plugin.

For tracing I want to be able to print the data constructor of every variable. An example using Camlp4 is shown here: http://caml.inria.fr/pub/docs/tutorial-camlp4/tutorial007.html#toc52

   type colour = Red | Green | Blue
   let print_colour =
     function
       Red -> print_string "Red"
     | Green -> print_string "Green"
     | Blue -> print_string "Blue"

Upvotes: 11

Views: 2790

Answers (1)

Fabrice Le Fessant
Fabrice Le Fessant

Reputation: 4274

ocamldebug works fine when you can use bytecode.

If you want to debug a native code application, there is a patch by Thomas gazagnaire on Mantis that allows to step line by line in the OCaml program using gdb. Parts of this patch should be integrated in the next version of OCaml (3.13 or 4.00).

Currently, however, there is no way to print OCaml values, but another patch is coming, using GADT's to define a generic printer function for any type.

Upvotes: 10

Related Questions