in Toplevel, how to turn on the stack trace for exceptions?
simple question, don't know how to ask more in details.
in Toplevel, how to turn on the stack trace for exceptions?
simple question, don't know how to ask more in details.
This used to not be easily possible (only code compiled outside the toplevel would support backtraces), but since OCaml 4.03.0 (released in April 2016) the toplevel supports backtraces, thanks to the contributions of whitequark and Jake Donham.
Just run the toplevel with OCAMLRUNPARAM=b ocaml
to get backtraces. Of course, compiled code that you want to link and use from the toplevel should be compiled with -g
to contain backtrace information -- otherwise you will only see the part of the call stack that calls functions defined from the toplevel.
I know that this question is 10 years old, but here is an answer from 2023: you can use Printexc.record_backtrace true
.
© 2022 - 2024 — McMap. All rights reserved.