aboutsummaryrefslogtreecommitdiff
path: root/plugins/ltac/tactic_debug.ml
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/ltac/tactic_debug.ml')
-rw-r--r--plugins/ltac/tactic_debug.ml43
1 files changed, 28 insertions, 15 deletions
diff --git a/plugins/ltac/tactic_debug.ml b/plugins/ltac/tactic_debug.ml
index 539536911c..5fbea4eeef 100644
--- a/plugins/ltac/tactic_debug.ml
+++ b/plugins/ltac/tactic_debug.ml
@@ -1,7 +1,7 @@
(************************************************************************)
(* * The Coq Proof Assistant / The Coq Development Team *)
-(* v * INRIA, CNRS and contributors - Copyright 1999-2019 *)
-(* <O___,, * (see CREDITS file for the list of authors) *)
+(* v * Copyright INRIA, CNRS and contributors *)
+(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(* \VV/ **************************************************************)
(* // * This file is distributed under the terms of the *)
(* * GNU Lesser General Public License Version 2.1 *)
@@ -86,7 +86,6 @@ open Goptions
let () =
declare_bool_option
{ optdepr = false;
- optname = "Ltac batch debug";
optkey = ["Ltac";"Batch";"Debug"];
optread = (fun () -> !batch);
optwrite = (fun x -> batch := x) }
@@ -108,13 +107,29 @@ let db_initialize =
let int_of_string s =
try Proofview.NonLogical.return (int_of_string s)
- with e -> Proofview.NonLogical.raise e
+ with e ->
+ let e = Exninfo.capture e in
+ Proofview.NonLogical.raise e
let string_get s i =
try Proofview.NonLogical.return (String.get s i)
- with e -> Proofview.NonLogical.raise e
+ with e ->
+ let e = Exninfo.capture e in
+ Proofview.NonLogical.raise e
+
+let check_positive n =
+ try
+ if n < 0 then
+ raise (Invalid_argument "number must be positive")
+ else
+ Proofview.NonLogical.return ()
+ with e ->
+ let e = Exninfo.capture e in
+ Proofview.NonLogical.raise e
-let run_invalid_arg () = Proofview.NonLogical.raise (Invalid_argument "run_com")
+let run_invalid_arg () =
+ let info = Exninfo.null in
+ Proofview.NonLogical.raise (Invalid_argument "run_com", info)
(* Gives the number of steps or next breakpoint of a run command *)
let run_com inst =
@@ -126,7 +141,7 @@ let run_com inst =
let s = String.sub inst i (String.length inst - i) in
if inst.[0] >= '0' && inst.[0] <= '9' then
int_of_string s >>= fun num ->
- (if num<0 then run_invalid_arg () else return ()) >>
+ check_positive num >>
(skip:=num) >> (skipped:=0)
else
breakpoint:=Some (possibly_unquote s)
@@ -157,11 +172,11 @@ let rec prompt level =
let open Proofview.NonLogical in
Proofview.NonLogical.print_notice (fnl () ++ str "TcDebug (" ++ int level ++ str ") > ") >>
if Util.(!batch) then return (DebugOn (level+1)) else
- let exit = (skip:=0) >> (skipped:=0) >> raise Sys.Break in
+ let exit = (skip:=0) >> (skipped:=0) >> raise (Sys.Break, Exninfo.null) in
Proofview.NonLogical.catch Proofview.NonLogical.read_line
begin function (e, info) -> match e with
| End_of_file -> exit
- | e -> raise ~info e
+ | e -> raise (e, info)
end
>>= fun inst ->
match inst with
@@ -177,7 +192,7 @@ let rec prompt level =
Proofview.NonLogical.catch (run_com inst >> runtrue >> return (DebugOn (level+1)))
begin function (e, info) -> match e with
| Failure _ | Invalid_argument _ -> prompt level
- | e -> raise ~info e
+ | e -> raise (e, info)
end
end
@@ -214,9 +229,7 @@ let debug_prompt lev tac f =
Proofview.tclTHEN
(Proofview.tclLIFT begin
(skip:=0) >> (skipped:=0) >>
- if Logic.catchable_exception reraise then
- msg_tac_debug (str "Level " ++ int lev ++ str ": " ++ explain_logic_error reraise)
- else return ()
+ msg_tac_debug (str "Level " ++ int lev ++ str ": " ++ explain_logic_error reraise)
end)
(Proofview.tclZERO ~info reraise)
end
@@ -403,7 +416,7 @@ let extract_ltac_trace ?loc trace =
(* We entered a user-defined tactic,
we display the trace with location of the call *)
let msg = hov 0 (explain_ltac_call_trace c tail loc ++ fnl()) in
- (if Loc.finer loc tloc then loc else tloc), Some msg
+ (if Loc.finer loc tloc then loc else tloc), msg
else
(* We entered a primitive tactic, we don't display trace but
report on the finest location *)
@@ -419,7 +432,7 @@ let extract_ltac_trace ?loc trace =
aux best_loc tail
| [] -> best_loc in
aux loc trace in
- best_loc, None
+ best_loc, mt ()
let get_ltac_trace info =
let ltac_trace = Exninfo.get info ltac_trace_info in