我有一个非常短的测试文件:
let print_backtrace () = try raise Not_found with
Not_found -> Printexc.print_backtrace stdout;;
let f () = print_backtrace (); Printf.printf "this is to make f non-tail-recursive\n";;
f ();
我进行编译和运行:
我编译并运行:
% ocamlc -g test.ml
% OCAMLRUNPARAM=b ./a.out
Raised at file "test.ml", line 1, characters 35-44
this is to make f non-tail-recursive
为什么堆栈跟踪中没有列出f
?我应该如何编写一个函数,以便打印调用它的位置的堆栈跟踪?