X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=common.cc;h=e6c6cce60ccd2e2b73bc22d5ae48129a37c307b1;hb=feccc087e6d4a80e9e597e34c98f6dbdc82b5748;hp=bbb30539a8bd36710d9837614c2823b4f1ed3894;hpb=80f5924fb6c148ecb703dfeae5a751948062588b;p=c11tester.git diff --git a/common.cc b/common.cc index bbb30539..e6c6cce6 100644 --- a/common.cc +++ b/common.cc @@ -14,15 +14,15 @@ #define MAX_TRACE_LEN 100 -FILE *model_out; -int fd_user_out; /**< @brief File descriptor from which to read user program output */ +/** @brief Model-checker output stream; default to stdout until redirected */ +FILE *model_out = stdout; #define CONFIG_STACKTRACE /** Print a backtrace of the current program state. */ void print_trace(void) { #ifdef CONFIG_STACKTRACE - print_stacktrace(stdout); + print_stacktrace(model_out); #else void *array[MAX_TRACE_LEN]; char **strings; @@ -60,6 +60,10 @@ void model_assert(bool expr, const char *file, int line) } } +#ifndef CONFIG_DEBUG + +static int fd_user_out; /**< @brief File descriptor from which to read user program output */ + /** * @brief Setup output redirecting * @@ -77,6 +81,8 @@ void model_assert(bool expr, const char *file, int line) * output much data, we will need to buffer it in user-space during execution. * This also means that if ModelChecker decides not to print an execution, it * should promptly clear the pipe. + * + * This function should only be called once. */ void redirect_output() { @@ -159,3 +165,4 @@ void print_program_output() } } } +#endif /* ! CONFIG_DEBUG */