common: make model_print() use OS file descriptor, not C library FILE*
authorBrian Norris <banorris@uci.edu>
Thu, 4 Apr 2013 19:46:13 +0000 (12:46 -0700)
committerBrian Norris <banorris@uci.edu>
Thu, 4 Apr 2013 19:57:13 +0000 (12:57 -0700)
commite52837077816345a2afa94b42195992a5871824c
tree8113ee51aa9012a5abb9a449c53857af94032de0
parent28067adf4ed506b7e38ddf38e522d5a9621bef92
common: make model_print() use OS file descriptor, not C library FILE*

A C library FILE does buffering (and possibly other opaque operations)
that can conflict with the model-checker's methods of snapshotting
memory. Particularly, it seems like we could corrupt and drop data that
was written to model_out, if the data was large enough and buffered in
just the right way.

Really, with the presence of dprintf(), there is no reason to print to a
FILE stream; we can just use the file descriptor (either STDOUT_FILENO
or the descriptor received from dup2()).

This fixes bugs seen in verbose mode, with a lot of extra debug
printing. Some of the output was being dropped.
common.cc
common.h
model.cc