0

Let's say I:

dune init proj foobar
cd foobar

Then modify test/test_foobar.ml to be:

let () = print_endline "First"
let () = print_endline "Second"
let () = print_endline "Third"

I can execute the program with dune test.
How can I run the program and step each line individually in a debugger with source available? Either ocamldebug or gdb is probably fine.

I can do gdb --tui --args ./_build/default/test/test_foobar.exe but it does NOT show the source.

I don't see any suitable files to launch with ocamldebug e.g.:

$ ocamldebug ./_build/default/test/test_foobar.ml
    OCaml Debugger version 5.2.0

(ocd) r
Loading program... < shortened >/foobar/./_build/default/test/test_foobar.ml is not a bytecode file.

Working with OCaml 5.2.0 and dune 3.15.3

1

1 Answer 1

1

Add (modes byte exe) to your test/dune file to cause a byte-code version to be built also e.g. _build/default/test/test_foobar.bc which can be run in ocamldebug.

The test/dune file:

(test
 (name test_foobar)
 (modes byte exe)
)

Unresolved: how to have the source present when running in gdb.

Not the answer you're looking for? Browse other questions tagged or ask your own question.