"not a bytecode file" error message in ocamldebug

Here is my short sequence of commands :

$ ocamlc -bin-annot -g str.cma unix.cma -o debugger.d.cmo -c debugger.ml
$ ocamlopt -bin-annot -g str.cmxa unix.cmxa -o debugger.ocaml_debuggable
$ ocamldebug debugger.ocaml_debuggable
OCaml Debugger version 4.04.1
(ocd) break @debugger 6291
Loading program… /Users/jonathandoyle/Documents/OCaml/Idaho/debugger.ocaml_debuggable is not a bytecode file.

What did I do wrong ?

I don’t use ocamldebug, but the manual implies that it only accepts bytecode executables. That means you shouldn’t be creating debugger.ocaml_debuggable with ocamlopt, but with ocamlc.

I used ocamlc in place in ocamloptand it works now, thank you.

I am surprised though that the -g option exists for ocamlopt (and is even mentioned in the manual) as it seems to serve no purpose

It does. Retains symbol names which are needed for the stack traces (and native debugging in general). See the manual.

1 Like

If I understood correctly, native debugging cannot use ocamldebug. How does one do it then ? Is it via gdb ?

Maybe soon with first class support. But it’s already useful to have the names in C backtraces and for other C profiling tools in general.