draperlaboratory / cbat_tools

Program analysis tools developed at Draper on the CBAT project.
MIT License
102 stars 14 forks source link

Add module to handle configurations like flag information and formatting information. #310

Open gltrost opened 3 years ago

gltrost commented 3 years ago

Right now, information from flags is passed around through the code-base, often having to be passed into several different functions before the information is used.

Likewise, some information like formatting information should exist and be explicitly in a single location in our code.

One way to deal with these issues is to write a new module that acts like an event-log/event-stream, possibly called log.ml, to handle such information.

ccasin commented 3 years ago

I don't think I understand this suggestion. Config information must travel from the front-end of the tool to the location where it is used, so what does it mean for it to exist "explicitly in a single location"?

Generally using state passing style or a state monad are the standard ways to transport this information in a functional program. Certainly we could be more uniform, in this respect.

codyroux commented 3 years ago

In many "real" systems, this just isn't practical, and there is a configuration module which contains runtime-specific information for the program.

Note that BAP itself works in this style, e.g. in this module: http://binaryanalysisplatform.github.io/bap/api/odoc/bap/Bap/Std/Self/Config/index.html

codyroux commented 3 years ago

Note this line: https://github.com/draperlaboratory/cbat_tools/blob/050d8bcf1dc7982116e439ce5da083dab8e26605/wp/lib/bap_wp/src/precondition.ml#L1358

This prints to stderr by default, so at the very least we need to suppress this by default, or at least make it a call to info.