From c48d80592e0ac4cd8a6175893222459a1b41895f Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 23 Sep 2024 07:34:12 -0400 Subject: [PATCH] Fix extra dot in coverage point hierarchy when using name()=''. --- Changes | 1 + src/V3EmitCImp.cpp | 6 +++--- test_regress/t/t_cover_main.out | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Changes b/Changes index 5cadc4502..08e483f95 100644 --- a/Changes +++ b/Changes @@ -62,6 +62,7 @@ Verilator 5.029 devel * Fix tracing when name() is empty (#5470). [Sam Shahrestani] * Fix timing mode not exiting on empty events (#5472). * Fix --binary with .cpp PLI filenames under relative directory paths. +* Fix extra dot in coverage point hierarchy when using name()=''. Verilator 5.028 2024-08-21 diff --git a/src/V3EmitCImp.cpp b/src/V3EmitCImp.cpp index 7737504e9..7588aaa2d 100644 --- a/src/V3EmitCImp.cpp +++ b/src/V3EmitCImp.cpp @@ -321,6 +321,8 @@ class EmitCImp final : EmitCFunc { } // static doesn't need save-restore as is constant puts("static uint32_t fake_zero_count = 0;\n"); + puts("std::string fullhier = std::string{VerilatedModule::name()} + hierp;\n"); + puts("if (!fullhier.empty() && fullhier[0] == '.') fullhier = fullhier.substr(1);\n"); // Used for second++ instantiation of identical bin puts("if (!enable) count32p = &fake_zero_count;\n"); puts("*count32p = 0;\n"); @@ -329,9 +331,7 @@ class EmitCImp final : EmitCFunc { puts(" \"filename\",filenamep,"); puts(" \"lineno\",lineno,"); puts(" \"column\",column,\n"); - // Need to move hier into scopes and back out if do this - // puts( "\"hier\",std::string{vlSymsp->name()} + hierp,"); - puts("\"hier\",std::string{VerilatedModule::name()} + hierp,"); + puts("\"hier\",fullhier,"); puts(" \"page\",pagep,"); puts(" \"comment\",commentp,"); puts(" (linescovp[0] ? \"linescov\" : \"\"), linescovp);\n"); diff --git a/test_regress/t/t_cover_main.out b/test_regress/t/t_cover_main.out index 3dc822828..4194def02 100644 --- a/test_regress/t/t_cover_main.out +++ b/test_regress/t/t_cover_main.out @@ -1,2 +1,2 @@ # SystemC::Coverage-3 -C 'ft/t_cover_main.vl9n4pagev_line/toblockS9-11h.t' 1 +C 'ft/t_cover_main.vl9n4pagev_line/toblockS9-11ht' 1