From: Clifford Wolf Date: Sun, 4 Mar 2018 21:35:59 +0000 (+0100) Subject: Improve handling of warning messages X-Git-Tag: yosys-0.8~179 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e5534a080e953b7935defa92bed9452ed1616047;p=yosys.git Improve handling of warning messages Signed-off-by: Clifford Wolf --- diff --git a/kernel/driver.cc b/kernel/driver.cc index f49f6023b..97a78cd16 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -480,6 +480,8 @@ int main(int argc, char **argv) if (mode_v && !mode_q) log_files.push_back(stderr); + if (log_warnings_count) + log("Warnings: %d unique messages, %d total\n", GetSize(log_warnings), log_warnings_count); #ifdef _WIN32 log("End of script. Logfile hash: %s\n", hash.c_str()); #else diff --git a/kernel/log.cc b/kernel/log.cc index 8b12008bc..de564cb36 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -42,6 +42,8 @@ std::vector log_files; std::vector log_streams; std::map> log_hdump; std::vector log_warn_regexes, log_nowarn_regexes; +std::set log_warnings; +int log_warnings_count = 0; bool log_hdump_all = false; FILE *log_errfile = NULL; SHA1 *log_hasher = NULL; @@ -216,14 +218,26 @@ void logv_warning(const char *format, va_list ap) } else { - if (log_errfile != NULL && !log_quiet_warnings) - log_files.push_back(log_errfile); + if (log_warnings.count(message)) + { + log("Warning: %s", message.c_str()); + log_flush(); + } + else + { + if (log_errfile != NULL && !log_quiet_warnings) + log_files.push_back(log_errfile); - log("Warning: %s", message.c_str()); - log_flush(); + log("Warning: %s", message.c_str()); + log_flush(); - if (log_errfile != NULL && !log_quiet_warnings) - log_files.pop_back(); + if (log_errfile != NULL && !log_quiet_warnings) + log_files.pop_back(); + + log_warnings.insert(message); + } + + log_warnings_count++; } } @@ -242,14 +256,26 @@ void logv_warning_noprefix(const char *format, va_list ap) } else { - if (log_errfile != NULL && !log_quiet_warnings) - log_files.push_back(log_errfile); + if (log_warnings.count(message)) + { + log("%s", message.c_str()); + log_flush(); + } + else + { + if (log_errfile != NULL && !log_quiet_warnings) + log_files.push_back(log_errfile); - log("%s", message.c_str()); - log_flush(); + log("%s", message.c_str()); + log_flush(); + + if (log_errfile != NULL && !log_quiet_warnings) + log_files.pop_back(); + + log_warnings.insert(message); + } - if (log_errfile != NULL && !log_quiet_warnings) - log_files.pop_back(); + log_warnings_count++; } } diff --git a/kernel/log.h b/kernel/log.h index e27dafab9..a8aa58a9e 100644 --- a/kernel/log.h +++ b/kernel/log.h @@ -50,6 +50,8 @@ extern std::vector log_files; extern std::vector log_streams; extern std::map> log_hdump; extern std::vector log_warn_regexes, log_nowarn_regexes; +extern std::set log_warnings; +extern int log_warnings_count; extern bool log_hdump_all; extern FILE *log_errfile; extern SHA1 *log_hasher;