mirror of
https://github.com/verilator/verilator.git
synced 2026-10-07 18:42:58 +02:00
Fix trace signal names getting hashed (#2643).
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user