Fix trace signal names getting hashed (#2643).

This commit is contained in:
Wilson Snyder
2020-11-16 18:11:27 -05:00
parent 26c0e6ba00
commit 70b3a599ce
11 changed files with 1269 additions and 1229 deletions
+12
View File
@@ -25,6 +25,7 @@
size_t VName::s_minLength = 32;
size_t VName::s_maxLength = 0; // Disabled
std::map<string, string> VName::s_dehashMap;
//######################################################################
// Wildcard
@@ -377,6 +378,15 @@ void VHashSha256::selfTest() {
//######################################################################
// VName
string VName::dehash(const string& in) {
const string::size_type pos = in.find("__Vhsh");
if (VL_LIKELY(pos == string::npos)) return in;
const string vhsh = in.substr(pos);
const auto& it = s_dehashMap.find(vhsh);
UASSERT(it != s_dehashMap.end(), "String not in reverse hash map '" << vhsh << "'");
return in.substr(0, pos) + it->second;
}
string VName::hashedName() {
if (m_name == "") return "";
if (m_hashed != "") return m_hashed; // Memoized
@@ -387,8 +397,10 @@ string VName::hashedName() {
VHashSha256 hash(m_name);
string suffix = "__Vhsh" + hash.digestSymbol();
if (s_minLength < s_maxLength) {
s_dehashMap[suffix] = m_name.substr(s_minLength);
m_hashed = m_name.substr(0, s_minLength) + suffix;
} else {
s_dehashMap[suffix] = m_name;
m_hashed = suffix;
}
return m_hashed;