X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=blobdiff_plain;f=common.cc;h=904a298e9070327100e968daf55573fc25afcbf4;hp=338058d9f3a8b990278605fe0b6c6c1c38e0d082;hb=241f7577895a5c74aad14d9903b6c25ea02e217d;hpb=964ae5c3c62fc383c53e90b20f32ba17b7b616ab diff --git a/common.cc b/common.cc index 338058d9..904a298e 100644 --- a/common.cc +++ b/common.cc @@ -22,9 +22,7 @@ int model_out = STDOUT_FILENO; void print_trace(void) { #ifdef CONFIG_STACKTRACE - FILE *file = fdopen(model_out, "w"); - print_stacktrace(file); - fclose(file); + print_stacktrace(model_out); #else void *array[MAX_TRACE_LEN]; char **strings; @@ -35,16 +33,11 @@ void print_trace(void) model_print("\nDumping stack trace (%d frames):\n", size); - for (i = 0; i < size; i++) + for (i = 0;i < size;i++) model_print("\t%s\n", strings[i]); free(strings); -#endif /* CONFIG_STACKTRACE */ -} - -void model_print_summary(void) -{ - model->print_summary(); +#endif /* CONFIG_STACKTRACE */ } void assert_hook(void) @@ -57,14 +50,14 @@ void model_assert(bool expr, const char *file, int line) if (!expr) { char msg[100]; sprintf(msg, "Program has hit assertion in file %s at line %d\n", - file, line); + file, line); model->assert_user_bug(msg); } } #ifndef CONFIG_DEBUG -static int fd_user_out; /**< @brief File descriptor from which to read user program output */ +static int fd_user_out; /**< @brief File descriptor from which to read user program output */ /** * @brief Setup output redirecting @@ -146,7 +139,7 @@ void clear_program_output() { fflush(stdout); char buf[200]; - while (read_to_buf(fd_user_out, buf, sizeof(buf))); + while (read_to_buf(fd_user_out, buf, sizeof(buf))) ; } /** @brief Print out any pending program output */ @@ -154,6 +147,8 @@ void print_program_output() { char buf[200]; + model_print("---- BEGIN PROGRAM OUTPUT ----\n"); + /* Gather all program output */ fflush(stdout); @@ -172,5 +167,7 @@ void print_program_output() ret -= res; } } + + model_print("---- END PROGRAM OUTPUT ----\n"); } -#endif /* ! CONFIG_DEBUG */ +#endif /* ! CONFIG_DEBUG */