Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
like image 321
voglerr Avatar asked Nov 10 '11 10:11

voglerr


1 Answers

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.

like image 187
Fabrice Le Fessant Avatar answered Sep 22 '22 17:09

Fabrice Le Fessant