MCPcopy Create free account
hub / github.com/SVF-tools/SVF / writeToFile

Method writeToFile

svf/lib/Graphs/SVFGReadWrite.cpp:46–204  ·  view source on GitHub ↗

Format of file __Nodes__ SVFGNodeID: >= >= MVER: {MRVERID: MemRegion: pts{ } MRVERSION: MSSADef: , pts{ }} >= ICFGNodeID: __Edges__ srcSVFGNodeID: => dstSVFGNodeID: >= | MVER: {MRVERID: MemRegion: pts{ } MRVERSION: MSSADef: , pts{ }}

Source from the content-addressed store, hash-verified

44// __Edges__
45// srcSVFGNodeID: <id> => dstSVFGNodeID: <id> >= <edge type> | MVER: {MRVERID: <id> MemRegion: pts{<pts> } MRVERSION: <version> MSSADef: <version>, pts{<pts> }}
46void SVFG::writeToFile(const string& filename)
47{
48 outs() << "Writing SVFG analysis to '" << filename << "'...";
49 error_code err;
50 std::fstream f(filename.c_str(), std::ios_base::out);
51 if (!f.good())
52 {
53 outs() << " error opening file for writing!\n";
54 return;
55 }
56 f << "__Nodes__\n";
57 // Iterate over nodes and write to file
58 for(iterator it = begin(), eit = end(); it!=eit; ++it)
59 {
60 NodeID nodeId = it->first;
61 const SVFGNode* node = it->second;
62 if(const FormalINSVFGNode* formalIn = SVFUtil::dyn_cast<FormalINSVFGNode>(node))
63 {
64 //node
65 f << "SVFGNodeID: " << nodeId << " >= " << "FormalINSVFGNode";
66 f << " >= MVER: {";
67 f << *formalIn->getMRVer() << "} >= ICFGNodeID: " << formalIn->getFunEntryNode()->getId() << "\n";
68 }
69 else if(const FormalOUTSVFGNode* formalOut = SVFUtil::dyn_cast<FormalOUTSVFGNode>(node))
70 {
71 //node
72 f << "SVFGNodeID: " << nodeId << " >= " << "FormalOUTSVFGNode";
73 f << " >= MVER: {";
74 f << *formalOut->getMRVer() << "} >= ICFGNodeID: " << formalOut->getFunExitNode()->getId() << "\n";
75 }
76 else if(const ActualINSVFGNode* actualIn = SVFUtil::dyn_cast<ActualINSVFGNode>(node))
77 {
78 //node
79 f << "SVFGNodeID: " << nodeId << " >= " << "ActualINSVFGNode";
80 f << " >= MVER: {";
81 f << *actualIn->getMRVer() << "} >= ICFGNodeID: " << actualIn->getCallSite()->getId() << "\n";
82 }
83 else if(const ActualOUTSVFGNode* actualOut = SVFUtil::dyn_cast<ActualOUTSVFGNode>(node))
84 {
85 //node
86 f << "SVFGNodeID: " << nodeId << " >= " << "ActualOUTSVFGNode" << " >= MVER: {";
87 f << *actualOut->getMRVer() << "} >= ICFGNodeID: " << actualOut->getCallSite()->getId() << "\n";
88 }
89 else if(const MSSAPHISVFGNode* phiNode = SVFUtil::dyn_cast<MSSAPHISVFGNode>(node))
90 {
91 //node
92 f << "SVFGNodeID: " << nodeId << " >= " << "PHISVFGNode";
93 unordered_map<u32_t,const MRVer*> opvers;
94 for (MemSSA::PHI::OPVers::const_iterator it = phiNode->opVerBegin(), eit = phiNode->opVerEnd();
95 it != eit; it++)
96 {
97 opvers.insert(make_pair(it->first, it->second));
98 }
99 // opvers
100 f << " >= MVER: {";
101 f << *phiNode->getResVer();
102 const ICFGNode* inst = phiNode->getICFGNode()->getBB()->front();
103 f << "} >= ICFGNodeID: " << inst->getId();

Callers 1

Calls 15

getFunEntryNodeMethod · 0.80
getFunExitNodeMethod · 0.80
insertMethod · 0.80
getSVFStmtMethod · 0.80
hasMUMethod · 0.80
hasCHIMethod · 0.80
getMRVerMethod · 0.45
getIdMethod · 0.45
getCallSiteMethod · 0.45
opVerBeginMethod · 0.45
opVerEndMethod · 0.45

Tested by

no test coverage detected