|
|
|
@ -8,14 +8,12 @@
|
|
|
|
|
(** Configuration options *)
|
|
|
|
|
|
|
|
|
|
let trace_conv =
|
|
|
|
|
let parse s =
|
|
|
|
|
match Trace.parse s with
|
|
|
|
|
| Ok c -> Ok c.trace_mods_funs
|
|
|
|
|
| Error err -> Error err
|
|
|
|
|
in
|
|
|
|
|
let print fs c =
|
|
|
|
|
let print fs {trace_all; trace_mods_funs} =
|
|
|
|
|
let pf fmt = Format.fprintf fs fmt in
|
|
|
|
|
Map.iteri c ~f:(fun ~key:mod_name ~data:{trace_mod; trace_funs} ->
|
|
|
|
|
if trace_all then pf "*"
|
|
|
|
|
else
|
|
|
|
|
Map.iteri trace_mods_funs
|
|
|
|
|
~f:(fun ~key:mod_name ~data:{trace_mod; trace_funs} ->
|
|
|
|
|
( match trace_mod with
|
|
|
|
|
| Some true -> pf "+%s" mod_name
|
|
|
|
|
| Some false -> pf "-%s" mod_name
|
|
|
|
@ -24,7 +22,7 @@ let trace_conv =
|
|
|
|
|
if fun_enabled then pf "+%s.%s" mod_name fun_name
|
|
|
|
|
else pf "-%s.%s" mod_name fun_name ) )
|
|
|
|
|
in
|
|
|
|
|
(parse, print)
|
|
|
|
|
(Trace.parse, print)
|
|
|
|
|
|
|
|
|
|
type t =
|
|
|
|
|
{ compile_only: bool
|
|
|
|
@ -38,17 +36,17 @@ type t =
|
|
|
|
|
[@aka ["o"]] [@docv "output.llair"]
|
|
|
|
|
(** Dump $(i,input.bc) translated to LLAIR in human-readable form to
|
|
|
|
|
$(i,output.llair), or $(b,-) for $(b,stdout). *)
|
|
|
|
|
; trace: Trace.trace_mods_funs
|
|
|
|
|
; trace: Trace.config
|
|
|
|
|
[@aka ["t"]]
|
|
|
|
|
[@docv "spec"]
|
|
|
|
|
[@conv trace_conv]
|
|
|
|
|
[@default Trace.none.trace_mods_funs]
|
|
|
|
|
[@default Trace.none]
|
|
|
|
|
(** Enable debug tracing according to $(i,spec), which is a sequence
|
|
|
|
|
of module and function names separated by $(b,+) or $(b,-). For
|
|
|
|
|
example, $(b,Control-Control.exec_inst) enables all tracing in
|
|
|
|
|
the $(b,Control) module except the $(b,Control.exec_inst)
|
|
|
|
|
function. *)
|
|
|
|
|
; trace_all: bool [@aka ["v"]] (** Enable all debug tracing. *) }
|
|
|
|
|
function. The $(i,spec) value $(b,* )enables all debug tracing. *)
|
|
|
|
|
}
|
|
|
|
|
[@@deriving cmdliner]
|
|
|
|
|
|
|
|
|
|
let run main =
|
|
|
|
@ -57,6 +55,6 @@ let run main =
|
|
|
|
|
|> function
|
|
|
|
|
| `Error _ -> Caml.exit 1
|
|
|
|
|
| `Help | `Version -> Caml.exit 0
|
|
|
|
|
| `Ok {compile_only; input; output; trace; trace_all} ->
|
|
|
|
|
Trace.init ~config:{trace_all; trace_mods_funs= trace} () ;
|
|
|
|
|
| `Ok {compile_only; input; output; trace} ->
|
|
|
|
|
Trace.init ~config:trace () ;
|
|
|
|
|
main ~input ~output ~compile_only
|
|
|
|
|