vog*_*err 9 debugging trace ocaml
你在OCaml中用什么跟踪和调试?
为了调试我尝试了ocamldebug和Emacs插件.
对于跟踪,我希望能够打印每个变量的数据构造函数.使用Camlp4的示例如下所示: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"
Run Code Online (Sandbox Code Playgroud)
ocamldebug 当你可以使用字节码时工作正常.
如果你想调试本机代码应用程序,Thomas Gazagnaire在Mantis上有一个补丁,允许使用gdb在OCaml程序中逐行执行.该补丁的部分内容应集成在下一版本的OCaml(3.13或4.00)中.
然而,目前,没有办法打印OCaml值,但是另一个补丁即将到来,使用GADT为任何类型定义通用打印机功能.