summaryrefslogtreecommitdiff
path: root/debugger/history.ml
blob: 0ece812b3ee1f64915f119b8eb9ab2a2fc54b99e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(**************************************************************************)
(*                                                                        *)
(*                                 OCaml                                  *)
(*                                                                        *)
(*           Jerome Vouillon, projet Cristal, INRIA Rocquencourt          *)
(*           OCaml port by John Malecki and Xavier Leroy                  *)
(*                                                                        *)
(*   Copyright 1996 Institut National de Recherche en Informatique et     *)
(*     en Automatique.                                                    *)
(*                                                                        *)
(*   All rights reserved.  This file is distributed under the terms of    *)
(*   the GNU Lesser General Public License version 2.1, with the          *)
(*   special exception on linking described in the file LICENSE.          *)
(*                                                                        *)
(**************************************************************************)

open Int64ops
open Checkpoints
open Primitives
open Debugger_config

let history = ref ([] : int64 list)

let empty_history () =
  history := []

let add_current_time () =
  let time = current_time () in
    if !history = [] then
      history := [time]
    else if time <> List.hd !history then
      history := list_truncate !history_size (time::!history)

let previous_time_1 () =
  match !history with
    _::((time::_) as hist) ->
      history := hist; time
  | _ ->
      prerr_endline "No more information."; raise Toplevel

let rec previous_time n =
  if n = _1
  then previous_time_1()
  else begin ignore(previous_time_1()); previous_time(pre64 n) end