diff options
author | Clifford Wolf <clifford@clifford.at> | 2014-07-24 03:49:32 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2014-07-24 03:49:32 +0200 |
commit | 9cf12570ba639ca23e1d611a27160fb46b3c46d1 (patch) | |
tree | 04500fef5e6542aeab91f3c5b61dc4602be0218f | |
parent | 6b1018314c130ffa12df2e8c73f1c0cd5853b6f7 (diff) | |
download | yosys-9cf12570ba639ca23e1d611a27160fb46b3c46d1.tar.gz yosys-9cf12570ba639ca23e1d611a27160fb46b3c46d1.tar.bz2 yosys-9cf12570ba639ca23e1d611a27160fb46b3c46d1.zip |
Added support for YOSYS_COVER_DIR env variable
-rw-r--r-- | kernel/driver.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/kernel/driver.cc b/kernel/driver.cc index e365e67c3..4992686bd 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -749,6 +749,32 @@ int main(int argc, char **argv) delete yosys_design; yosys_design = NULL; +#ifndef NDEBUG + if (getenv("YOSYS_COVER_DIR")) + { + char filename_buffer[4096]; + snprintf(filename_buffer, 4096, "%s/yosys_cover_%d_XXXXXX.txt", getenv("YOSYS_COVER_DIR"), getpid()); + FILE *f = fdopen(mkstemps(filename_buffer, 4), "w"); + + if (f == NULL) + log_error("Can't create coverage file `%s'.\n", filename_buffer); + + log("<writing coverage file \"%s\">\n", filename_buffer); + + std::map<std::string, std::pair<std::string, int>> coverage_data; + for (CoverAgent *p = CoverAgent::first_cover_agent; p; p = p->next_cover_agent) { + if (coverage_data.count(p->id)) + log("WARNING: found duplicate coverage id \"%s\".\n", p->id); + coverage_data[p->id].first = stringf("%s:%d:%s", p->file, p->line, p->func); + coverage_data[p->id].second += p->ticks; + } + + for (auto &it : coverage_data) + fprintf(f, "%-40s %10d %s\n", it.second.first.c_str(), it.second.second, it.first.c_str()); + fclose(f); + } +#endif + log("\nREADY.\n"); log_pop(); |