diff --git a/sledge/bin/sledge_cli.ml b/sledge/bin/sledge_cli.ml index 3e5228c04..c68a71aec 100644 --- a/sledge/bin/sledge_cli.ml +++ b/sledge/bin/sledge_cli.ml @@ -146,6 +146,33 @@ let analyze_cmd = in command ~summary ~readme param +let disassemble = + let%map_open llair_txt_output = + flag "llair-txt-output" (optional string) + ~doc: + " write generated textual LLAIR to , or to standard \ + output if omitted" + in + fun program () -> + let pgm = program () in + match llair_txt_output with + | None -> Format.printf "%a@." Llair.Program.pp pgm + | Some file -> + Out_channel.with_file file ~f:(fun oc -> + let fs = Format.formatter_of_out_channel oc in + Format.fprintf fs "%a@." Llair.Program.pp pgm ) + +let disassemble_cmd = + let summary = "print LLAIR code in textual form" in + let readme () = + "The file must be LLAIR code, as produced by `sledge llvm \ + translate`." + in + let param = + Command.Param.(anon ("" %: string) >>| unmarshal |*> disassemble) + in + command ~summary ~readme param + let translate = let%map_open llair_output = flag "llair-output" (optional string) @@ -195,6 +222,14 @@ let llvm_grp = let param = translate_inputs in command ~summary ~readme param in + let disassemble_cmd = + let summary = + "translate LLVM bitcode to LLAIR and print in textual form" + in + let readme () = "The file must be LLVM bitcode." in + let param = translate_inputs |*> disassemble in + command ~summary ~readme param + in let analyze_cmd = let summary = "analyze LLVM bitcode" in let readme () = @@ -210,32 +245,9 @@ let llvm_grp = "Code can be provided by one or more LLVM bitcode files." in Command.group ~summary ~readme ~preserve_subcommand_order:() - [("analyze", analyze_cmd); ("translate", translate_cmd)] - -let disassemble_cmd = - let summary = "print LLAIR code in textual form" in - let readme () = - "The file must be LLAIR code, as produced by `sledge llvm \ - translate`." - in - let param = - let%map_open input = anon ("" %: string) - and llair_txt_output = - flag "llair-txt-output" (optional string) - ~doc: - " write generated textual LLAIR to , or to standard \ - output if omitted" - in - fun () -> - let program = unmarshal input () in - match llair_txt_output with - | None -> Format.printf "%a@." Llair.Program.pp program - | Some file -> - Out_channel.with_file file ~f:(fun oc -> - let fs = Format.formatter_of_out_channel oc in - Format.fprintf fs "%a@." Llair.Program.pp program ) - in - command ~summary ~readme param + [ ("analyze", analyze_cmd) + ; ("translate", translate_cmd) + ; ("disassemble", disassemble_cmd) ] let smt_cmd = let summary = "process SMT-LIB benchmarks" in diff --git a/sledge/sledge-help.txt b/sledge/sledge-help.txt index 7f1cc7511..55186c09f 100644 --- a/sledge/sledge-help.txt +++ b/sledge/sledge-help.txt @@ -6,18 +6,19 @@ The [-trace ] argument of each subcommand enables debug tracing according === subcommands === - buck integration with Buck - . analyze analyze buck target - . bitcode report bitcode files in buck target - . link link buck target to LLVM bitcode - llvm integration with LLVM - . analyze analyze LLVM bitcode - . translate translate LLVM bitcode to LLAIR - analyze analyze LLAIR code - disassemble print LLAIR code in textual form - smt process SMT-LIB benchmarks - version print version information - help explain a given subcommand (perhaps recursively) + buck integration with Buck + . analyze analyze buck target + . bitcode report bitcode files in buck target + . link link buck target to LLVM bitcode + llvm integration with LLVM + . analyze analyze LLVM bitcode + . translate translate LLVM bitcode to LLAIR + . disassemble translate LLVM bitcode to LLAIR and print in textual form + analyze analyze LLAIR code + disassemble print LLAIR code in textual form + smt process SMT-LIB benchmarks + version print version information + help explain a given subcommand (perhaps recursively) ====== sledge buck ====== @@ -120,9 +121,10 @@ Code can be provided by one or more LLVM bitcode files. === subcommands === - analyze analyze LLVM bitcode - translate translate LLVM bitcode to LLAIR - help explain a given subcommand (perhaps recursively) + analyze analyze LLVM bitcode + translate translate LLVM bitcode to LLAIR + disassemble translate LLVM bitcode to LLAIR and print in textual form + help explain a given subcommand (perhaps recursively) ====== sledge llvm analyze ====== @@ -180,6 +182,31 @@ Translate one or more LLVM bitcode files to LLAIR. Each filename may be (alias: -?) +====== sledge llvm disassemble ====== + +translate LLVM bitcode to LLAIR and print in textual form + + sledge llvm disassemble [ ...] + +The file must be LLVM bitcode. + +=== flags === + + [-colors] enable printing in colors + [-fuzzer] add a harness for libFuzzer targets + [-llair-output ] write generated LLAIR to + [-llair-txt-output ] write generated textual LLAIR to , or to + standard output if omitted + [-margin ] wrap debug tracing at columns + [-no-internalize] do not internalize all functions except the entry + points specified in the config file + [-no-models] do not add models for C/C++ runtime and standard + libraries + [-trace ] enable debug tracing + [-help] print this help text and exit + (alias: -?) + + ====== sledge analyze ====== analyze LLAIR code