Debugger support for OCaml

I agree that debugging in OCaml seems to be stuck in time.

This is extremely unfortunate because it is able to do time traveling (as you mention) which is something that many other languages still cannot boast.

  • ocamldebug does not work properly when there is more than 1 OS thread
  • As types are erased during compile time in OCaml, it can be difficult to debug polymorphic functions. Rust and C/C++ monomorphise all code so there is never any confusion about the type of anything in the debugger. Golang and Java have type information available during runtime so again, debugging is easy. In this respect OCaml is similar to Haskell while using the byte-code debugger.
  • The future of ocamldebug is unknown on multicore

As far as GDB support is concerned, there was a project to improve GDB support (so you could print out variables like in ocamldebug IIUC) but it never got merged into trunk.

However, if you are interested in low level debugging in gdb, here is a recent answer related to this.

My guess is that ocamldebug will continue to work for the single domain, single thread case in OCaml 5.00 but ocamldebug is currently broken in multicore there (AFAIK).

4 Likes