Пример #1
0
void printAsserts(Analyzer& analyzer, SgProject* sageProject) {
  if(boolOptions["rers-binary"]) {
	for(int i=0;i<62;i++) {
	  cout << "assert: error_"<<i<<": ";
	  if(analyzer.binaryBindingAssert[i]) {
		cout << color("green")<<"YES (REACHABLE)"<<color("normal");
	  } else {
		cout << color("cyan")<<"NO (UNREACHABLE)"<<color("normal");
	  }
	  cout << endl;
	}
	return;
  }
  LabelSet lset=analyzer.getTransitionGraph()->labelSetOfIoOperations(InputOutput::FAILED_ASSERT);
  list<pair<SgLabelStatement*,SgNode*> > assertNodes=analyzer.listOfLabeledAssertNodes(sageProject);
  for(list<pair<SgLabelStatement*,SgNode*> >::iterator i=assertNodes.begin();i!=assertNodes.end();++i) {
	cout << "assert: "
		 << SgNodeHelper::getLabelName((*i).first)
	  //	 << SgNodeHelper::nodeToString((*i).second)<< " : "
	  ;
	cout << ": ";
	Label lab=analyzer.getLabeler()->getLabel((*i).second);
	if(lset.find(lab)!=lset.end()) {
	  cout << color("green")<<"YES (REACHABLE)"<<color("normal");
	}
	else {
	  cout << color("cyan")<<"NO (UNREACHABLE)"<<color("normal");
	}
	cout << endl;
  }
}
Пример #2
0
void printAssertStatistics(Analyzer& analyzer, SgProject* sageProject) {
  LabelSet lset=analyzer.getTransitionGraph()->labelSetOfIoOperations(InputOutput::FAILED_ASSERT);
  list<pair<SgLabelStatement*,SgNode*> > assertNodes=analyzer.listOfLabeledAssertNodes(sageProject);
  int reachable=0;
  int unreachable=0;
  for(list<pair<SgLabelStatement*,SgNode*> >::iterator i=assertNodes.begin();i!=assertNodes.end();++i) {
	Label lab=analyzer.getLabeler()->getLabel((*i).second);
	if(lset.find(lab)!=lset.end())
	  reachable++;
	else
	  unreachable++;
  }
  int n=assertNodes.size();
  assert(reachable+unreachable == n);

  if(boolOptions["rers-binary"]) {
	reachable=0;
	unreachable=0;
	for(int i=0;i<62;i++) {
	  if(analyzer.binaryBindingAssert[i])
		reachable++;
	  else
		unreachable++;
	}
  }
  cout<<"Assert reachability statistics: "
	  <<color("normal")<<"YES: "<<color("green")<<reachable
	  <<color("normal")<<", NO: " <<color("cyan")<<unreachable
	  <<color("normal")<<", TOTAL: " <<n
	  <<endl
	;
}
Пример #3
0
void generateAssertsCsvFile(Analyzer& analyzer, SgProject* sageProject, string filename) {
  ofstream* csv = NULL;
  csv = new ofstream();
  // use binary and \r\n tp enforce DOS line endings
  // http://tools.ietf.org/html/rfc4180
  csv->open(filename.c_str(), ios::trunc|ios::binary);
  //*csv << "Index;\"Assert Error Label\";ReachabilityResult;Confidence\r\n";
  
  LabelSet lset=analyzer.getTransitionGraph()->labelSetOfIoOperations(InputOutput::FAILED_ASSERT);
  list<pair<SgLabelStatement*,SgNode*> > assertNodes=analyzer.listOfLabeledAssertNodes(sageProject);
  if(boolOptions["rers-binary"]) {
	for(int i=0;i<62;i++) {
	  *csv << i<<",";
	  if(analyzer.binaryBindingAssert[i]) {
		*csv << "yes,9";
	  } else {
		*csv << "no,9";
	  }
	  *csv << "\n";
	}
  } else {
	for(list<pair<SgLabelStatement*,SgNode*> >::iterator i=assertNodes.begin();i!=assertNodes.end();++i) {
	  string name=SgNodeHelper::getLabelName((*i).first);
	  if(name=="globalError")
		name="error_60";
	  name=name.substr(6,name.size()-6);
	  *csv << name
		   <<","
		;
	  Label lab=analyzer.getLabeler()->getLabel((*i).second);
	  if(lset.find(lab)!=lset.end()) {
		*csv << "yes,9";
	  } else {
		*csv << "no,9";
	  }
	  *csv << "\n";
	}
  }
  if (csv) delete csv;
}