From cf4bf9b7a590bdf4093d70dcbbae2adae38b81d8 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 14 Jul 2018 18:45:06 -0400 Subject: [PATCH] Show file and line info when possible on internal graph errors. --- src/V3Cdc.cpp | 1 + src/V3Gate.cpp | 1 + src/V3Graph.cpp | 17 +++++++++++++++++ src/V3Graph.h | 3 +++ src/V3GraphAcyc.cpp | 1 + src/V3GraphAlg.cpp | 2 +- src/V3LinkCells.cpp | 1 + src/V3OrderGraph.h | 12 +++++++----- src/V3Split.cpp | 1 + src/V3Task.cpp | 1 + src/V3Trace.cpp | 3 +++ src/V3Tristate.cpp | 1 + 12 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/V3Cdc.cpp b/src/V3Cdc.cpp index 0fdafd536..b696c8b05 100644 --- a/src/V3Cdc.cpp +++ b/src/V3Cdc.cpp @@ -73,6 +73,7 @@ public: , m_asyncPath(false) {} virtual ~CdcEitherVertex() {} // ACCESSORS + virtual FileLine* fileline() const { return nodep()->fileline(); } AstScope* scopep() const { return m_scopep; } AstNode* nodep() const { return m_nodep; } AstSenTree* srcDomainp() const { return m_srcDomainp; } diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 374beb637..06c868ac5 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -172,6 +172,7 @@ public: // ACCESSORS virtual string name() const { return (cvtToStr((void*)m_nodep)+"@"+scopep()->prettyName()); } virtual string dotColor() const { return "yellow"; } + virtual FileLine* fileline() const { return nodep()->fileline(); } AstNode* nodep() const { return m_nodep; } AstActive* activep() const { return m_activep; } bool slow() const { return m_slow; } diff --git a/src/V3Graph.cpp b/src/V3Graph.cpp index f82d2503d..c29751677 100644 --- a/src/V3Graph.cpp +++ b/src/V3Graph.cpp @@ -118,6 +118,23 @@ uint32_t V3GraphVertex::outHash() const { return hash; } +void V3GraphVertex::v3errorEnd(std::ostringstream& str) const { + std::ostringstream nsstr; + nsstr<v3errorEnd(nsstr); + } +} +void V3GraphVertex::v3errorEndFatal(std::ostringstream& str) const { + v3errorEnd(str); assert(0); +} + std::ostream& operator<<(std::ostream& os, V3GraphVertex* vertexp) { os<<" VERTEX="<name(); if (vertexp->rank()) os<<" r"<rank(); diff --git a/src/V3Graph.h b/src/V3Graph.h index ab740f21e..359f2ff02 100644 --- a/src/V3Graph.h +++ b/src/V3Graph.h @@ -217,6 +217,7 @@ public: virtual string dotStyle() const { return ""; } virtual string dotName() const { return ""; } virtual uint32_t rankAdder() const { return 1; } + virtual FileLine* fileline() const { return NULL; } // NULL for unknown virtual int sortCmp(const V3GraphVertex* rhsp) const { // LHS goes first if of lower rank, or lower fanout if (m_rank < rhsp->m_rank) return -1; @@ -249,6 +250,8 @@ public: // METHODS /// Edges are routed around this vertex to point from "from" directly to "to" void rerouteEdges(V3Graph* graphp); + void v3errorEnd(std::ostringstream& str) const; + void v3errorEndFatal(std::ostringstream& str) const; }; std::ostream& operator<<(std::ostream& os, V3GraphVertex* vertexp); diff --git a/src/V3GraphAcyc.cpp b/src/V3GraphAcyc.cpp index cc694f06d..86095a0c2 100644 --- a/src/V3GraphAcyc.cpp +++ b/src/V3GraphAcyc.cpp @@ -56,6 +56,7 @@ public: bool isDelete() const { return m_deleted; } virtual string name() const { return m_origVertexp->name(); } virtual string dotColor() const { return m_origVertexp->dotColor(); } + virtual FileLine* fileline() const { return m_origVertexp->fileline(); } }; //-------------------------------------------------------------------- diff --git a/src/V3GraphAlg.cpp b/src/V3GraphAlg.cpp index da908ecb5..e5d7b45f1 100644 --- a/src/V3GraphAlg.cpp +++ b/src/V3GraphAlg.cpp @@ -532,7 +532,7 @@ double V3Graph::orderDFSIterate(V3GraphVertex* vertexp) { // Compute fanouts of each node // If forward edge, don't double count that fanout if (vertexp->user() == 2) return vertexp->fanout(); // Already processed it - if (vertexp->user() == 1) v3fatalSrc("Loop found, backward edges should be dead"); + if (vertexp->user() == 1) vertexp->v3fatalSrc("Loop found, backward edges should be dead"); vertexp->user(1); double fanout = 0; for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index e8ec640ca..fdb23d683 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -62,6 +62,7 @@ public: virtual ~LinkCellsVertex() {} AstNodeModule* modp() const { return m_modp; } virtual string name() const { return modp()->name(); } + virtual FileLine* fileline() const { return modp()->fileline(); } // Recursive modules get space for maximum recursion virtual uint32_t rankAdder() const { return m_modp->recursiveClone() ? (1+v3Global.opt.moduleRecursionDepth()) : 1; } }; diff --git a/src/V3OrderGraph.h b/src/V3OrderGraph.h index a4bf7b490..e6ec2b096 100644 --- a/src/V3OrderGraph.h +++ b/src/V3OrderGraph.h @@ -222,6 +222,7 @@ public: virtual ~OrderVarVertex() {} virtual OrderVarVertex* clone (V3Graph* graphp) const = 0; virtual OrderVEdgeType type() const = 0; + virtual FileLine* fileline() const { return varScp()->fileline(); } // ACCESSORS AstVarScope* varScp() const { return m_varScp; } void isClock(bool flag) { m_isClock=flag; } @@ -328,11 +329,12 @@ public: // METHODS virtual OrderVEdgeType type() const { return OrderVEdgeType::VERTEX_MOVE; } virtual string dotColor() const { - if (logicp()) { - return logicp()->dotColor(); - } else { - return ""; - } + if (logicp()) return logicp()->dotColor(); + else return ""; + } + virtual FileLine* fileline() const { + if (logicp()) return logicp()->fileline(); + else return NULL; } virtual string name() const { string nm; diff --git a/src/V3Split.cpp b/src/V3Split.cpp index 4d49ece44..28f540dba 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -117,6 +117,7 @@ protected: return m_nodep->name(); } } + virtual FileLine* fileline() const { return nodep()->fileline(); } public: virtual AstNode* nodep() const { return m_nodep; } }; diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 9df3e171e..e70515e9c 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -73,6 +73,7 @@ public: AstNodeFTask* nodep() const { return m_nodep; } virtual string name() const { return nodep()->name(); } virtual string dotColor() const { return pure() ? "black" : "red"; } + virtual FileLine* fileline() const { return nodep()->fileline(); } AstCFunc* cFuncp() const { return m_cFuncp; } void cFuncp(AstCFunc* nodep) { m_cFuncp=nodep; } }; diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index f24bd04c0..984c0fb6f 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -115,6 +115,7 @@ public: AstCFunc* nodep() const { return m_nodep; } virtual string name() const { return nodep()->name(); } virtual string dotColor() const { return "yellow"; } + virtual FileLine* fileline() const { return nodep()->fileline(); } }; class TraceTraceVertex : public V3GraphVertex { @@ -128,6 +129,7 @@ public: AstTraceInc* nodep() const { return m_nodep; } virtual string name() const { return nodep()->declp()->name(); } virtual string dotColor() const { return "red"; } + virtual FileLine* fileline() const { return nodep()->fileline(); } TraceTraceVertex* duplicatep() const { return m_duplicatep; } void duplicatep(TraceTraceVertex* dupp) { if (duplicatep()) nodep()->v3fatalSrc("Assigning duplicatep() to already duplicated node"); @@ -144,6 +146,7 @@ public: AstVarScope* nodep() const { return m_nodep; } virtual string name() const { return nodep()->name(); } virtual string dotColor() const { return "skyblue"; } + virtual FileLine* fileline() const { return nodep()->fileline(); } }; //###################################################################### diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index e9ea04fbc..5be625bf3 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -108,6 +108,7 @@ public: :feedsTri() ? "blue" : "lightblue") : (isTristate() ? "darkgreen" :feedsTri() ? "green" : "lightgreen")); } + virtual FileLine* fileline() const { return nodep()->fileline(); } void isTristate(bool flag) { m_isTristate = flag; } bool isTristate() const { return m_isTristate; } void feedsTri(bool flag) { m_feedsTri = flag; }