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"
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"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您可以使用字节码时,
ocamldebug
可以正常工作。如果您想调试本机代码应用程序,可以使用 Thomas gazagnaire 提供的补丁 在 Mantis 上,允许使用 gdb 在 OCaml 程序中逐行执行。该补丁的部分内容应集成到下一版本的 OCaml(3.13 或 4.00)中。
然而,目前还没有办法打印 OCaml 值,但另一个补丁即将推出,使用 GADT 为任何类型定义通用打印机函数。
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.