mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-06 14:13:23 +00:00
kernel: Trap in log_error()
when a debugger is attached.
The workflow of debugging fatal pass errors in Yosys is flawed in three ways: 1. Running Yosys under a debugger is sufficient for the debugger to catch some fatal errors (segfaults, aborts, STL exceptions) but not others (`log_error()`, `log_cmd_error()`). This is neither obvious nor easy to remember. 2. To catch Yosys-specific fatal errors, it is necessary to set a breakpoint at `logv_error_with_prefix()`, or at least, `logv_error()`. This is neither obvious nor easy to remember, and GDB's autocomplete takes many seconds to suggest function names due to the large amount of symbols in Yosys. 3. If a breakpoint is not set and Yosys encounters with such a fatal error, the process terminates. When debugging a crash that takes a long time to reproduce (or a nondeterministic crash) this can waste a significant amount of time. To solve this problem, add a macro `YS_DEBUGTRAP` that acts as a hard breakpoint (if available), and a macro `YS_DEBUGTRAP_IF_DEBUGGING` that acts as a hard breakpoint only if debugger is present. Then, use `YS_DEBUGTRAP_IF_DEBUGGING` in `logv_error_with_prefix()` to obviate the need for a breakpoint on nearly every platform. Co-Authored-By: Alberto Gonzalez <boqwxp@airmail.cc>
This commit is contained in:
parent
cf14e186eb
commit
e9f2d3f009
2 changed files with 44 additions and 3 deletions
|
@ -354,6 +354,9 @@ static void logv_error_with_prefix(const char *prefix,
|
|||
|
||||
if (check_expected_logs)
|
||||
log_check_expected();
|
||||
|
||||
YS_DEBUGTRAP_IF_DEBUGGING;
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
log_files = backup_log_files;
|
||||
throw 0;
|
||||
|
@ -673,7 +676,7 @@ void log_check_expected()
|
|||
}
|
||||
if (item.second.current_count != item.second.expected_count) {
|
||||
log_warn_regexes.clear();
|
||||
log_error("Expected warning pattern '%s' found %d time(s), instead of %d time(s) !\n",
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -700,7 +703,7 @@ void log_check_expected()
|
|||
_exit(0);
|
||||
#else
|
||||
_Exit(0);
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
display_error_log_msg = false;
|
||||
log_warn_regexes.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue