mirror of
https://github.com/YosysHQ/yosys
synced 2026-06-03 15:47:58 +00:00
Make log_error() work in a Multithreaded context.
`log_error()` causes an exit so we don't have to try too hard here. The main thing is to ensure that we normally are able to exit without causing a stack overflow due to recursive asserts about not being in a `Multithreaded` context.
This commit is contained in:
parent
577191e44d
commit
af3bb9751f
2 changed files with 13 additions and 8 deletions
|
|
@ -324,6 +324,14 @@ void log_formatted_file_info(std::string_view filename, int lineno, std::string
|
||||||
log("%s:%d: Info: %s", filename, lineno, str);
|
log("%s:%d: Info: %s", filename, lineno, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void log_suppressed() {
|
||||||
|
if (log_debug_suppressed && !log_make_debug) {
|
||||||
|
constexpr const char* format = "<suppressed ~%d debug messages>\n";
|
||||||
|
logv_string(format, stringf(format, log_debug_suppressed));
|
||||||
|
log_debug_suppressed = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[[noreturn]]
|
[[noreturn]]
|
||||||
static void log_error_with_prefix(std::string_view prefix, std::string str)
|
static void log_error_with_prefix(std::string_view prefix, std::string str)
|
||||||
{
|
{
|
||||||
|
|
@ -345,7 +353,9 @@ static void log_error_with_prefix(std::string_view prefix, std::string str)
|
||||||
}
|
}
|
||||||
|
|
||||||
log_last_error = std::move(str);
|
log_last_error = std::move(str);
|
||||||
log("%s%s", prefix, log_last_error);
|
std::string message(prefix);
|
||||||
|
message += log_last_error;
|
||||||
|
logv_string("%s%s", message);
|
||||||
log_flush();
|
log_flush();
|
||||||
|
|
||||||
log_make_debug = bak_log_make_debug;
|
log_make_debug = bak_log_make_debug;
|
||||||
|
|
@ -355,7 +365,7 @@ static void log_error_with_prefix(std::string_view prefix, std::string str)
|
||||||
item.current_count++;
|
item.current_count++;
|
||||||
|
|
||||||
for (auto &[_, item] : log_expect_prefix_error)
|
for (auto &[_, item] : log_expect_prefix_error)
|
||||||
if (std::regex_search(string(prefix) + string(log_last_error), item.pattern))
|
if (std::regex_search(message, item.pattern))
|
||||||
item.current_count++;
|
item.current_count++;
|
||||||
|
|
||||||
log_check_expected();
|
log_check_expected();
|
||||||
|
|
|
||||||
|
|
@ -206,12 +206,7 @@ template <typename... Args>
|
||||||
log_formatted_cmd_error(fmt.format(args...));
|
log_formatted_cmd_error(fmt.format(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void log_suppressed() {
|
void log_suppressed();
|
||||||
if (log_debug_suppressed && !log_make_debug) {
|
|
||||||
log("<suppressed ~%d debug messages>\n", log_debug_suppressed);
|
|
||||||
log_debug_suppressed = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct LogMakeDebugHdl {
|
struct LogMakeDebugHdl {
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue