diff options
author | Prashanth Mundkur <prashanth.mundkur@gmail.com> | 2020-06-10 01:03:15 -0700 |
---|---|---|
committer | Prashanth Mundkur <prashanth.mundkur@gmail.com> | 2020-06-10 01:03:15 -0700 |
commit | 86bd287af50d296f3c83b7d0b524e3aaee073f78 (patch) | |
tree | 40b0a53366456a278797119ad2e51bcde37d9c78 /c_emulator/riscv_sim.c | |
parent | 6594b770016a11d0b358f9e022b7ebc91063a13a (diff) | |
download | sail-riscv-86bd287af50d296f3c83b7d0b524e3aaee073f78.zip sail-riscv-86bd287af50d296f3c83b7d0b524e3aaee073f78.tar.gz sail-riscv-86bd287af50d296f3c83b7d0b524e3aaee073f78.tar.bz2 |
Enable sailcov support in c_emulator if SAILCOV is set in the environment.
Diffstat (limited to 'c_emulator/riscv_sim.c')
-rw-r--r-- | c_emulator/riscv_sim.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/c_emulator/riscv_sim.c b/c_emulator/riscv_sim.c index ebd3b9d..4d6a4c0 100644 --- a/c_emulator/riscv_sim.c +++ b/c_emulator/riscv_sim.c @@ -14,6 +14,7 @@ #include "elf.h" #include "sail.h" #include "rts.h" +#include "sail_coverage.h" #include "riscv_platform.h" #include "riscv_platform_impl.h" #include "riscv_sail.h" @@ -551,6 +552,15 @@ void write_signature(const char *file) fclose(f); } +void close_logs(void) { +#ifdef SAILCOV + if (sail_coverage_exit() != 0) { + fprintf(stderr, "Could not write coverage information!\n"); + exit(EXIT_FAILURE); + } +#endif +} + void finish(int ec) { if (sig_file) write_signature(sig_file); @@ -572,6 +582,7 @@ void finish(int ec) fprintf(stderr, "Instructions: %d\n", total_insns); fprintf(stderr, "Perf: %.3f Kips\n", Kips); } + close_logs(); exit(ec); } @@ -903,4 +914,5 @@ int main(int argc, char **argv) #endif model_fini(); flush_logs(); + close_logs(); } |