Package bap :: Module bap
[hide private]
[frames] | no frames]

Module bap

source code

Classes [hide private]
  BapError
Base class for BAP runtime errors
  MalformedOutput
Raised if we were unable to parse the output of bap.
  Failed
Raised when bap subprocess returns a non-zero code
  Killed
Raised when bap subprocess is killed by a signal
Functions [hide private]
 
run(path, args=[], bap='bap', parser={'format': 'adt', 'load': <function loads at 0x7f33fa2769b0>})
run(file[, args] [, bap=PATH] [,parser=PARSER]) -> project
source code
Variables [hide private]
  adt_project_parser = {'format': 'adt', 'load': <function loads...
  __package__ = 'bap'
Function Details [hide private]

run(path, args=[], bap='bap', parser={'format': 'adt', 'load': <function loads at 0x7f33fa2769b0>})

source code 
run(file[, args] [, bap=PATH] [,parser=PARSER]) -> project

Run bap on a specified `file`, wait until it finishes, parse
and return the result, using project data structure as default.

Example:

>>> proj = run('/bin/true')

To specify extra command line arguments, pass them as a list:

>>> proj = run('/bin/true', ['--no-cache', '--symbolizer=ida'])

To specify an explicit path to `bap` executable use `bap` keyword
argument:

>>> proj = run('/bin/true', bap='/usr/bin/bap')


By default a project data structure is dumped in ADT format and
loaded into `bir.Project` data structure. To parse other formats,
a parser argument can be specified. It must be a dictionary, that
may contain the following two fields:

  - `format` - a format name as accepted by bap's `--dump` option,
               it will passed to bap.
  - `load` - a function that parses the output.


In case of errors, the `load` function must raise `SyntaxError`
exception. Example:

>>> version = run('/bin/true', parser={'load' : str.strip})

If `parser` is `None` or if it doesn't provide `load` function,
then the program output is returned as is.


Exceptions
----------

Will pass through exceptions from the underlying subprocess module,
with OSError being the most common one. If everything went fine on
the system level, then may raise SyntaxError at the parsing step.
Also may raise Failed or Killed exceptions in case if the return code
wasn't zero.


Variables Details [hide private]

adt_project_parser

Value:
{'format': 'adt', 'load': <function loads at 0x7f33fa2769b0>}