Skip to content

Commit b8e12b3

Browse files
authored
fixes bap.top and baptop (#1541)
This commit fixes the `bap.top` library and the `baptop` executable so that they can now be used. Before that, they were failing with ``` Exception: (Invalid_argument "The dynlink.cma library cannot be used inside the OCaml toplevel") ``` The problem was that we were trying to use the dynlink facilities to track the missing units (before that we were using findlib for that so it was working). However, for toplevel we don't need to do this, as the toplevel loader will keep track of the loaded dependencies for us.
1 parent a691de9 commit b8e12b3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/bap_plugins/bap_plugins_units.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ open Core_kernel[@@warning "-D"]
22

33
let name = "dynlink"
44

5+
let is_toplevel = Caml.Sys.interactive.contents
6+
57
type reason = [
68
| `In_core
79
| `Provided_by of string
@@ -22,7 +24,7 @@ let copy_units_from_dynlink () =
2224
Dynlink.all_units () |>
2325
List.iter ~f:(fun unit -> Hashtbl.add_exn units unit `In_core)
2426

25-
let init () = copy_units_from_dynlink ()
27+
let init () = if not is_toplevel then copy_units_from_dynlink ()
2628
let list () = Hashtbl.keys units
2729
let record name reason = match Hashtbl.add units name reason with
2830
| `Ok -> ()

0 commit comments

Comments
 (0)