draperlaboratory / cbat_tools

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

Give Output.print_result a parameter to specify a formatter #291

Open jtpaasch opened 3 years ago

jtpaasch commented 3 years ago

Currently, in wp, Output.print_result prints everything to stdout. In fact, it uses Printf.printf: https://github.com/draperlaboratory/cbat_tools/blob/master/wp/lib/bap_wp/src/output.ml#L152

The purpose of this ticket is twofold:

(1) Let the user specify which channel they want to output the result to. (2) The default should be stderr.

Concretely: add an optional parameter to Output.print_result which lets the user specify a formatter, which defaults to the err_formatter unless otherwise specified, and then use fprintf instead of printf.

In the future, we should really be returning good exit codes that tell if we got sat or unsat, but for now, if we put our diagnostic information into stderr and allow the user to specify their formatter, we'll at least be a better *nix citizen.

jtpaasch commented 3 years ago

Apologies for confusions on this. Here's a clarification: this ticket requires no changes to the CLI plugin. It only asks for changes to the library.

If the default formatter in the library is stderr, then the plugin behavior won't change. Everybody will still see their output printed to their tty just as they did before.

However, this will give a library user the power to specify a custom place for the output. Then the library user won't be forced to live with the output getting dumped directly to stdout.

codyroux commented 3 years ago

You don't want the user to be able to set the output stream?

jtpaasch commented 3 years ago

Not for the CLI. TTYs have redirection already. We don't need to reimplement that feature.

codyroux commented 3 years ago

Fair enough.