diff options
| author | Alasdair | 2019-10-31 22:08:38 +0000 |
|---|---|---|
| committer | Alasdair | 2019-10-31 22:31:21 +0000 |
| commit | d61c5160a637479c264b74d8cefc5c0a67942795 (patch) | |
| tree | cb7c7a9c14141a2c889f56b55e25bb2bbcba5820 /src/interactive.mli | |
| parent | b53e4e02517624edaab08f5583d24f6fbaa385fd (diff) | |
Allow sail to be scripted using sail
Currently the -is option allows a list of interactive commands to be
passed to the interactive toplevel, however this is only capable of
executing a sequential list of instructions which is quite limiting.
This commit allows sail interactive commands to be invoked from sail
functions running in the interpreter which can be freely interleaved
with ordinary sail code, for example one could test an assertion at each
QEMU/GDB breakpoint like so:
$include <aarch64.sail>
function main() -> unit = {
sail_gdb_start("target-select remote localhost:1234");
while true do {
sail_gdb_continue(); // Run until breakpoint
sail_gdb_sync(); // Sync register state with QEMU
if not(my_assertion()) {
print_endline("Assertion failed")
}
}
}
Diffstat (limited to 'src/interactive.mli')
| -rw-r--r-- | src/interactive.mli | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/interactive.mli b/src/interactive.mli index b1df0630..933d0a46 100644 --- a/src/interactive.mli +++ b/src/interactive.mli @@ -62,6 +62,17 @@ val env : Env.t ref val arg : string -> string val command : string -> string -val commands : (string * (string * (string -> unit))) list ref +type action = + | ArgString of string * (string -> action) + | ArgInt of string * (int -> action) + | Action of (unit -> unit) -val register_command : name:string -> help:string -> (string -> unit) -> unit +val reflect_typ : action -> typ + +val commands : (string * (string * action)) list ref + +val register_command : name:string -> help:string -> action -> unit + +val generate_help : string -> string -> action -> string + +val run_action : string -> string -> action -> unit |
