Continued... Show file and line info when possible on internal graph errors.

This commit is contained in:
Wilson Snyder 2018-07-14 20:44:43 -04:00
parent 22939d7473
commit 43694ec87c
6 changed files with 32 additions and 14 deletions

View File

@ -277,6 +277,10 @@ inline void v3errorEndFatal(std::ostringstream& sstr) { V3Error::v3errorEnd(sstr
#define v3fatal(msg) v3warnCodeFatal(V3ErrorCode::EC_FATAL, msg)
// Use this instead of fatal() to mention the source code line.
#define v3fatalSrc(msg) v3warnCodeFatal(V3ErrorCode::EC_FATALSRC, __FILE__<<":"<<std::dec<<__LINE__<<": "<<msg)
// Use this when normal v3fatal is called in static method that overrides fileline.
#define v3fatalStatic(msg) \
::v3errorEndFatal((V3Error::v3errorPrep(V3ErrorCode::EC_FATAL), \
(V3Error::v3errorStr()<<msg), V3Error::v3errorStr()));
#define UINFO(level,stmsg) {if(VL_UNLIKELY(debug()>=(level))) { cout<<"- "<<V3Error::lineStr(__FILE__,__LINE__)<<stmsg; }}
#define UINFONL(level,stmsg) {if(VL_UNLIKELY(debug()>=(level))) { cout<<stmsg; } }

View File

@ -256,6 +256,10 @@ void V3Graph::clearColors() {
//======================================================================
// Dumping
void V3Graph::loopsMessageCb(V3GraphVertex* vertexp) {
vertexp->v3fatalSrc("Loops detected in graph: "<<vertexp);
}
void V3Graph::loopsVertexCb(V3GraphVertex* vertexp) {
// Needed here as V3GraphVertex<< isn't defined until later in header
std::cerr<<"-Info-Loop: "<<(void*)(vertexp)<<" "<<vertexp<<endl;

View File

@ -27,6 +27,7 @@
#include <vector>
#include <algorithm>
class FileLine;
class V3Graph;
class V3GraphVertex;
class V3GraphEdge;
@ -171,7 +172,7 @@ public:
static void selfTest();
// CALLBACKS
virtual void loopsMessageCb(V3GraphVertex* vertexp) { v3fatalSrc("Loops detected in graph: "<<vertexp); }
virtual void loopsMessageCb(V3GraphVertex* vertexp);
virtual void loopsVertexCb(V3GraphVertex* vertexp);
};
@ -248,10 +249,11 @@ public:
V3GraphEdge* beginp(GraphWay way) const {
return way.forward() ? outBeginp() : inBeginp(); }
// METHODS
/// Edges are routed around this vertex to point from "from" directly to "to"
void rerouteEdges(V3Graph* graphp);
/// Error reporting
void v3errorEnd(std::ostringstream& str) const;
void v3errorEndFatal(std::ostringstream& str) const;
/// Edges are routed around this vertex to point from "from" directly to "to"
void rerouteEdges(V3Graph* graphp);
};
std::ostream& operator<<(std::ostream& os, V3GraphVertex* vertexp);

View File

@ -40,11 +40,11 @@ DfaVertex* DfaGraph::findStart() {
for (V3GraphVertex* vertexp = this->verticesBeginp(); vertexp; vertexp=vertexp->verticesNextp()) {
if (DfaVertex* vvertexp = dynamic_cast<DfaVertex*>(vertexp)) {
if (vvertexp->start()) {
if (startp) v3fatalSrc("Multiple start points in NFA graph");
if (startp) vertexp->v3fatalSrc("Multiple start points in NFA graph");
startp = vvertexp;
}
} else {
v3fatalSrc("Non DfaVertex in DfaGraph");
vertexp->v3fatalSrc("Non DfaVertex in DfaGraph");
}
}
if (!startp) v3fatalSrc("No start point in NFA graph");
@ -116,7 +116,9 @@ private:
DfaVertex* nfaStatep = static_cast<DfaVertex*>(dfaEdgep->top());
hash ^= hashVertex(nfaStatep);
if (debug()) {
if (nfaStatep->user()==m_step) v3fatalSrc("DFA state points to duplicate NFA state.");
if (nfaStatep->user()==m_step) {
nfaStatep->v3fatalSrc("DFA state points to duplicate NFA state.");
}
nfaStatep->user(m_step);
}
}
@ -444,7 +446,7 @@ private:
vertexp->user(1);
} else {
// If ever remove this, need dyn cast below
v3fatalSrc("Non DfaVertex in dfa graph");
vertexp->v3fatalSrc("Non DfaVertex in dfa graph");
}
}

View File

@ -1239,7 +1239,9 @@ inline void OrderMoveDomScope::ready(OrderVisitor* ovp) {
// Mark one vertex as finished, remove from ready list if done
inline void OrderMoveDomScope::movedVertex(OrderVisitor* ovp, OrderMoveVertex* vertexp) {
UASSERT(m_onReadyList, "Moving vertex from ready when nothing was on que as ready.");
if (!m_onReadyList) {
vertexp->v3fatalSrc("Moving vertex from ready when nothing was on que as ready.");
}
if (m_readyVertices.empty()) { // Else more work to get to later
m_onReadyList = false;
m_readyDomScopeE.unlink(ovp->m_pomReadyDomScope, this);
@ -1306,7 +1308,9 @@ void OrderVisitor::processInputsOutIterate(OrderEitherVertex* vertexp, VertexVec
// First make sure input path is fully recursed
processInputsInIterate(vertexp, todoVec);
// Propagate PrimaryIn through simple assignments
if (!vertexp->isFromInput()) v3fatalSrc("processInputsOutIterate only for input marked vertexes");
if (!vertexp->isFromInput()) {
vertexp->v3fatalSrc("processInputsOutIterate only for input marked vertexes");
}
vertexp->user(3); // out-edges processed
{
@ -1653,7 +1657,9 @@ void OrderVisitor::processMoveDoneOne(OrderMoveVertex* vertexp) {
}
void OrderVisitor::processMoveOne(OrderMoveVertex* vertexp, OrderMoveDomScope* domScopep, int level) {
UASSERT(vertexp->domScopep() == domScopep, "Domain mismatch; list misbuilt?");
if (vertexp->domScopep() != domScopep) {
vertexp->v3fatalSrc("Domain mismatch; list misbuilt?");
}
const OrderLogicVertex* lvertexp = vertexp->logicp();
const AstScope* scopep = lvertexp->scopep();
UINFO(5," POSmove l"<<std::setw(3)<<level<<" d="<<(void*)(lvertexp->domainp())

View File

@ -168,11 +168,11 @@ public:
// nodes.
PendingEdgeSet pendingEdges(cmp);
vluint32_t vert_ct = 0;
vluint32_t vertCount = 0;
for (V3GraphVertex* vxp = verticesBeginp();
vxp; vxp = vxp->verticesNextp()) {
mstp->addVertex(castVertexp(vxp)->key());
vert_ct++;
vertCount++;
}
// Choose an arbitrary start vertex and visit it;
@ -225,8 +225,8 @@ public:
}
}
UASSERT(edges_made + 1 == vert_ct, "Algorithm failed");
UASSERT(visited_set.size() == vert_ct, "Algorithm failed");
UASSERT(edges_made + 1 == vertCount, "Algorithm failed");
UASSERT(visited_set.size() == vertCount, "Algorithm failed");
}
// Populate *outp with a minimal perfect matching of *this.