package bap-std

  1. Overview
  2. Docs

Plugin loader.

This module handles the set of plugins, visible to the platform.

Plugins are looked at the following locations:

  • paths explicitly specified by a user (via library parameter);
  • paths specified by the BAP_PLUGIN_PATH environment variable (same syntax as PATH variable);
  • $prefix/lib/bap, where $prefix is the installation prefix, specified during the installation.

The latter destination is used by the bapbundle install command, so this is the default repository of plugins.

The plugin loader is an event driven system. Once, Plugins.run function is called, events of type Plugins.events will start to fire. By default they are intercepted by a logger, and by the default handler (see Plugins.run function description about the default handler). The logger will write the infromation about events, that is useful for debugging issues with plugins.

type event = [
  1. | `Opening of string
    (*

    a bundle with a plugin is opened

    *)
  2. | `Loading of plugin
    (*

    a plugin loading process is started

    *)
  3. | `Linking of string
    (*

    a library or module is linked in

    *)
  4. | `Loaded of plugin
    (*

    a plugin was successfully loaded

    *)
  5. | `Errored of string * Core_kernel.Std.Error.t
    (*

    failed to load a plugin

    *)
]
include sig ... end
val sexp_of_event : event -> Sexplib.Sexp.t
val list : ?env:string list -> ?provides:string list -> ?library:string list -> unit -> plugin list

list ?env ~provides:features ?library () scans a list of directories, provided by a library parameter, and, finally, Config.libdir for files with a plugin extension. Returns all plugins that provide a superset of features and has constrains that are subset of env.

val run : ?argv:string array -> ?env:string list -> ?provides:string list -> ?don't_setup_handlers:bool -> ?library:string list -> ?exclude:string list -> unit -> unit

run ?env ?provides ?library ?exclude load and execute all plugins that can be found in the library paths, and are not in the exclude list. The default event handler will abort the program if there is any Errored event occurs, a message will be printed to the standard output. If don't_setup_handlers option is chosen, then events are not treated, so that a host program may setup a more fine granular error handling.

val load : ?argv:string array -> ?env:string list -> ?provides:string list -> ?library:string list -> ?exclude:string list -> unit -> (plugin, string * Core_kernel.Std.Error.t) Core_kernel.Std.Result.t list

load ?env ?provides ?library ?exclude is like run, but will not setup handlers, and will return a result of loading. Each element of the list is either an Ok plugin if a plugin was successfully loaded, or Error (name,error) if a plugin with the given name failed with error.

plugin subsystem event stream.

val loaded : unit Bap_future.Std.future

loaded occurs when all plugins are loaded

OCaml

Innovation. Community. Security.