1 (**************************************************************************)
2 (* *)
3 (* OCaml *)
4 (* *)
5 (* Jerome Vouillon, projet Cristal, INRIA Rocquencourt *)
6 (* OCaml port by John Malecki and Xavier Leroy *)
7 (* *)
8 (* Copyright 1996 Institut National de Recherche en Informatique et *)
9 (* en Automatique. *)
10 (* *)
11 (* All rights reserved. This file is distributed under the terms of *)
12 (* the GNU Lesser General Public License version 2.1, with the *)
13 (* special exception on linking described in the file LICENSE. *)
14 (* *)
15 (**************************************************************************)
16
17 (********************************* Events ******************************)
18
19 open Instruct
20
21 type code_event =
22 { ev_frag : int;
23 ev_ev : Instruct.debug_event }
24
25 let get_pos ev =
26 match ev.ev_kind with
27 | Event_before -> ev.ev_loc.Location.loc_start
28 | Event_after _ -> ev.ev_loc.Location.loc_end
29 | _ -> ev.ev_loc.Location.loc_start
30 ;;
31
32
33 (*** Current events. ***)
34
35 (* Event at current position *)
36 let current_event =
37 ref (None : code_event option)
38
39 (* Current position in source. *)
40 (* Raise `Not_found' if not on an event (beginning or end of program). *)
41 let get_current_event () =
42 match !current_event with
43 | None -> raise Not_found
44 | Some ev -> ev
45
46 let current_event_is_before () =
47 match !current_event with
48 None ->
49 raise Not_found
50 | Some {ev_ev = {ev_kind = Event_before}} ->
51 true
52 | _ ->
53 false
54