From b84c9bb4c0b2b6cbf672a800c1b228958a88e269 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 11 Nov 2020 19:00:10 -0500 Subject: [PATCH] Internals: Show scope debug information. --- src/V3Ast.cpp | 4 ++-- src/V3Ast.h | 3 ++- src/V3AstNodes.cpp | 11 +++++++++-- src/V3AstNodes.h | 1 + test_regress/t/t_lint_inherit.v | 2 ++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 6444ae0e4..f1b146440 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -1113,7 +1113,7 @@ void AstNode::dumpTreeAndNext(std::ostream& os, const string& indent, int maxDep } } -void AstNode::dumpTreeFile(const string& filename, bool append, bool doDump) { +void AstNode::dumpTreeFile(const string& filename, bool append, bool doDump, bool doCheck) { // Not const function as calls checkTree if (doDump) { { // Write log & close @@ -1131,7 +1131,7 @@ void AstNode::dumpTreeFile(const string& filename, bool append, bool doDump) { } } } - if (v3Global.opt.debugCheck() || v3Global.opt.dumpTree()) { + if (doCheck && (v3Global.opt.debugCheck() || v3Global.opt.dumpTree())) { // Error check checkTree(); // Broken isn't part of check tree because it can munge iterp's diff --git a/src/V3Ast.h b/src/V3Ast.h index 120bb13ad..0c37dde78 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1821,7 +1821,8 @@ public: void dumpTreeGdb(); // For GDB only void dumpTreeAndNext(std::ostream& os = std::cout, const string& indent = " ", int maxDepth = 0) const; - void dumpTreeFile(const string& filename, bool append = false, bool doDump = true); + void dumpTreeFile(const string& filename, bool append = false, bool doDump = true, + bool doCheck = true); static void dumpTreeFileGdb(const char* filenamep = nullptr); // METHODS - queries diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 3074722cf..c620cb432 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -1090,6 +1090,7 @@ void AstCell::dump(std::ostream& str) const { void AstCellInline::dump(std::ostream& str) const { this->AstNode::dump(str); str << " -> " << origModName(); + str << " [scopep=" << reinterpret_cast(scopep()) << "]"; } const char* AstClassPackage::broken() const { BROKEN_BASE_RTN(AstNodeModule::broken()); @@ -1179,7 +1180,7 @@ void AstInitArray::dump(std::ostream& str) const { str << " ..."; break; } - str << " [" << itr.first << "]=" << (void*)itr.second; + str << " [" << itr.first << "]=" << reinterpret_cast(itr.second); } } void AstJumpGo::dump(std::ostream& str) const { @@ -1415,7 +1416,7 @@ void AstTypeTable::dump(std::ostream& str) const { } void AstAssocArrayDType::dumpSmall(std::ostream& str) const { this->AstNodeDType::dumpSmall(str); - str << "[assoc-" << (void*)keyDTypep() << "]"; + str << "[assoc-" << reinterpret_cast(keyDTypep()) << "]"; } string AstAssocArrayDType::prettyDTypeName() const { return subDTypep()->prettyDTypeName() + "[" + keyDTypep()->prettyDTypeName() + "]"; @@ -1503,6 +1504,12 @@ void AstVar::dump(std::ostream& str) const { if (!lifetime().isNone()) str << " [" << lifetime().ascii() << "] "; str << " " << varType(); } +void AstScope::dump(std::ostream& str) const { + this->AstNode::dump(str); + str << " [abovep=" << reinterpret_cast(aboveScopep()) << "]"; + str << " [cellp=" << reinterpret_cast(aboveCellp()) << "]"; + str << " [modp=" << reinterpret_cast(modp()) << "]"; +} void AstSenTree::dump(std::ostream& str) const { this->AstNode::dump(str); if (isMulti()) str << " [MULTI]"; diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 24334009d..94cbc43e2 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -2248,6 +2248,7 @@ public: virtual bool maybePointedTo() const override { return true; } virtual string name() const override { return m_name; } // * = Scope name virtual void name(const string& name) override { m_name = name; } + virtual void dump(std::ostream& str) const override; string nameDotless() const; string nameVlSym() const { return ((string("vlSymsp->")) + nameDotless()); } AstNodeModule* modp() const { return m_modp; } diff --git a/test_regress/t/t_lint_inherit.v b/test_regress/t/t_lint_inherit.v index cfee91136..01674a6b4 100644 --- a/test_regress/t/t_lint_inherit.v +++ b/test_regress/t/t_lint_inherit.v @@ -45,8 +45,10 @@ module m2 input d, // Due to bug the below disable used to be ignored. // verilator lint_off UNOPT + // verilator lint_off UNOPTFLAT output reg [1:0] q // verilator lint_on UNOPT + // verilator lint_on UNOPTFLAT ); always @* begin