Antoine
Antoine

Reputation: 1812

How to interpret GDB backtrace of an OCaml program?

I'm trying to read the backtrace of my OCaml program inside GDB. The output looks like the following:

(gdb) bt
#0  0x0000000100535ac6 in .L207 ()
#1  0x0000000100535acb in .L207 ()
#2  0x0000000100535acb in .L207 ()
...

How can I interpret this kind of output?

EDIT:

EDIT 2: the output seems to be correct with the Linux version of GDB. Does anyone know why there is such a difference between the OS X and Linux versions?

Upvotes: 3

Views: 562

Answers (3)

chrismamo1
chrismamo1

Reputation: 977

Have you looked into using ocamldebug instead, or do you have to debug on the machine end?

If you want to understand what your code is doing on the CPU/Register/Assembly/Bitfiddling-witchcraft end then it might be more informative to read Jane Street's blog post writing performance sensitive ocaml code.

Upvotes: 0

ygrek
ygrek

Reputation: 6697

Check what C compiler and assembler is used. Mac OS probably uses clang and it may not generate full debug info for gdb. In that case using lldb may be more fruitful.

Upvotes: 2

unhammer
unhammer

Reputation: 4671

Did you compile with -g? I typically get stuff like #3 0x0000000000401f49 in caml_program (). There's also export OCAMLRUNPARAM=b, gives stacktraces when your program crashes.

(You might want to post a code snippet and the compile commands.)

You may also find http://www.ocamlpro.com/blog/2012/08/20/ocamlpro-and-4.00.0.html and http://oud.ocaml.org/2012/slides/oud2012-paper5-slides.pdf handy.

Upvotes: 2

Related Questions