@@ -119,6 +119,7 @@ type output = [
119
119
| `invalid
120
120
| `addr
121
121
| `memory
122
+ | `knowledge
122
123
] [@@deriving compare, enumerate]
123
124
124
125
type target =
@@ -196,22 +197,24 @@ module Spec = struct
196
197
| `size -> " size"
197
198
| `addr -> " addr"
198
199
| `memory -> " memory"
200
+ | `knowledge -> " knowledge"
199
201
| `invalid -> " invalid" in
200
202
201
203
let as_flag = function
202
204
| `insn | `bil | `bir -> [" pretty"]
203
205
| `sema -> [" all- slots"]
204
- | `kinds | `size | `invalid | `memory | `addr -> [enabled] in
206
+ | `kinds | `size | `invalid | `memory | `addr | `knowledge -> [enabled] in
205
207
206
208
let doc = function
207
209
| `insn -> " Print the decoded instruction ."
208
210
| `bil -> " Print the BIL code ."
209
211
| `bir -> " Print the IR. "
210
- | `sema -> " Print the knowledge base ."
212
+ | `sema -> " Print the full semantics of the instruction ."
211
213
| `kinds -> " Print semantics tags associated with instruction ."
212
214
| `size -> " Print the instruction size ."
213
215
| `addr -> " Print the instruction address "
214
216
| `memory -> " Print the instruction memory representation "
217
+ | `knowledge -> " Print the knowledge base ."
215
218
| `invalid -> " Print invalid instructions ." in
216
219
217
220
let name s = " show- " ^ name_of_output s in
@@ -339,6 +342,10 @@ let print_insn_memory formats mem =
339
342
List.iter formats ~f:(fun _enabled ->
340
343
printf " % a@ \n" Memory.pp mem)
341
344
345
+ let print_knowledge formats =
346
+ List.iter formats ~f:(fun _ ->
347
+ printf " % a" KB.pp_state (Toplevel.current ()))
348
+
342
349
let print_insn insn_formats insn =
343
350
List.iter insn_formats ~f:(fun fmt ->
344
351
Insn.with_printer fmt (fun () ->
@@ -383,7 +390,8 @@ let print arch mem code formats =
383
390
print_bil (formats `bil) insn;
384
391
print_bir (formats `bir) insn;
385
392
print_sema (formats `sema) insn;
386
- print_kinds (formats `kinds) code
393
+ print_kinds (formats `kinds) code;
394
+ print_knowledge (formats `knowledge)
387
395
388
396
let bits = function
389
397
| Target {name=t} -> Theory.Target.bits t
@@ -428,13 +436,14 @@ let validate_formats formats =
428
436
List.map formats ~f:(function
429
437
| (`insn|`bil|`bir) as kind,fmts ->
430
438
validate_module kind fmts
431
- | (`kinds|`size|`invalid|`addr|`memory),[] -> Ok ()
432
- | (`kinds|`size|`invalid|`addr|`memory),[opt]
439
+ | (`kinds|`size|`invalid|`addr|`memory|`knowledge ),[] -> Ok ()
440
+ | (`kinds|`size|`invalid|`addr|`memory|`knowledge ),[opt]
433
441
when String.equal enabled opt -> Ok ()
434
442
| `kinds,_ -> Error (No_formats_expected " kinds")
435
443
| `size,_ -> Error (No_formats_expected " size")
436
444
| `addr,_ -> Error (No_formats_expected " addr")
437
445
| `memory,_ -> Error (No_formats_expected " memory")
446
+ | `knowledge,_ -> Error (No_formats_expected " knowledge")
438
447
| `invalid,_ -> Error (No_formats_expected " invalid")
439
448
| `sema,_ ->
440
449
(* no validation right now, since the knowledge introspection
0 commit comments