From a433096d5a236b996b9ec0b287c077f268aece1c Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 4 Jun 2020 19:49:18 -0400 Subject: [PATCH] Internals: Fix misc internal coverage holes. No functional change intended. --- include/verilated.cpp | 13 +++++++++++++ include/verilated_vpi.cpp | 14 ++++++++------ src/V3Global.cpp | 4 ---- src/V3Global.h | 1 - src/V3MergeCond.cpp | 2 +- src/V3Os.cpp | 2 -- src/V3Os.h | 1 - 7 files changed, 22 insertions(+), 15 deletions(-) diff --git a/include/verilated.cpp b/include/verilated.cpp index 2c8c1eada..b1f0ea992 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -2254,11 +2254,24 @@ void Verilated::flushCb(VerilatedVoidCb cb) VL_MT_SAFE { } } +// When running internal code coverage (gcc --coverage, as opposed to +// verilator --coverage), dump coverage data to properly cover failing +// tests. +#ifdef VL_GCOV +extern "C" { +void __gcov_flush(); // gcc sources gcc/gcov-io.h has the prototype +} +void vl_gcov_flush() { __gcov_flush(); } +#else +void vl_gcov_flush() {} +#endif + void Verilated::flushCall() VL_MT_SAFE { const VerilatedLockGuard lock(m_mutex); if (s_flushCb) (*s_flushCb)(); fflush(stderr); fflush(stdout); + vl_gcov_flush(); } const char* Verilated::productName() VL_PURE { return VERILATOR_PRODUCT; } diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index 02367290a..e4c5a2c20 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -623,7 +623,7 @@ const char* VerilatedVpiError::strFromVpiVal(PLI_INT32 vpiVal) VL_MT_SAFE { "vpiRawFourStateVal", }; // clang-format on - if (vpiVal < 0) return names[0]; + if (VL_UNCOVERABLE(vpiVal < 0)) return names[0]; return names[(vpiVal <= vpiRawFourStateVal) ? vpiVal : 0]; } const char* VerilatedVpiError::strFromVpiObjType(PLI_INT32 vpiVal) VL_MT_SAFE { @@ -767,7 +767,7 @@ const char* VerilatedVpiError::strFromVpiObjType(PLI_INT32 vpiVal) VL_MT_SAFE { "vpiGenVar" }; // clang-format on - if (vpiVal < 0) return names[0]; + if (VL_UNCOVERABLE(vpiVal < 0)) return names[0]; return names[(vpiVal <= vpiGenVar) ? vpiVal : 0]; } const char* VerilatedVpiError::strFromVpiMethod(PLI_INT32 vpiVal) VL_MT_SAFE { @@ -850,7 +850,7 @@ const char* VerilatedVpiError::strFromVpiCallbackReason(PLI_INT32 vpiVal) VL_MT_ "cbAtEndOfSimTime" }; // clang-format on - if (vpiVal < 0) return names[0]; + if (VL_UNCOVERABLE(vpiVal < 0)) return names[0]; return names[(vpiVal <= cbAtEndOfSimTime) ? vpiVal : 0]; } @@ -1141,7 +1141,8 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { if (VL_UNLIKELY(!vop->rangep())) return 0; return (new VerilatedVpioConst(vop->rangep()->left()))->castVpiHandle(); } - _VL_VPI_WARNING(__FILE__, __LINE__, "%s: Unsupported vpiHandle (%p) for type %s, nothing will be returned", + _VL_VPI_WARNING(__FILE__, __LINE__, + "%s: Unsupported vpiHandle (%p) for type %s, nothing will be returned", VL_FUNC, object, VerilatedVpiError::strFromVpiMethod(type)); return 0; } @@ -1153,7 +1154,8 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { if (VL_UNLIKELY(!vop->rangep())) return 0; return (new VerilatedVpioConst(vop->rangep()->right()))->castVpiHandle(); } - _VL_VPI_WARNING(__FILE__, __LINE__, "%s: Unsupported vpiHandle (%p) for type %s, nothing will be returned", + _VL_VPI_WARNING(__FILE__, __LINE__, + "%s: Unsupported vpiHandle (%p) for type %s, nothing will be returned", VL_FUNC, object, VerilatedVpiError::strFromVpiMethod(type)); return 0; } @@ -2089,7 +2091,7 @@ PLI_INT32 vpi_control(PLI_INT32 operation, ...) { } case vpiStop: { VL_STOP_MT("", 0, "*VPI*"); - return 1; + return 1; // LCOV_EXCL_LINE } default: { _VL_VPI_WARNING(__FILE__, __LINE__, "%s: Unsupported type %s, ignoring", VL_FUNC, diff --git a/src/V3Global.cpp b/src/V3Global.cpp index 553e248fe..1e1f0a784 100644 --- a/src/V3Global.cpp +++ b/src/V3Global.cpp @@ -36,10 +36,6 @@ AstNetlist* V3Global::makeNetlist() { void V3Global::checkTree() { rootp()->checkTree(); } -void V3Global::clear() { - if (m_rootp) VL_DO_CLEAR(m_rootp->deleteTree(), m_rootp = NULL); -} - void V3Global::readFiles() { // NODE STATE // AstNode::user4p() // VSymEnt* Package and typedef symbol names diff --git a/src/V3Global.h b/src/V3Global.h index 4d3c96473..659b47737 100644 --- a/src/V3Global.h +++ b/src/V3Global.h @@ -105,7 +105,6 @@ public: UASSERT(!m_rootp, "call once"); m_rootp = makeNetlist(); } - void clear(); // ACCESSORS (general) AstNetlist* rootp() const { return m_rootp; } VWidthMinUsage widthMinUsage() const { return m_widthMinUsage; } diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index 2a5fd9556..30edff29c 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -192,7 +192,7 @@ private: : new AstConst(rhsp->fileline(), AstConst::LogicFalse()); } } - rhsp->v3fatal("Don't know how to fold expression"); + rhsp->v3fatalSrc("Don't know how to fold expression"); } void mergeEnd() { diff --git a/src/V3Os.cpp b/src/V3Os.cpp index 74b7495a2..8d0d07546 100644 --- a/src/V3Os.cpp +++ b/src/V3Os.cpp @@ -240,8 +240,6 @@ void V3Os::unlinkRegexp(const string& dir, const string& regexp) { } } -std::string V3Os::getcwd() { return filenameRealPath("."); } - //###################################################################### // METHODS (random) diff --git a/src/V3Os.h b/src/V3Os.h index 8e511257d..a107f36dc 100644 --- a/src/V3Os.h +++ b/src/V3Os.h @@ -53,7 +53,6 @@ public: // METHODS (directory utilities) static void createDir(const string& dirname); static void unlinkRegexp(const string& dir, const string& regexp); - static std::string getcwd(); // Return the current working directory // METHODS (random) static vluint64_t rand64(vluint64_t* statep);