Internals: Fix debug prints racing with option parsing.
debug() declared by VL_DEGUB_FUNC used to cache the result of the debug level lookup (which depends on options) in a static. This meant that if the debug() function was called before option parsing, the default debug level of 0 would be used for the rest of the program, even if a --debug option was given. Fixed by not caching the debug level until after option parsing is complete.
This commit is contained in:
parent
f55177a49f
commit
add3811f46
|
|
@ -417,7 +417,11 @@ inline void v3errorEndFatal(std::ostringstream& sstr) {
|
|||
#define VL_DEBUG_FUNC \
|
||||
static int debug() { \
|
||||
static int level = -1; \
|
||||
if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel(__FILE__); \
|
||||
if (VL_UNLIKELY(level < 0)) { \
|
||||
const int debugSrcLevel = v3Global.opt.debugSrcLevel(__FILE__); \
|
||||
if (!v3Global.opt.available()) return debugSrcLevel; \
|
||||
level = debugSrcLevel; \
|
||||
} \
|
||||
return level; \
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -791,6 +791,9 @@ void V3Options::notify() {
|
|||
if (coverage() && savable()) {
|
||||
cmdfl->v3error("--coverage and --savable not supported together");
|
||||
}
|
||||
|
||||
// Mark options as available
|
||||
m_available = true;
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
|
|
|
|||
|
|
@ -361,6 +361,8 @@ private:
|
|||
bool m_oTable; // main switch: -Oa: lookup table creation
|
||||
// clang-format on
|
||||
|
||||
bool m_available = false; // Set to true at the end of option parsing
|
||||
|
||||
private:
|
||||
// METHODS
|
||||
void addArg(const string& arg);
|
||||
|
|
@ -402,6 +404,7 @@ public:
|
|||
void addVFile(const string& filename);
|
||||
void addForceInc(const string& filename);
|
||||
void notify();
|
||||
bool available() const { return m_available; }
|
||||
|
||||
// ACCESSORS (options)
|
||||
bool preprocOnly() const { return m_preprocOnly; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue