test: add a "pending release sequences" test
[c11tester.git] / cyclegraph.cc
index c7bb69b990d801dc026765420e918e35a31f1b0d..321ebe9e2f242babe1adad4e233dd7fe51427e71 100644 (file)
@@ -41,6 +41,7 @@ CycleNode * CycleGraph::getNode(const ModelAction *action) {
 void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to) {
        ASSERT(from);
        ASSERT(to);
+       ASSERT(from != to);
 
        CycleNode *fromnode=getNode(from);
        CycleNode *tonode=getNode(to);
@@ -82,6 +83,7 @@ void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to) {
 void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) {
        ASSERT(from);
        ASSERT(rmw);
+       ASSERT(from != rmw);
 
        CycleNode *fromnode=getNode(from);
        CycleNode *rmwnode=getNode(rmw);
@@ -120,22 +122,29 @@ void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) {
 }
 
 #if SUPPORT_MOD_ORDER_DUMP
-void CycleGraph::dumpGraphToFile(const char *filename) {
-       char buffer[200];
-  sprintf(buffer, "%s.dot",filename);
-  FILE *file=fopen(buffer, "w");
-  fprintf(file, "digraph %s {\n",filename);
+void CycleGraph::dumpNodes(FILE *file) {
   for(unsigned int i=0;i<nodeList.size();i++) {
                CycleNode *cn=nodeList[i];
                std::vector<CycleNode *> * edges=cn->getEdges();
                const ModelAction *action=cn->getAction();
                fprintf(file, "N%u [label=\"%u, T%u\"];\n",action->get_seq_number(),action->get_seq_number(), action->get_tid());
+               if (cn->getRMW()!=NULL) {
+                       fprintf(file, "N%u -> N%u[style=dotted];\n", action->get_seq_number(), cn->getRMW()->getAction()->get_seq_number());
+               }
                for(unsigned int j=0;j<edges->size();j++) {
                  CycleNode *dst=(*edges)[j];
                        const ModelAction *dstaction=dst->getAction();
       fprintf(file, "N%u -> N%u;\n", action->get_seq_number(), dstaction->get_seq_number());
          }
        }
+}
+
+void CycleGraph::dumpGraphToFile(const char *filename) {
+       char buffer[200];
+  sprintf(buffer, "%s.dot",filename);
+  FILE *file=fopen(buffer, "w");
+  fprintf(file, "digraph %s {\n",filename);
+       dumpNodes(file);
   fprintf(file,"}\n");
   fclose(file);        
 }
@@ -165,7 +174,7 @@ bool CycleGraph::checkReachable(const ModelAction *from, const ModelAction *to)
  */
 bool CycleGraph::checkReachable(CycleNode *from, CycleNode *to) {
        std::vector<CycleNode *, MyAlloc<CycleNode *> > queue;
-       HashTable<CycleNode *, CycleNode *, uintptr_t, 4, MYMALLOC, MYCALLOC, MYFREE> discovered;
+       HashTable<CycleNode *, CycleNode *, uintptr_t, 4, model_malloc, model_calloc, model_free> discovered;
 
        queue.push_back(from);
        discovered.put(from, from);