Current state of OCamldebug

I tend to use debuggers a lot, generally speaking, while programming in various languages (even though purists may scoff at them). I’d love to get a feel of the debugging story in OCaml today.

Now we have some native debugging support being built by @mshinwell et all. Then we have ocamldebug for debugging bytecode. I’d like to understand from people if this is a practical debugger or has bit-rotted away somewhat…

It seems from How do you Debug Ocaml? (in 2017) @gasche points out issues with ocamldebug. Have things improved in 2019?

Can someone give me a feel of the overall state of debugging in ocamldebug is today?

Also specifically:

  • Using ocamldebug can I debug programs that make use of libraries like ctypes and cstruct? (I realize I won’t be able to get into the C-code side of things but will debugging work properly in presence of functions that make FFI calls?)
  • How reliable is ocamldebug when debugging code when there are things like unix signal handlers installed in your OCaml program? I ask this question because I want to do a bit of linux “system” programming in OCaml but I want to be sure if I will be able to reach out to the debugger when things start going wrong… I know I can use gdb on my native executable even today but the experience is not going to be very good is it?
  • How robust is the ocamldebug debugger generally?
  • What would be the kind of slowdown I should expect using ocamldebug vs say, gdb (with the proposed DWARF integration work being done by @mshinwell) ?
  • How usable is record-replay for a program that is, say, ~20k lines of code in ocamldebug?
  • Are there problems when debugging code that has a lot of ppx extensions in it?

I know these are a huge number of questions. Please answer as few (or as many) as you want :slight_smile: !

2 Likes

I use the debugger a lot when working in Python. There it’s very powerful because I can inspect and potentially modify any value. When using ocamldebug, I’m usually discouraged by the effort it takes to tell the debugger how to print values. That is already more cumbersome in ocaml due to the need to define one’s own printing functions, but in the debugger the absence of automatic locating and loading of printing functions makes it more so. I then often resort to printf.

If this were improved I would think ocamldebug would be already quite a bit more useful to me. However, I don’t know if it will ever be possible to allow evaluation of code in the debugger (‘introspection’) given it’s design. That means, e.g. testing the length of a list at a certain point during evaluation will probably remain out of reach.

I dimly recall a few instances where the debugger would appear to hang for a program that otherwise ran successfully, but it’s rare ime.

ocamldebug is bytecode, and is noticeably (3x?) slower than usual bytecode. So don’t expect to be able to debug compute-intensive programs without modification.

1 Like

@n4323 Thank for sharing your experience with ocamldebug! Appreciate it.