Ocaml debugger for Visual Studio Code

Hello,

I am trying to give full language support for OCaml in Visual Studio Code.
I have already installed this extension : https://marketplace.visualstudio.com/items?itemName=freebroccolo.reasonml
This gave me possibility to the features like code completion, jump to definition etc. But it does not provide debugging feature.

I want to debug my OCaml source code inside Visual Studio Code.
I already installed this Ocaml Debugger extension : https://marketplace.visualstudio.com/items?itemName=hackwaly.ocaml-debugger

But it does not even provide an option to create launch file.

Do you have any suggestion to debug the Ocaml code?
I really need it as I am new to Ocaml and I am working on another developer’s big code base and debugger will help me to understand it in less time.

Thank you in advance.

1 Like

There exist an ocaml debugger, but personally I havn’t had much sucessful experience in using it - so I would recommend that you use print-debugging as an OCaml newcomer

Have you tried the example launch configuration in the README?

A few things to keep in mind:

  • You need to install the debug adapter first (opam install earlybird)
  • You may need to create the launch.json file manually (under the .vscode directory in your project).
  • The debugger only works with bytecode executables. Depending on your build system, you may need to build the bytecode executable first. If you are using dune, you can do that easily (e.g. dune build src/main.bc).

Hope this helps.

1 Like

hi @hongchangwu ,
I followed your instructions, including the video, but I encountered an error while executing the “make examples” commands. Could you please suggest a solution for resolving this error? I have attached a screenshot of the error to this post.

thanks,