24 #if !defined(_WIN32) || defined(__MINGW32__)
25 # include <sys/time.h>
56 #if defined(_WIN32) && !defined(__MINGW32__)
58 int gettimeofday(
struct timeval *tv,
struct timezone *tz)
60 LARGE_INTEGER counter;
63 QueryPerformanceFrequency(&freq);
64 QueryPerformanceCounter(&counter);
66 counter.QuadPart *= 1000000;
67 counter.QuadPart /= freq.QuadPart;
69 tv->tv_sec = long(counter.QuadPart / 1000000);
70 tv->tv_usec = counter.QuadPart % 1000000;
76 void logv(
const char *format, va_list ap)
78 while (format[0] ==
'\n' && format[1] != 0) {
83 std::string str =
vstringf(format, ap);
88 size_t nnl_pos = str.find_last_not_of(
'\n');
89 if (nnl_pos == std::string::npos)
104 gettimeofday(&tv,
NULL);
109 tv.tv_usec += 1000000;
113 time_str +=
stringf(
"[%05d.%06d] ",
int(tv.tv_sec),
int(tv.tv_usec));
116 if (format[0] && format[strlen(format)-1] ==
'\n')
120 fputs(time_str.c_str(), f);
127 fputs(str.c_str(), f);
135 bool pop_errfile =
false;
180 void log(
const char *format, ...)
183 va_start(ap, format);
191 va_start(ap, format);
199 va_start(ap, format);
207 va_start(ap, format);
214 va_start(ap, format);
271 std::stringstream buf;
286 const char *p = str.
c_str();
287 if (p[0] ==
'\\' && p[1] !=
'$' && p[1] != 0)
294 std::stringstream buf;
296 log(
"%s", buf.str().c_str());
302 #ifdef YOSYS_ENABLE_COVER
304 std::map<std::string, std::pair<std::string, int>> extra_coverage_data;
306 void cover_extra(std::string parent, std::string
id,
bool increment) {
307 if (extra_coverage_data.count(
id) == 0) {
308 for (CoverData *p = __start_yosys_cover_list; p != __stop_yosys_cover_list; p++)
310 extra_coverage_data[
id].first =
stringf(
"%s:%d:%s", p->file, p->line, p->func);
314 extra_coverage_data[
id].second++;
317 std::map<std::string, std::pair<std::string, int>> get_coverage_data()
319 std::map<std::string, std::pair<std::string, int>> coverage_data;
322 std::string key =
stringf(
"passes.%s", it.first.c_str());
323 coverage_data[key].first =
stringf(
"%s:%d:%s", __FILE__, __LINE__, __FUNCTION__);
324 coverage_data[key].second += it.second->call_counter;
327 for (
auto &it : extra_coverage_data) {
328 if (coverage_data.count(it.first))
329 log_warning(
"found duplicate coverage id \"%s\".\n", it.first.c_str());
330 coverage_data[it.first].first = it.second.first;
331 coverage_data[it.first].second += it.second.second;
334 for (CoverData *p = __start_yosys_cover_list; p != __stop_yosys_cover_list; p++) {
335 if (coverage_data.count(p->id))
336 log_warning(
"found duplicate coverage id \"%s\".\n", p->id);
337 coverage_data[p->id].first =
stringf(
"%s:%d:%s", p->file, p->line, p->func);
338 coverage_data[p->id].second += p->counter;
341 for (
auto &it : coverage_data)
342 if (!it.second.first.compare(0, strlen(YOSYS_SRC
"/"), YOSYS_SRC
"/"))
343 it.second.first = it.second.first.substr(strlen(YOSYS_SRC
"/"));
345 return coverage_data;
const char * c_str() const
void dump_cell(std::ostream &f, std::string indent, const RTLIL::Cell *cell)
std::string stringf(const char *fmt,...)
void log_warning(const char *format,...)
std::set< RTLIL::IdString > log_id_cache
void log_header(const char *format,...)
#define YOSYS_NAMESPACE_END
void log_dump_val_worker(RTLIL::SigSpec v)
const char * log_signal(const RTLIL::SigSpec &sig, bool autoint)
void logv_warning(const char *format, va_list ap)
void log_error(const char *format,...)
void logv_header(const char *format, va_list ap)
static struct timeval initial_tv
std::list< std::string > string_buf
std::vector< std::ostream * > log_streams
static int log_newline_count
YOSYS_NAMESPACE_BEGIN std::vector< FILE * > log_files
std::string vstringf(const char *fmt, va_list ap)
int GetSize(RTLIL::Wire *wire)
#define log_assert(_assert_expr_)
std::vector< int > header_count
void log_cmd_error(const char *format,...)
#define YOSYS_NAMESPACE_BEGIN
void dump_sigspec(std::ostream &f, const RTLIL::SigSpec &sig, bool autoint=true)
void log(const char *format,...)
void logv_error(const char *format, va_list ap)
std::map< std::string, Pass * > pass_register
void log_cell(RTLIL::Cell *cell, std::string indent)
std::string id(RTLIL::IdString internal_id, bool may_rename=true)
void logv(const char *format, va_list ap)
const char * log_id(RTLIL::IdString str)
void update(const std::string &s)
static bool next_print_log