Saturday, 24 August 2013

Printing backtrace doesn't work

Printing backtrace doesn't work

I have a block of code as follows:
try
... (* body *)
with
| e ->
Printexc.record_backtrace true;
printf "Unexpected exception : %s\n" (Printexc.to_string e);
let x = Printexc.get_backtrace () in
print_string x;
Printexc.print_backtrace stdout
The code in body does raise an exception, and it shows as follows:
`Unexpected exception : Not_found`
However it doesn't print any backtrace.
I compile the file with -g and export OCAMLRUNPARAM=b, does anyone know
the reason why the backtrace cannot be printed?

No comments:

Post a Comment