From 31a3aa4b328161bcb251e0825f69740fa1b6a454 Mon Sep 17 00:00:00 2001 From: ivg Date: Tue, 16 Aug 2022 15:56:15 -0400 Subject: [PATCH] adds bap-toplevel (doesnt' work) --- bap-toplevel.opam | 35 ++++++++++++++++++++++++ dune-project | 14 ++++++++++ lib/bap/dune | 70 +++++++++++++++++++++++++++++------------------ src/baptop.ml | 6 +++- src/dune | 9 ++++++ 5 files changed, 106 insertions(+), 28 deletions(-) create mode 100644 bap-toplevel.opam diff --git a/bap-toplevel.opam b/bap-toplevel.opam new file mode 100644 index 000000000..5a2350d27 --- /dev/null +++ b/bap-toplevel.opam @@ -0,0 +1,35 @@ +# This file is generated by dune, edit dune-project instead +opam-version: "2.0" +version: "master" +synopsis: "BAP toplevel, baptop" +description: + "The utop-enhanced bap toplevel interpreter. Run `baptop` and start using bap right away. Or use it as the interpreter for your BAP scripts, e.g., `baptop myprog.ml`" +maintainer: ["Ivan Gotovchits "] +authors: ["The BAP Team"] +license: "MIT" +tags: ["bap" "toplevel"] +homepage: "https://github.com/BinaryAnalysisPlatform/bap" +bug-reports: "https://github.com/BinaryAnalysisPlatform/bap/issues" +depends: [ + "dune" {>= "2.8"} + "bap-base" {= version} + "bap-std" {= version} + "core_kernel" {>= "v0.14" & < "v0.16"} + "ocamlfind" {= version} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/BinaryAnalysisPlatform/bap.git" diff --git a/dune-project b/dune-project index ec2230cfe..942951bb1 100644 --- a/dune-project +++ b/dune-project @@ -1390,6 +1390,20 @@ The library provides several algorithms: (ogre (= :version)) (ppx_bap (= :version)))) +(package + (name bap-toplevel) + (synopsis "BAP toplevel, baptop") + (tags (bap toplevel)) + (description "\ +The utop-enhanced bap toplevel interpreter. \ +Run `baptop` and start using bap right away. Or use it \ +as the interpreter for your BAP scripts, e.g., `baptop myprog.ml`") + (depends + (bap-base (= :version)) + (bap-std (= :version)) + (core_kernel (and (>= v0.14) (< v0.16))) + (ocamlfind (= :version)))) + (package (name bap-trace) (synopsis "BAP plugin for loading and inspecting execution traces") diff --git a/lib/bap/dune b/lib/bap/dune index bad7f67e8..3222bd82a 100644 --- a/lib/bap/dune +++ b/lib/bap/dune @@ -1,28 +1,44 @@ (library - (name bap) - (public_name bap-std) - (wrapped false) - (preprocess (pps ppx_bap)) - (libraries - bap-bundle - bap-core-theory - bap_disasm - bap-future - bap_image - bap-knowledge - bap-main - bap_sema - bap_types - bitvec - bitvec-binprot - bitvec-order - bitvec-sexp - core_kernel - core_kernel.caml_unix - fileutils - graphlib - monads - ogre - regular) - (modules bap bap_project bap_self) - (private_modules bap_project bap_self)) \ No newline at end of file + (name bap) + (public_name bap-std) + (wrapped false) + (preprocess (pps ppx_bap)) + (libraries + bap-bundle + bap-core-theory + bap_disasm + bap-future + bap_image + bap-knowledge + bap-main + bap_sema + bap_types + bitvec + bitvec-binprot + bitvec-order + bitvec-sexp + core_kernel + core_kernel.caml_unix + fileutils + graphlib + monads + ogre + regular) + (modules bap bap_project bap_self) + (private_modules bap_project bap_self)) + + +(library + (name baptop) + (public_name bap.top) + (modules bap_init_toplevel) + (private_modules bap_init_toplevel) + (library_flags (-linkall)) + (modes byte) + (special_builtin_support findlib_dynload) + (libraries + bap + bap-main + bap-plugins + compiler-libs + compiler-libs.common)) diff --git a/src/baptop.ml b/src/baptop.ml index ced362714..ee28c9eaf 100644 --- a/src/baptop.ml +++ b/src/baptop.ml @@ -3,4 +3,8 @@ let main () = UTop_main.main () -let () = main () +let () = + try main () with + Symtable.Error err -> + Format.eprintf "Internal error: %a@." Symtable.report_error err; + exit 1 diff --git a/src/dune b/src/dune index 8739cfdee..4070c2541 100644 --- a/src/dune +++ b/src/dune @@ -35,3 +35,12 @@ fileutils re.posix threads)) + +(executable + (name baptop) + (public_name baptop) + (package bap-toplevel) + (modules baptop) + (modes byte) + (link_flags (-linkall)) + (libraries utop threads findlib.dynload))