OCaml 中的跟踪和调试

发布于 2024-12-15 04:07:52 字数 506 浏览 2 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤独患者 2024-12-22 04:07:52

当您可以使用字节码时,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文