Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] never mind- got toplevel backtraces working
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: jehenrik <jehenrik@y...>
Subject: [Caml-list] never mind- got toplevel backtraces working
Hmm, for getting backtraces in the toplevel, I decided to Keep It Simple 
Stupid, and it worked.  Just hook the runtime with two external 
declarations and mktop.  No recompiling anything:

test.ml:

external init_backtrace : unit -> unit = "init_backtrace"
external print_exception_backtrace : unit -> unit = 
"print_exception_backtrace"


% ocamlmktop test.ml -o testtop
% testtop


exception Undefined;;
let foo x = if x == 7 then raise Undefined else x*x;;
let rec consecutiveInts a b =
   if a <= b then a::(consecutiveInts (a+1) b) else [];;
consecutiveInts 1 10;;
Test.init_backtrace ();;
try
   List.map foo (consecutiveInts 1 10)
with
   _ -> Test.print_exception_backtrace (); [];;


output:

      Called from module List, character 1656
Called from module List, character 1672
Called from module List, character 1672
Called from module List, character 1672
Called from module List, character 1672
Called from module List, character 1672
Called from module List, character 1672
- : int list = []
#

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners