简体   繁体   中英

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:

  • I've enabled debug info by using ./configure --enable-debug (I'm using oasis).
  • I'm using GDB 7.9.1 on OS X 10.10
  • I'm using OCaml 4.02.2

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?

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.

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM