X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=kernel%2Flog.cc;h=a21ba480a6d6313fe6c0d1c743aba664d9d09770;hb=f975cf39cbedbca0482109b7aa625570a3857ee6;hp=1785809e41a63188dcd1d2529be90a830bb7206a;hpb=d079ab9d19b7d18134f5b6f30da9a6666f30ad97;p=yosys.git diff --git a/kernel/log.cc b/kernel/log.cc index 1785809e4..a21ba480a 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -41,8 +41,8 @@ YOSYS_NAMESPACE_BEGIN std::vector log_files; std::vector log_streams; std::map> log_hdump; -std::vector log_warn_regexes, log_nowarn_regexes, log_werror_regexes; -std::vector> log_expect_log, log_expect_warning, log_expect_error; +std::vector log_warn_regexes, log_nowarn_regexes, log_werror_regexes; +std::vector> log_expect_log, log_expect_warning, log_expect_error; std::set log_warnings, log_experimentals, log_experimentals_ignored; int log_warnings_count = 0; int log_warnings_count_noexpect = 0; @@ -177,11 +177,11 @@ void logv(const char *format, va_list ap) if (!linebuffer.empty() && linebuffer.back() == '\n') { for (auto &re : log_warn_regexes) - if (std::regex_search(linebuffer, re)) + if (YS_REGEX_NS::regex_search(linebuffer, re)) log_warning("Found log message matching -W regex:\n%s", str.c_str()); for (auto &item : log_expect_log) - if (std::regex_search(linebuffer, item.first)) + if (YS_REGEX_NS::regex_search(linebuffer, item.first)) item.second.current_count++; linebuffer.clear(); @@ -238,7 +238,7 @@ static void logv_warning_with_prefix(const char *prefix, bool suppressed = false; for (auto &re : log_nowarn_regexes) - if (std::regex_search(message, re)) + if (YS_REGEX_NS::regex_search(message, re)) suppressed = true; if (suppressed) @@ -251,12 +251,12 @@ static void logv_warning_with_prefix(const char *prefix, log_make_debug = 0; for (auto &re : log_werror_regexes) - if (std::regex_search(message, re)) + if (YS_REGEX_NS::regex_search(message, re)) log_error("%s", message.c_str()); bool warning_match = false; for (auto &item : log_expect_warning) - if (std::regex_search(message, item.first)) { + if (YS_REGEX_NS::regex_search(message, item.first)) { item.second.current_count++; warning_match = true; } @@ -349,11 +349,14 @@ static void logv_error_with_prefix(const char *prefix, log_error_atexit(); for (auto &item : log_expect_error) - if (std::regex_search(log_last_error, item.first)) + if (YS_REGEX_NS::regex_search(log_last_error, item.first)) item.second.current_count++; if (check_expected_logs) log_check_expected(); + + YS_DEBUGTRAP_IF_DEBUGGING; + #ifdef EMSCRIPTEN log_files = backup_log_files; throw 0; @@ -668,19 +671,23 @@ void log_check_expected() for (auto &item : log_expect_warning) { if (item.second.current_count == 0) { + log_warn_regexes.clear(); log_error("Expected warning pattern '%s' not found !\n", item.second.pattern.c_str()); } if (item.second.current_count != item.second.expected_count) { - log_error("Expected warning pattern '%s' found %d time(s), instead of %d time(s) !\n", + log_warn_regexes.clear(); + log_error("Expected warning pattern '%s' found %d time(s), instead of %d time(s) !\n", item.second.pattern.c_str(), item.second.current_count, item.second.expected_count); } } for (auto &item : log_expect_log) { if (item.second.current_count == 0) { + log_warn_regexes.clear(); log_error("Expected log pattern '%s' not found !\n", item.second.pattern.c_str()); } if (item.second.current_count != item.second.expected_count) { + log_warn_regexes.clear(); log_error("Expected log pattern '%s' found %d time(s), instead of %d time(s) !\n", item.second.pattern.c_str(), item.second.current_count, item.second.expected_count); } @@ -688,17 +695,18 @@ void log_check_expected() for (auto &item : log_expect_error) if (item.second.current_count == item.second.expected_count) { + log_warn_regexes.clear(); log("Expected error pattern '%s' found !!!\n", item.second.pattern.c_str()); #ifdef EMSCRIPTEN - log_files = backup_log_files; throw 0; #elif defined(_MSC_VER) _exit(0); #else _Exit(0); - #endif + #endif } else { display_error_log_msg = false; + log_warn_regexes.clear(); log_error("Expected error pattern '%s' not found !\n", item.second.pattern.c_str()); } }