How to track OCaml program errors?

I am writing a compiler written in OCaml. Sometimes, when there is a runtime error, it shows an error line, but it does not show context, for example, how a function is called, with what values ​​...

To help debugging, does anyone know a way to show the execution steps before the error with the real value of the corresponding variables?

By the way, I use Emacs as an editor.

+3
source share
2 answers

Ocaml compiled. You seem to be used to interpreted languages, where the runtime system has access to the complete source code of the program. Using a compiled program, the runtime system does not have access to a lot of information. For example, variable names disappear during compilation, and nothing will track the arguments passed to each function, unless it is necessary for the program to run normally (this will require a lot of overhead).

( -g ), , . , . , . OCAMLRUNPARAM , b .

ocamlc -g -o foo foo.ml
export OCAMLRUNPARAM=b
./foo

, .

+7
0

All Articles