How can I map OCaml bytecode to source?

Is there any nice feature in the format or library for moving from any part of the bytecode to the line of code from which it originally came? This would obviously be useful for debugging and error reporting.

In particular, I am looking at how difficult it would be to add source map support to js_of_ocaml .

+4
source share
2 answers

js_of_ocaml -debuginfo uses debug_event in bytecode to write a line of code in a comment.

+3
source

When compiling with debugging information enabled (option -g ), the bytecode transfers the so-called "event structure", for example, a function record and a return point, which provide information about the location and input of information.

As a proof of concept for checking this information, I created a small branch ocamlpp (a small Benoรฎt Vaugon utility for checking bytecode files) that prints this debugging information along with the bytecode instructions.

I have no idea if js_of_ocaml is js_of_ocaml necessary steps to save this location information during compilation. You should probably contact your companion, Jer Vouillon, for more information.

+6
source

Source: https://habr.com/ru/post/1486450/


All Articles