[Teaching] Backtraces in toplevel

Gabriel Scherer gabriel.scherer at gmail.com
Tue May 12 12:46:56 BST 2015


I don't think you need the toplevel itself to be compiled with -g to get
stack traces (that would be true of stack traces raised by exception inside
the toplevel implementation, but those correspond to OCaml implementation
bugs, not to bugs in your student's programs). However, in existing
released versions of OCaml I suspect that stack traces are not available
for code defined from the toplevel (I think it works for libraries compiled
outside the toplevel and linked/loaded from the toplevel, but not for
functions defined directly by sending phrases to the toplevel). This was
the topic of the issue report PR#6468 (
http://caml.inria.fr/mantis/view.php?id=6468 ), and Peter Zotov developed a
patch to implement that feature. It will be available in the next *major*
release of the OCaml distribution (around autumn/winter), but if you
already maintain a fork you could try to backport it.



On Tue, May 12, 2015 at 10:48 AM, Yann Salmon <yann.salmon at prepas.org>
wrote:

> Hello,
>
> I have recently started using Arthur Charguéraud's experimental OCaml
> compiler and top-level with improved type error messages. This is great
> and the students are now able to gain better autonomy in programming. I
> modified the OCaml source code to enable easy-type-errors by default.
>
> However, Arthur's patch cannot improve runtime error messages, like the
> frequent Out-of-bound access exception. For this, I would like the OCaml
> toplevel to automatically print a backtrace.
>
> I understand that I should do two things :
>  1. compile the toplevel with -g
>  2. run the toplevel with OCAMLRUNPARAM set to B.
>
> I do not understand however what I should change in the makefiles to
> pass the -g option correctly (my attempts were not successful), and I am
> not sure what parts of the OCaml source code I should change to get de
> backtrace printing behaviour enabled by default.
>
> Can somebody help ?
>
> --
> Cordialement,
> Yann Salmon
>
> Informatique
> MPSI, PCSI, MP*, PC*
> Descartes - Tours
>
> <http://pro.yannsalmon.fr/>
> _______________________________________________
> Teaching mailing list
> Teaching at lists.ocaml.org
> http://lists.ocaml.org/listinfo/teaching
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocaml.org/pipermail/teaching/attachments/20150512/6ce99704/attachment.html>


More information about the Teaching mailing list