<div dir="ltr"><div><div>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 ( <a href="http://caml.inria.fr/mantis/view.php?id=6468">http://caml.inria.fr/mantis/view.php?id=6468</a> ), 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.<br></div><br></div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 12, 2015 at 10:48 AM, Yann Salmon <span dir="ltr"><<a href="mailto:yann.salmon@prepas.org" target="_blank">yann.salmon@prepas.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I have recently started using Arthur Charguéraud's experimental OCaml<br>
compiler and top-level with improved type error messages. This is great<br>
and the students are now able to gain better autonomy in programming. I<br>
modified the OCaml source code to enable easy-type-errors by default.<br>
<br>
However, Arthur's patch cannot improve runtime error messages, like the<br>
frequent Out-of-bound access exception. For this, I would like the OCaml<br>
toplevel to automatically print a backtrace.<br>
<br>
I understand that I should do two things :<br>
 1. compile the toplevel with -g<br>
 2. run the toplevel with OCAMLRUNPARAM set to B.<br>
<br>
I do not understand however what I should change in the makefiles to<br>
pass the -g option correctly (my attempts were not successful), and I am<br>
not sure what parts of the OCaml source code I should change to get de<br>
backtrace printing behaviour enabled by default.<br>
<br>
Can somebody help ?<br>
<br>
--<br>
Cordialement,<br>
Yann Salmon<br>
<br>
Informatique<br>
MPSI, PCSI, MP*, PC*<br>
Descartes - Tours<br>
<br>
<<a href="http://pro.yannsalmon.fr/" target="_blank">http://pro.yannsalmon.fr/</a>><br>
_______________________________________________<br>
Teaching mailing list<br>
<a href="mailto:Teaching@lists.ocaml.org">Teaching@lists.ocaml.org</a><br>
<a href="http://lists.ocaml.org/listinfo/teaching" target="_blank">http://lists.ocaml.org/listinfo/teaching</a><br>
</blockquote></div><br></div>