Fix gcov dump on warnings discarding later coverage counts (#8017)

This commit is contained in:
Yilou Wang 2026-07-31 18:08:05 +02:00 committed by GitHub
parent 781f6d90bf
commit 704c5a1c96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -3887,7 +3887,7 @@ void Verilated::runFlushCallbacks() VL_MT_SAFE {
// When running internal code coverage (gcc --coverage, as opposed to
// verilator --coverage), dump coverage data to properly cover failing
// tests.
VL_GCOV_DUMP();
VL_GCOV_DUMP_RESET();
}
void Verilated::addExitCb(VoidPCb cb, void* datap) VL_MT_SAFE { addCbExit(cb, datap); }

View File

@ -332,10 +332,19 @@
#ifdef VL_GCOV
extern "C" void __gcov_dump();
extern "C" void __gcov_reset();
// Dump internal code coverage data before e.g. std::abort()
# define VL_GCOV_DUMP() __gcov_dump()
// Dump, then re-arm dumping; dumping is one-shot, so without the reset a dump
// on a nonfatal path would silently discard everything counted after it
# define VL_GCOV_DUMP_RESET() \
do { \
__gcov_dump(); \
__gcov_reset(); \
} while (false)
#else
# define VL_GCOV_DUMP()
# define VL_GCOV_DUMP_RESET()
#endif
//=========================================================================