88 std::vector<FILE*> out_files;
89 std::vector<std::string> patterns;
93 for (argidx = 1; argidx <
args.size(); argidx++)
95 if (
args[argidx] ==
"-q") {
99 if ((
args[argidx] ==
"-o" ||
args[argidx] ==
"-a" ||
args[argidx] ==
"-d") && argidx+1 <
args.size()) {
100 const char *open_mode =
args[argidx] ==
"-a" ?
"a+" :
"w";
101 std::string filename =
args[++argidx];
102 if (
args[argidx-1] ==
"-d") {
104 log_cmd_error(
"The 'cover -d' option is not supported on win32.\n");
106 char filename_buffer[4096];
107 snprintf(filename_buffer, 4096,
"%s/yosys_cover_%d_XXXXXX.txt", filename.c_str(), getpid());
108 filename = mkstemps(filename_buffer, 4);
111 FILE *f = fopen(filename.c_str(), open_mode);
113 for (
auto f : out_files)
117 out_files.push_back(f);
122 while (argidx <
args.size() &&
args[argidx].substr(0, 1) !=
"-")
123 patterns.push_back(
args[argidx++]);
127 log_header(
"Printing code coverage counters.\n");
131 #ifdef YOSYS_ENABLE_COVER
132 for (
auto &it : get_coverage_data()) {
133 if (!patterns.empty()) {
134 for (
auto &p : patterns)
135 if (
patmatch(p.c_str(), it.first.c_str()))
140 for (
auto f : out_files)
141 fprintf(f,
"%-60s %10d %s\n", it.second.first.c_str(), it.second.second, it.first.c_str());
143 log(
"%-60s %10d %s\n", it.second.first.c_str(), it.second.second, it.first.c_str());
146 for (
auto f : out_files)
149 log_cmd_error(
"This version of Yosys was not built with support for code coverage counters.\n");
152 for (
auto f : out_files)
void log_header(const char *format,...)
bool patmatch(const char *pattern, const char *string)
void log_cmd_error(const char *format,...)
void log(const char *format,...)
void extra_args(std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)