# Enhancing Ocaml Debugging Experience in Visual Studio Code

**URL:** <https://discuss.ocaml.org/t/enhancing-ocaml-debugging-experience-in-visual-studio-code/12236>\
**Category:** Learning\
**Tags:** ocamldebug, compiler, opam, build, dune\
**Created:** [May 26, 2023, 1:19pm UTC](https://discuss.ocaml.org/t/enhancing-ocaml-debugging-experience-in-visual-studio-code/12236 "2023-05-26T13:19:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![support](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@support](https://discuss.ocaml.org/u/support)\
**Post date:** [May 26, 2023, 1:19pm UTC](https://discuss.ocaml.org/t/enhancing-ocaml-debugging-experience-in-visual-studio-code/12236/1 "2023-05-26T13:19:59Z")

</div>

Hi all,

**Ocaml debugger for Visual Studio Code**

`I am trying to provide full language support for Ocaml in Visual Studio Code. I have already installed this extension. Now, I want to debug my Ocaml source code within Visual Studio Code. I have also installed the Ocaml Debugger extension. However, it does not even provide an option to create a launch file. Do you have any suggestions for debugging Ocaml code? I really need it as I am new to Ocaml and I am working on another developer's extensive code base. Having a debugger will greatly help me understand it in less time.`

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [May 26, 2023, 2:42pm UTC](https://discuss.ocaml.org/t/enhancing-ocaml-debugging-experience-in-visual-studio-code/12236/2 "2023-05-26T14:42:29Z")

</div>

The only support for debugging inside VS Code is [GitHub - hackwaly/ocamlearlybird: OCaml debug adapter](https://github.com/hackwaly/ocamlearlybird/) but sadly it is not being actively maintained (judging by the README it only supports 4.11 and 4.12). And in any case since it is an adaptor for `ocamldebug` it only supports bytecode.

Until better alternatives come along, I suggest you get used to the time-tested debugging technique practiced by OCaml experts and beginners alike with unsurpassed effectiveness: [`printf` debugging.](https://www.azquotes.com/quote/721056)

Cheers,  
Nicolas

---

<div class="post-metadata">

**Author:** ![lukstafi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lukstafi/32/3442_2.png) [@lukstafi](https://discuss.ocaml.org/u/lukstafi)\
**Post date:** [May 26, 2023, 3:35pm UTC](https://discuss.ocaml.org/t/enhancing-ocaml-debugging-experience-in-visual-studio-code/12236/3 "2023-05-26T15:35:58Z")

</div>

There are [`ppx_debug`](https://github.com/dariusf/ppx_debug) and [`ppx_interact`](https://github.com/dariusf/ppx_interact). The associated [VS Code extension](https://github.com/dariusf/ppx_debug-vscode).

P.S. [`ppx_minidebug`](https://github.com/lukstafi/ppx_minidebug) might be easier to install (although not on opam yet.).

---

<div class="post-metadata">

**Author:** ![jbeckford](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/jbeckford/32/3027_2.png) [@jbeckford](https://discuss.ocaml.org/u/jbeckford)\
**Post date:** [May 26, 2023, 5:31pm UTC](https://discuss.ocaml.org/t/enhancing-ocaml-debugging-experience-in-visual-studio-code/12236/4 "2023-05-26T17:31:30Z")

</div>

I’ve been scratching my head because earlier this week I accidentally had working breakpoints (in `.ml` source files) for native code in Visual Studio Code. Kinda flabbergasted that I’ve been using OCaml for two years and never knew I could do that.

Just for Linux and macOS, not Windows, although I think I understand the (small) gap on Windows. And no printing of the runtime `value` type yet.

If there is interest, I can figure out how to post a show and tell video on YouTube. Definitely for intermediate-to-advanced OCaml users only though: my setup involves the `-output-complete-obj` and I’m using my [DkSDK](https://diskuv.com/cmake/help/latest/) product to tweak a zillion things. But underneath it is just options in the C + ASM compiler, the OCaml compiler and Dune which I can show, and perhaps it may motivate someone to wrap it up in a friendly way for beginners. And perhaps it will motivate someone to wrap up a runtime `value` printer [1] using [natvis](https://code.visualstudio.com/docs/cpp/natvis).

And perhaps it is already common knowledge! If not, “like” this post so I can get a sense if it is worth spending time on a video.

[1]: Bonus: A real pretty printer if the sibling `value` in a C stub function was a LexiFi/`refl`/etc. RTTI `value`.

---

<div class="post-metadata">

**Author:** ![support](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@support](https://discuss.ocaml.org/u/support)\
**Post date:** [May 27, 2023, 7:33am UTC](https://discuss.ocaml.org/t/enhancing-ocaml-debugging-experience-in-visual-studio-code/12236/5 "2023-05-27T07:33:12Z")

</div>

Thank you for your response.  
My Ocaml version is 4.14. if possible for debugging ?

---

<div class="post-metadata">

**Author:** ![support](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@support](https://discuss.ocaml.org/u/support)\
**Post date:** [May 27, 2023, 8:19am UTC](https://discuss.ocaml.org/t/enhancing-ocaml-debugging-experience-in-visual-studio-code/12236/6 "2023-05-27T08:19:22Z")

</div>

Hi @lukstafi ,

Thank you for your response. I cloned this project (link: [GitHub - dariusf/ppx\_debug: Tools for record-and-replay debugging](https://github.com/dariusf/ppx_debug)). Inside the demo folder in this repository, there is no readme file. Please let me know the commands for how to run this folder for debugging. I have attached a screenshot to this message.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/ocaml/original/2X/3/3da9d1ee677e0c8b8fc0679439981dd9650397f3.png)

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![beajeanm](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/beajeanm/32/189_2.png) [@beajeanm](https://discuss.ocaml.org/u/beajeanm)\
**Post date:** [May 28, 2023, 6:16pm UTC](https://discuss.ocaml.org/t/enhancing-ocaml-debugging-experience-in-visual-studio-code/12236/7 "2023-05-28T18:16:06Z")

</div>

There is a link to a tutorial on the readme of the project, have you tried that first?

---

<div class="post-metadata">

**Author:** ![Gopiandcode](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/gopiandcode/32/5346_2.png) [@Gopiandcode](https://discuss.ocaml.org/u/Gopiandcode)\
**Post date:** [May 29, 2023, 1:02am UTC](https://discuss.ocaml.org/t/enhancing-ocaml-debugging-experience-in-visual-studio-code/12236/8 "2023-05-29T01:02:44Z")

</div>

The author (@dariusf ) is also on the discuss forum — he might be able to help.
