Version française
Home     About     Download     Resources     Contact us    
Browse thread
how to set breakpoint at exception throw?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: how to set breakpoint at exception throw?
Hello,

On Tue, Jul 04, 2000 at 08:19:20PM +0200, Gerd Stolpmann wrote:

> Uncaught exception: Not_found
> Exception backtrace:
> - File x, line 3: Not_found
> - File x, line 7: Not_found
> - File x, line 11: Not_found

Can't camlp4 help you?

========================================= file toto.ml
open Pcaml

EXTEND
  expr: LEVEL "apply"
    [ [ "myraise"; e = expr LEVEL "simple" ->
          let bp = <:expr< $int:string_of_int (fst loc)$ >> in
          let ep = <:expr< $int:string_of_int (snd loc)$ >> in
          <:expr< raise (LocExc $e$ $str:!input_file$ ($bp$, $ep$)) >> ] ]
  ;
END
=========================================

$ ocamlc -pp "camlp4o pa_extend.cmo q_MLast.cmo" -I `camlp4 -where` -c toto.ml

========================================= file foo.ml
exception LocExc of exn * string * (int * int)

try 
  try
    myraise Not_found
  with
    x ->
      (* XXX: Clean-up code here *)
      myraise x
with
  x ->
    (* XXX: Clean-up code here *)
    myraise x
=========================================

$ ocamlc -c -pp "camlp4o ./toto.cmo" foo.ml

$ camlp4o ./toto.cmo pr_o.cmo foo.ml
exception LocExc of exn * string * (int * int);;

try
  try raise (LocExc (Not_found, "foo.ml", (63, 80))) with
    x -> raise (LocExc (x, "foo.ml", (139, 148)))
with
  x -> raise (LocExc (x, "foo.ml", (199, 208)));;

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/