diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 1996-04-29 13:24:01 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 1996-04-29 13:24:01 +0000 |
commit | 6b09d9235c3d35d0473d0d8a73b6199e0f28745d (patch) | |
tree | 08fef6a6038ec8cdd97aa839a34b256786d82cc0 | |
parent | 4946407f015e9e71e4029982f6b890e31159e53b (diff) |
Detecter le cas ou l'on trace deux fois la meme fonction sous divers noms.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@770 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | toplevel/topdirs.ml | 27 | ||||
-rw-r--r-- | toplevel/trace.ml | 6 | ||||
-rw-r--r-- | toplevel/trace.mli | 2 |
3 files changed, 18 insertions, 17 deletions
diff --git a/toplevel/topdirs.ml b/toplevel/topdirs.ml index 8b862ca98..569b2cd40 100644 --- a/toplevel/topdirs.ml +++ b/toplevel/topdirs.ml @@ -198,15 +198,17 @@ external current_environment: unit -> Obj.t = "get_current_environment" let dir_trace lid = try let (path, desc) = Env.lookup_value lid !toplevel_env in - if is_traced path then begin - Printtyp.path path; print_string " is already traced."; - print_newline() - end else begin - let clos = eval_path path in - (* Nothing to do if it's not a closure *) - if Obj.is_block clos & Obj.tag clos = 250 then begin - let old_clos = copy_closure clos in + let clos = eval_path path in + (* Nothing to do if it's not a closure *) + if Obj.is_block clos & Obj.tag clos = 250 then begin + match is_traced clos with + Some opath -> + Printtyp.path path; print_string " is already traced (under the name "; + Printtyp.path opath; print_string ")"; + print_newline() + | None -> (* Instrument the old closure *) + let old_clos = copy_closure clos in traced_functions := { path = path; closure = clos; @@ -228,11 +230,10 @@ let dir_trace lid = | _ -> Printtyp.longident lid; print_string " is now traced."; print_newline() - end else begin - Printtyp.longident lid; print_string " is not a function."; - print_newline() - end - end + end else begin + Printtyp.longident lid; print_string " is not a function."; + print_newline() + end with Not_found -> print_string "Unbound value "; Printtyp.longident lid; print_newline() diff --git a/toplevel/trace.ml b/toplevel/trace.ml index f9d9ed1f0..a6e3e9f1f 100644 --- a/toplevel/trace.ml +++ b/toplevel/trace.ml @@ -30,10 +30,10 @@ let traced_functions = ref ([] : traced_function list) (* Check if a function is already traced *) -let is_traced path = +let is_traced clos = let rec is_traced = function - [] -> false - | tf :: rem -> Path.same path tf.path or is_traced rem + [] -> None + | tf :: rem -> if tf.closure == clos then Some tf.path else is_traced rem in is_traced !traced_functions (* Make a copy of a closure *) diff --git a/toplevel/trace.mli b/toplevel/trace.mli index 3b1a637bc..931f05287 100644 --- a/toplevel/trace.mli +++ b/toplevel/trace.mli @@ -20,7 +20,7 @@ type traced_function = instrumented_fun: Obj.t } val traced_functions: traced_function list ref -val is_traced: Path.t -> bool +val is_traced: Obj.t -> Path.t option val copy_closure: Obj.t -> Obj.t val overwrite_closure: Obj.t -> Obj.t -> unit val instrument_closure: |