From c6ddc7e081ecae0c9ba24eaf5d90cddd5a12b6ab Mon Sep 17 00:00:00 2001 From: Ryszard Rozak Date: Tue, 20 May 2025 16:50:48 +0200 Subject: [PATCH] Add option to filter type Signed-off-by: Ryszard Rozak --- src/VlcMain.cpp | 3 +-- src/VlcOptions.h | 9 +++++---- src/VlcPoint.h | 4 ++-- src/VlcTop.cpp | 7 ++----- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/VlcMain.cpp b/src/VlcMain.cpp index e39e90472..dafb83c3b 100644 --- a/src/VlcMain.cpp +++ b/src/VlcMain.cpp @@ -80,8 +80,7 @@ void VlcOptions::parseOptsList(int argc, char** argv) { }); DECL_OPTION("-write", Set, &m_writeFile); DECL_OPTION("-write-info", Set, &m_writeInfoFile); - DECL_OPTION("-toggle-only", OnOff, &m_toggleOnly); - DECL_OPTION("-skip-toggle", OnOff, &m_skipToggle); + DECL_OPTION("-filter-type", Set, &m_filterType); parser.finalize(); // Parse parameters diff --git a/src/VlcOptions.h b/src/VlcOptions.h index 26c48f35a..60473a354 100644 --- a/src/VlcOptions.h +++ b/src/VlcOptions.h @@ -20,6 +20,7 @@ #include "config_build.h" #include "verilatedos.h" +#include "VlcPoint.h" #include "config_rev.h" #include @@ -43,8 +44,7 @@ class VlcOptions final { bool m_unlink = false; // main switch: --unlink string m_writeFile; // main switch: --write string m_writeInfoFile; // main switch: --write-info - bool m_toggleOnly = false; // main switch: --m_toggle_only - bool m_skipToggle = false; // main switch: --m_skip_toggle + string m_filterType; // main switch: --filter-type // clang-format on private: @@ -71,8 +71,9 @@ public: bool unlink() const { return m_unlink; } string writeFile() const { return m_writeFile; } string writeInfoFile() const { return m_writeInfoFile; } - bool toggleOnly() const { return m_toggleOnly; } - bool skipToggle() const { return m_skipToggle; } + bool isTypeOk(const char* name) const { + return m_filterType == "" || m_filterType == VlcPoint::type(name); + } // METHODS (from main) static string version() VL_MT_DISABLED; diff --git a/src/VlcPoint.h b/src/VlcPoint.h index 6660a2acc..e04d20b5e 100644 --- a/src/VlcPoint.h +++ b/src/VlcPoint.h @@ -64,7 +64,7 @@ public: string filename() const { return keyExtract(VL_CIK_FILENAME, m_name.c_str()); } string comment() const { return keyExtract(VL_CIK_COMMENT, m_name.c_str()); } string hier() const { return keyExtract(VL_CIK_HIER, m_name.c_str()); } - string type() const { return keyExtract(VL_CIK_TYPE, m_name.c_str()); } + string type() const { return type(m_name.c_str()); } string thresh() const { // string as maybe "" return keyExtract(VL_CIK_THRESH, m_name.c_str()); @@ -73,7 +73,7 @@ public: int lineno() const { return std::atoi(keyExtract(VL_CIK_LINENO, m_name.c_str()).c_str()); } int column() const { return std::atoi(keyExtract(VL_CIK_COLUMN, m_name.c_str()).c_str()); } // METHODS - static bool isToggle(const char* name) { return keyExtract(VL_CIK_TYPE, name) == "toggle"; } + static string type(const char* name) { return keyExtract(VL_CIK_TYPE, name); } static string keyExtract(const char* shortKey, const char* name) { // Hot function const size_t shortLen = std::strlen(shortKey); diff --git a/src/VlcTop.cpp b/src/VlcTop.cpp index 7332cd957..87670f6ca 100644 --- a/src/VlcTop.cpp +++ b/src/VlcTop.cpp @@ -51,11 +51,8 @@ void VlcTop::readCoverage(const string& filename, bool nonfatal) { if (line[secspace] == '\'' && line[secspace + 1] == ' ') break; } const string point = line.substr(3, secspace - 3); - if (opt.skipToggle() && VlcPoint::isToggle(point.c_str())) { - continue; - } else if (opt.toggleOnly() && !VlcPoint::isToggle(point.c_str())) { - continue; - } + if (!opt.isTypeOk(point.c_str())) continue; + const uint64_t hits = std::atoll(line.c_str() + secspace + 1); // UINFO(9," point '"<