Debugging and Profiling OCaml – lessons (re)learned
Links
- OCaml.org tutorial on debugging
- ppx_minidebug, a debugging and logging framework.
- Debugging Native Code Binaries in Real World OCaml
- KC Sivaramakrishnan’s Getting Started with GDB on OCaml
- Javier
Chávarri’s Profiling Dune Builds – a brief coverage of
perfandmemtrace - vg-b’s
workaround for some
perfproblems (the need forocaml-option-fp) - Tianyi Song’s Profiling OCaml programs the quick and dirty way about using Landmarks. Has precise timing (CPU cycles), both manual and automatic annotation (PPX based), callgraph visualization.
- Debugging OCaml with Emacs – setting up bytecode and native debugging.
- Bytecode debugging in OCaml 5.3
- Vincent Laviron brings up rr as an alternative to gdb. It’s Linux only, it combines native debugging like GDB with tracing.
- A tool to reverse debug OCaml/other binary runs – Bringing Record and Replay everywhere by Sid Kshatriya
Don’t forget
- Use Valgrind to debug memory corruption.
- Symptoms: random crashes in garbage collection, in
ctypescode, in system libraries etc. - Example invocation:
valgrind --leak-check=full --leak-resolution=high --show-leak-kinds=all --errors-for-leak-kinds=none _build/default/bin/example.exe
- Symptoms: random crashes in garbage collection, in
- Use GDB when the program hangs to quickly see the stack trace.
- If you use
landmarksto compare performances of parts within a program run: it seems that the optional wallclock timer is not reset properly between restarts.