caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] never mind- got toplevel backtraces working
@ 2002-09-08  2:12 jehenrik
  0 siblings, 0 replies; only message in thread
From: jehenrik @ 2002-09-08  2:12 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-09-08  2:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-08  2:12 [Caml-list] never mind- got toplevel backtraces working jehenrik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).