Debian Codegraph @

vernac/debugHook.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 (** Ltac debugger interface; clients should register hooks to interact
12 with their provided interface. *)
13
14 (** The debugger receives requests by calling read_cmd to get Actions.
15 Each Action may return one or more responses as Answers by calling submit_answer.
16 Many of them return a single Answer or no Answer, but a single step may generate any
17 number of Outputs.
18
19 Debugger initialization has the following steps:
20 -> Rocq sends Answer.Init
21 <- IDE sends zero or more initialization requests such as Action.UpdBpts
22 <- IDE sends Action.Configd
23
24 Stopping in the debugger generates Answer.Prompt and Answer.Goal messages,
25 at which point the IDE will typically call GetStack and GetVars. When the
26 IDE sends with StepIn..Continue, the debugger will execute more code. At
27 that point, Rocq won't try to read more messages from the IDE until the
28 debugger stops again or exits.
29 *)
30 module Action : sig
31 type t =
32 | StepIn (* execute a single step in the tactic *)
33 | StepOver (* execute steps until DB is back in the current stack frame *)
34 | StepOut (* execute steps until DB exits current stack frame *)
35 | Continue (* execute steps until a breakpoint or the debugger exits *)
36 | Skip (* legacy: continue execution with no further debugging *)
37 | Interrupt (* exit the debugger *)
38 | Help (* legacy: print help text *)
39 | UpdBpts of ((string * int) * bool) list
40 (* sets or clears breakpoints. Values are:
41 - absolute pathname of the the file
42 - byte offset in the UTF-8 representation of the file
43 - true to set, false to clear *)
44 | Configd (* "config done" - indicates that the debugger has been
45 configured, debugger does a Continue *)
46 | GetStack (* request the call stack, returned as Answer.Stack *)
47 | GetVars of int
48 (* request the variables defined for stack frame N,
49 returned as Answer.Vars. 0 is the topmost frame,
50 followed by 1,2,3, ... *)
51 | RunCnt of int
52 (* legacy: run for N steps *)
53 | RunBreakpoint of string
54 (* legacy: run until an idtac prints the string *)
55 | Command of string
56 (* legacy: user-typed command to the debugger *)
57 | Failed (* legacy: user command doesn't parse *)
58 | Ignore (* internal: do nothing, read another command *)
59
60 (* XXX: Should be moved to the clients *)
61 val parse : string -> (t, string) result
62 end
63
64 module Answer : sig
65 type t =
66 | Prompt of Pp.t (* output signalling the debugger has stopped
67 Should be printed as a prompt for user input,
68 e.g. in color without a newline at the end *)
69 | Goal of Pp.t (* goal for the current proof state *)
70 | Output of Pp.t (* general output *)
71 | Init (* signals initialization of the debugger *)
72 | Stack of (string * (string * int list) option) list
73 (* The call stack, starting from TOS.
74 Values are:
75 - description of the frame
76 (eg tactic name, line number, module)
77 - absolute pathname of the file
78 - array containing Loc.bp and Loc.ep of the
79 corresponding code *)
80 | Vars of (string * Pp.t) list
81 (* The variable values for the specified stack
82 frame. Values are variable name and variable value *)
83 end
84
85 module Intf : sig
86 type t =
87 { read_cmd : unit -> Action.t
88 (** request a debugger command from the client *)
89 ; submit_answer : Answer.t -> unit
90 (** receive a debugger answer from Ltac *)
91 ; isTerminal : bool
92 (** whether the debugger is running as a terminal (non-visual) *)
93 }
94
95 val set : t -> unit
96 val get : unit -> t option
97 end