svf-tools 1.0.463 → 1.0.466

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/SVF-doxygen/html/html/Andersen_8cpp_source.html +6 -6
  2. package/SVF-doxygen/html/html/BDDExpr_8cpp_source.html +1 -1
  3. package/SVF-doxygen/html/html/CHGBuilder_8cpp_source.html +1 -1
  4. package/SVF-doxygen/html/html/ConsG_8cpp_source.html +1 -1
  5. package/SVF-doxygen/html/html/ContextDDA_8h_source.html +1 -1
  6. package/SVF-doxygen/html/html/DCHG_8cpp_source.html +1 -1
  7. package/SVF-doxygen/html/html/FSMPTA_8cpp_source.html +3 -3
  8. package/SVF-doxygen/html/html/FlowDDA_8h_source.html +1 -1
  9. package/SVF-doxygen/html/html/FlowSensitiveTBHC_8cpp_source.html +2 -2
  10. package/SVF-doxygen/html/html/FlowSensitive_8cpp_source.html +1 -1
  11. package/SVF-doxygen/html/html/Graph2Json_8cpp_source.html +2 -2
  12. package/SVF-doxygen/html/html/LeakChecker_8cpp_source.html +1 -1
  13. package/SVF-doxygen/html/html/LockAnalysis_8cpp_source.html +1 -1
  14. package/SVF-doxygen/html/html/LockResultValidator_8cpp_source.html +1 -1
  15. package/SVF-doxygen/html/html/MHP_8cpp_source.html +1 -1
  16. package/SVF-doxygen/html/html/MSSAMuChi_8h.html +7 -1
  17. package/SVF-doxygen/html/html/MSSAMuChi_8h_source.html +2 -1
  18. package/SVF-doxygen/html/html/MTAAnnotator_8cpp_source.html +1 -1
  19. package/SVF-doxygen/html/html/MTAResultValidator_8cpp_source.html +1 -1
  20. package/SVF-doxygen/html/html/MTAStat_8cpp_source.html +1 -1
  21. package/SVF-doxygen/html/html/MemRegion_8cpp_source.html +10 -1
  22. package/SVF-doxygen/html/html/Options_8cpp_source.html +40 -39
  23. package/SVF-doxygen/html/html/Options_8h_source.html +41 -40
  24. package/SVF-doxygen/html/html/PathCondAllocator_8cpp_source.html +1 -1
  25. package/SVF-doxygen/html/html/SVFBasicTypes_8h_source.html +2 -2
  26. package/SVF-doxygen/html/html/SVFGOPT_8h_source.html +2 -2
  27. package/SVF-doxygen/html/html/SVFGReadWrite_8cpp.html +86 -0
  28. package/SVF-doxygen/html/html/SVFGReadWrite_8cpp_source.html +125 -0
  29. package/SVF-doxygen/html/html/SVFG_8cpp_source.html +48 -43
  30. package/SVF-doxygen/html/html/SVFG_8h_source.html +41 -38
  31. package/SVF-doxygen/html/html/SVFUtil_8cpp_source.html +1 -1
  32. package/SVF-doxygen/html/html/SrcSnkDDA_8cpp_source.html +2 -2
  33. package/SVF-doxygen/html/html/SymbolTableBuilder_8cpp_source.html +2 -2
  34. package/SVF-doxygen/html/html/SymbolTableInfo_8cpp_source.html +2 -2
  35. package/SVF-doxygen/html/html/TCT_8cpp_source.html +1 -1
  36. package/SVF-doxygen/html/html/TypeAnalysis_8cpp_source.html +2 -2
  37. package/SVF-doxygen/html/html/VersionedFlowSensitive_8cpp_source.html +2 -2
  38. package/SVF-doxygen/html/html/classSVF_1_1Andersen.html +2 -2
  39. package/SVF-doxygen/html/html/classSVF_1_1AndersenBase.html +5 -5
  40. package/SVF-doxygen/html/html/classSVF_1_1BDDExprManager.html +2 -2
  41. package/SVF-doxygen/html/html/classSVF_1_1CHGBuilder.html +1 -1
  42. package/SVF-doxygen/html/html/classSVF_1_1ContextDDA.html +1 -1
  43. package/SVF-doxygen/html/html/classSVF_1_1DCHGraph.html +1 -1
  44. package/SVF-doxygen/html/html/classSVF_1_1FlowDDA.html +1 -1
  45. package/SVF-doxygen/html/html/classSVF_1_1FlowSensitive.html +4 -4
  46. package/SVF-doxygen/html/html/classSVF_1_1FlowSensitiveTBHC.html +7 -7
  47. package/SVF-doxygen/html/html/classSVF_1_1ICFGPrinter.html +2 -2
  48. package/SVF-doxygen/html/html/classSVF_1_1LLVMModuleSet.html +2 -2
  49. package/SVF-doxygen/html/html/classSVF_1_1LeakChecker.html +1 -1
  50. package/SVF-doxygen/html/html/classSVF_1_1LockAnalysis.html +1 -1
  51. package/SVF-doxygen/html/html/classSVF_1_1LockResultValidator.html +1 -1
  52. package/SVF-doxygen/html/html/classSVF_1_1MHP.html +1 -1
  53. package/SVF-doxygen/html/html/classSVF_1_1MTAAnnotator.html +4 -4
  54. package/SVF-doxygen/html/html/classSVF_1_1MTAResultValidator.html +3 -3
  55. package/SVF-doxygen/html/html/classSVF_1_1MTASVFGBuilder.html +7 -7
  56. package/SVF-doxygen/html/html/classSVF_1_1MTAStat.html +1 -1
  57. package/SVF-doxygen/html/html/classSVF_1_1Options-members.html +55 -54
  58. package/SVF-doxygen/html/html/classSVF_1_1Options.html +90 -64
  59. package/SVF-doxygen/html/html/classSVF_1_1PathCondAllocator.html +1 -1
  60. package/SVF-doxygen/html/html/classSVF_1_1SVFG-members.html +91 -88
  61. package/SVF-doxygen/html/html/classSVF_1_1SVFG.html +299 -113
  62. package/SVF-doxygen/html/html/classSVF_1_1SVFGBuilder.html +2 -2
  63. package/SVF-doxygen/html/html/classSVF_1_1SVFGOPT-members.html +100 -97
  64. package/SVF-doxygen/html/html/classSVF_1_1SVFGOPT.html +18 -12
  65. package/SVF-doxygen/html/html/classSVF_1_1SVFIRBuilder.html +1 -1
  66. package/SVF-doxygen/html/html/classSVF_1_1SaberSVFGBuilder.html +1 -1
  67. package/SVF-doxygen/html/html/classSVF_1_1SrcSnkDDA.html +3 -3
  68. package/SVF-doxygen/html/html/classSVF_1_1SymbolTableBuilder.html +2 -2
  69. package/SVF-doxygen/html/html/classSVF_1_1SymbolTableInfo.html +4 -4
  70. package/SVF-doxygen/html/html/classSVF_1_1TCT.html +2 -2
  71. package/SVF-doxygen/html/html/classSVF_1_1TypeAnalysis.html +2 -2
  72. package/SVF-doxygen/html/html/classSVF_1_1VersionedFlowSensitive.html +2 -2
  73. package/SVF-doxygen/html/html/dir_1870ebf480d659cc38d2dd7ac3aa8993.html +2 -0
  74. package/SVF-doxygen/html/html/files.html +4 -3
  75. package/SVF-doxygen/html/html/functions_c.html +5 -9
  76. package/SVF-doxygen/html/html/functions_func_g.html +7 -4
  77. package/SVF-doxygen/html/html/functions_func_r.html +7 -4
  78. package/SVF-doxygen/html/html/functions_func_w.html +1 -0
  79. package/SVF-doxygen/html/html/functions_g.html +10 -10
  80. package/SVF-doxygen/html/html/functions_l.html +3 -3
  81. package/SVF-doxygen/html/html/functions_n.html +3 -3
  82. package/SVF-doxygen/html/html/functions_o.html +17 -17
  83. package/SVF-doxygen/html/html/functions_p.html +10 -10
  84. package/SVF-doxygen/html/html/functions_r.html +9 -3
  85. package/SVF-doxygen/html/html/functions_s.html +14 -14
  86. package/SVF-doxygen/html/html/functions_t.html +4 -4
  87. package/SVF-doxygen/html/html/functions_v.html +3 -3
  88. package/SVF-doxygen/html/html/functions_vars_g.html +0 -3
  89. package/SVF-doxygen/html/html/functions_vars_r.html +3 -0
  90. package/SVF-doxygen/html/html/functions_vars_w.html +3 -0
  91. package/SVF-doxygen/html/html/functions_w.html +4 -0
  92. package/SVF-doxygen/html/html/globals_s.html +1 -3
  93. package/SVF-doxygen/html/html/namespaceSVF.html +40 -1
  94. package/SVF-doxygen/html/html/namespacemembers_o.html +1 -1
  95. package/SVF-doxygen/html/html/search/all_10.js +6 -6
  96. package/SVF-doxygen/html/html/search/all_12.js +5 -3
  97. package/SVF-doxygen/html/html/search/all_13.js +13 -12
  98. package/SVF-doxygen/html/html/search/all_14.js +5 -5
  99. package/SVF-doxygen/html/html/search/all_15.js +1 -1
  100. package/SVF-doxygen/html/html/search/all_16.js +2 -2
  101. package/SVF-doxygen/html/html/search/all_17.js +2 -1
  102. package/SVF-doxygen/html/html/search/all_3.js +1 -1
  103. package/SVF-doxygen/html/html/search/all_7.js +1 -1
  104. package/SVF-doxygen/html/html/search/all_c.js +1 -1
  105. package/SVF-doxygen/html/html/search/all_d.js +2 -2
  106. package/SVF-doxygen/html/html/search/all_e.js +5 -5
  107. package/SVF-doxygen/html/html/search/all_f.js +4 -4
  108. package/SVF-doxygen/html/html/search/files_d.js +1 -0
  109. package/SVF-doxygen/html/html/search/functions_14.js +1 -1
  110. package/SVF-doxygen/html/html/search/functions_6.js +1 -0
  111. package/SVF-doxygen/html/html/search/functions_d.js +1 -1
  112. package/SVF-doxygen/html/html/search/functions_f.js +1 -0
  113. package/SVF-doxygen/html/html/search/variables_12.js +1 -0
  114. package/SVF-doxygen/html/html/search/variables_14.js +3 -3
  115. package/SVF-doxygen/html/html/search/variables_15.js +1 -1
  116. package/SVF-doxygen/html/html/search/variables_17.js +2 -1
  117. package/SVF-doxygen/html/html/search/variables_7.js +0 -1
  118. package/SVF-doxygen/html/html/search/variables_e.js +3 -3
  119. package/SVF-doxygen/html/html/structllvm_1_1DOTGraphTraits_3_01SVFG_01_5_01_4.html +20 -20
  120. package/SVF-doxygen/html/html/structllvm_1_1GraphTraits_3_01SVF_1_1SVFG_01_5_01_4.html +2 -2
  121. package/include/Graphs/SVFG.h +4 -0
  122. package/include/MSSA/MSSAMuChi.h +1 -0
  123. package/include/Util/Options.h +3 -3
  124. package/lib/Graphs/SVFG.cpp +31 -27
  125. package/lib/Graphs/SVFGReadWrite.cpp +478 -0
  126. package/lib/MSSA/MemRegion.cpp +7 -0
  127. package/lib/Util/Options.cpp +11 -8
  128. package/lib/WPA/TypeAnalysis.cpp +1 -1
  129. package/package.json +1 -1
@@ -36,7 +36,7 @@
36
36
  #include "Util/Options.h"
37
37
  #include "MemoryModel/PointerAnalysisImpl.h"
38
38
  #include <fstream>
39
-
39
+ #include "Util/Options.h"
40
40
 
41
41
  using namespace SVF;
42
42
  using namespace SVFUtil;
@@ -226,19 +226,23 @@ void SVFG::buildSVFG()
226
226
  DBOUT(DGENERAL, outs() << pasMsg("Build Sparse Value-Flow Graph \n"));
227
227
 
228
228
  stat->startClk();
229
-
230
- DBOUT(DGENERAL, outs() << pasMsg("\tCreate SVFG Addr-taken Node\n"));
231
-
232
- stat->ATVFNodeStart();
233
- addSVFGNodesForAddrTakenVars();
234
- stat->ATVFNodeEnd();
235
-
236
- DBOUT(DGENERAL, outs() << pasMsg("\tCreate SVFG Indirect Edge\n"));
237
-
238
- stat->indVFEdgeStart();
239
- connectIndirectSVFGEdges();
240
- stat->indVFEdgeEnd();
241
-
229
+ if (!Options::ReadSVFG.empty())
230
+ {
231
+ readFile(Options::ReadSVFG);
232
+ }
233
+ else
234
+ {
235
+ DBOUT(DGENERAL, outs() << pasMsg("\tCreate SVFG Addr-taken Node\n"));
236
+ stat->ATVFNodeStart();
237
+ addSVFGNodesForAddrTakenVars();
238
+ stat->ATVFNodeEnd();
239
+ DBOUT(DGENERAL, outs() << pasMsg("\tCreate SVFG Indirect Edge\n"));
240
+ stat->indVFEdgeStart();
241
+ connectIndirectSVFGEdges();
242
+ stat->indVFEdgeEnd();
243
+ if (!Options::WriteSVFG.empty())
244
+ writeToFile(Options::WriteSVFG);
245
+ }
242
246
  }
243
247
 
244
248
  /*
@@ -574,15 +578,15 @@ void SVFG::dump(const std::string& file, bool simple)
574
578
  /**
575
579
  * Get all inter value flow edges at this indirect call site, including call and return edges.
576
580
  */
577
- void SVFG::getInterVFEdgesForIndirectCallSite(const CallICFGNode* callBlockNode, const SVFFunction* callee, SVFGEdgeSetTy& edges)
581
+ void SVFG::getInterVFEdgesForIndirectCallSite(const CallICFGNode* callICFGNode, const SVFFunction* callee, SVFGEdgeSetTy& edges)
578
582
  {
579
- CallSiteID csId = getCallSiteID(callBlockNode, callee);
580
- RetICFGNode* retBlockNode = pag->getICFG()->getRetICFGNode(callBlockNode->getCallSite());
583
+ CallSiteID csId = getCallSiteID(callICFGNode, callee);
584
+ RetICFGNode* retICFGNode = pag->getICFG()->getRetICFGNode(callICFGNode->getCallSite());
581
585
 
582
586
  // Find inter direct call edges between actual param and formal param.
583
- if (pag->hasCallSiteArgsMap(callBlockNode) && pag->hasFunArgsList(callee))
587
+ if (pag->hasCallSiteArgsMap(callICFGNode) && pag->hasFunArgsList(callee))
584
588
  {
585
- const SVFIR::SVFVarList& csArgList = pag->getCallSiteArgsList(callBlockNode);
589
+ const SVFIR::SVFVarList& csArgList = pag->getCallSiteArgsList(callICFGNode);
586
590
  const SVFIR::SVFVarList& funArgList = pag->getFunArgsList(callee);
587
591
  SVFIR::SVFVarList::const_iterator csArgIt = csArgList.begin(), csArgEit = csArgList.end();
588
592
  SVFIR::SVFVarList::const_iterator funArgIt = funArgList.begin(), funArgEit = funArgList.end();
@@ -591,7 +595,7 @@ void SVFG::getInterVFEdgesForIndirectCallSite(const CallICFGNode* callBlockNode,
591
595
  const PAGNode *cs_arg = *csArgIt;
592
596
  const PAGNode *fun_arg = *funArgIt;
593
597
  if (fun_arg->isPointer() && cs_arg->isPointer())
594
- getInterVFEdgeAtIndCSFromAPToFP(cs_arg, fun_arg, callBlockNode, csId, edges);
598
+ getInterVFEdgeAtIndCSFromAPToFP(cs_arg, fun_arg, callICFGNode, csId, edges);
595
599
  }
596
600
  assert(funArgIt == funArgEit && "function has more arguments than call site");
597
601
  if (callee->getLLVMFun()->isVarArg())
@@ -604,25 +608,25 @@ void SVFG::getInterVFEdgesForIndirectCallSite(const CallICFGNode* callBlockNode,
604
608
  {
605
609
  const PAGNode *cs_arg = *csArgIt;
606
610
  if (cs_arg->isPointer())
607
- getInterVFEdgeAtIndCSFromAPToFP(cs_arg, varFunArgNode, callBlockNode, csId, edges);
611
+ getInterVFEdgeAtIndCSFromAPToFP(cs_arg, varFunArgNode, callICFGNode, csId, edges);
608
612
  }
609
613
  }
610
614
  }
611
615
  }
612
616
 
613
617
  // Find inter direct return edges between actual return and formal return.
614
- if (pag->funHasRet(callee) && pag->callsiteHasRet(retBlockNode))
618
+ if (pag->funHasRet(callee) && pag->callsiteHasRet(retICFGNode))
615
619
  {
616
- const PAGNode* cs_return = pag->getCallSiteRet(retBlockNode);
620
+ const PAGNode* cs_return = pag->getCallSiteRet(retICFGNode);
617
621
  const PAGNode* fun_return = pag->getFunRet(callee);
618
622
  if (cs_return->isPointer() && fun_return->isPointer())
619
623
  getInterVFEdgeAtIndCSFromFRToAR(fun_return, cs_return, csId, edges);
620
624
  }
621
625
 
622
626
  // Find inter indirect call edges between actual-in and formal-in svfg nodes.
623
- if (hasFuncEntryChi(callee) && hasCallSiteMu(callBlockNode))
627
+ if (hasFuncEntryChi(callee) && hasCallSiteMu(callICFGNode))
624
628
  {
625
- SVFG::ActualINSVFGNodeSet& actualInNodes = getActualINSVFGNodes(callBlockNode);
629
+ SVFG::ActualINSVFGNodeSet& actualInNodes = getActualINSVFGNodes(callICFGNode);
626
630
  for(SVFG::ActualINSVFGNodeSet::iterator ai_it = actualInNodes.begin(),
627
631
  ai_eit = actualInNodes.end(); ai_it!=ai_eit; ++ai_it)
628
632
  {
@@ -632,9 +636,9 @@ void SVFG::getInterVFEdgesForIndirectCallSite(const CallICFGNode* callBlockNode,
632
636
  }
633
637
 
634
638
  // Find inter indirect return edges between actual-out and formal-out svfg nodes.
635
- if (hasFuncRetMu(callee) && hasCallSiteChi(callBlockNode))
639
+ if (hasFuncRetMu(callee) && hasCallSiteChi(callICFGNode))
636
640
  {
637
- SVFG::ActualOUTSVFGNodeSet& actualOutNodes = getActualOUTSVFGNodes(callBlockNode);
641
+ SVFG::ActualOUTSVFGNodeSet& actualOutNodes = getActualOUTSVFGNodes(callICFGNode);
638
642
  for(SVFG::ActualOUTSVFGNodeSet::iterator ao_it = actualOutNodes.begin(),
639
643
  ao_eit = actualOutNodes.end(); ao_it!=ao_eit; ++ao_it)
640
644
  {
@@ -0,0 +1,478 @@
1
+ //===- SVFGReadWrite.cpp -- SVFG read & write-----------------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2017> <Yulei Sui>
6
+ //
7
+
8
+ // This program is free software: you can redistribute it and/or modify
9
+ // it under the terms of the GNU General Public License as published by
10
+ // the Free Software Foundation, either version 3 of the License, or
11
+ // (at your option) any later version.
12
+
13
+ // This program is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ /*
24
+ * SVFGReadWrite.cpp
25
+ *
26
+ * Created on: May 21, 2022
27
+ * Author: Jeffrey Ma
28
+ */
29
+
30
+ #include "Util/SVFModule.h"
31
+ #include "SVF-FE/LLVMUtil.h"
32
+ #include "Graphs/SVFG.h"
33
+ #include "Graphs/SVFGStat.h"
34
+ #include "MemoryModel/PointerAnalysisImpl.h"
35
+ #include <fstream>
36
+ #include "Util/Options.h"
37
+
38
+ using namespace SVF;
39
+ using namespace SVFUtil;
40
+
41
+ // Format of file
42
+ // __Nodes__
43
+ // SVFGNodeID: <id> >= <node type> >= MVER: {MRVERID: <id> MemRegion: pts{<pts> } MRVERSION: <version> MSSADef: <version>, pts{<pts> }} >= ICFGNodeID: <id>
44
+ // __Edges__
45
+ // srcSVFGNodeID: <id> => dstSVFGNodeID: <id> >= <edge type> | MVER: {MRVERID: <id> MemRegion: pts{<pts> } MRVERSION: <version> MSSADef: <version>, pts{<pts> }}
46
+ void 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
+ f << "} >= ICFGNodeID: " << pag->getICFG()->getICFGNode(&(phiNode->getICFGNode()->getBB()->front()))->getId();
103
+ f << " >= OPVers: {";
104
+ for (auto x: opvers)
105
+ {
106
+ const MRVer* op = x.second;
107
+ f << "{" << *op << "}" << ",";
108
+ }
109
+ f << "}\n";
110
+ }
111
+ }
112
+
113
+ f << "\n\n__Edges__\n";
114
+ // Iterate over edges and write to file
115
+ for(iterator it = begin(), eit = end(); it!=eit; ++it)
116
+ {
117
+ NodeID nodeId = it->first;
118
+ const SVFGNode* node = it->second;
119
+ if(const LoadSVFGNode* loadNode = SVFUtil::dyn_cast<LoadSVFGNode>(node))
120
+ {
121
+ MUSet& muSet = mssa->getMUSet(SVFUtil::cast<LoadStmt>(loadNode->getPAGEdge()));
122
+ for(MUSet::iterator it = muSet.begin(), eit = muSet.end(); it!=eit; ++it)
123
+ {
124
+ if(LOADMU* mu = SVFUtil::dyn_cast<LOADMU>(*it))
125
+ {
126
+ NodeID def = getDef(mu->getMRVer());
127
+ f << "srcSVFGNodeID: " << nodeId << " => " << "dstSVFGNodeID: " << def << " >= LoadNode | MVER: {"<< *mu->getMRVer() << "}" << "\n";
128
+ }
129
+ }
130
+ }
131
+ else if(const StoreSVFGNode* storeNode = SVFUtil::dyn_cast<StoreSVFGNode>(node))
132
+ {
133
+ CHISet& chiSet = mssa->getCHISet(SVFUtil::cast<StoreStmt>(storeNode->getPAGEdge()));
134
+ for(CHISet::iterator it = chiSet.begin(), eit = chiSet.end(); it!=eit; ++it)
135
+ {
136
+ if(STORECHI* chi = SVFUtil::dyn_cast<STORECHI>(*it))
137
+ {
138
+ NodeID def = getDef(chi->getOpVer());
139
+ f << "srcSVFGNodeID: " << nodeId << " => " << "dstSVFGNodeID: " << def << " >= StoreNode | MVER: {"<< *chi->getOpVer() << "}" << "\n";
140
+ }
141
+ }
142
+ }
143
+ else if(const FormalINSVFGNode* formalIn = SVFUtil::dyn_cast<FormalINSVFGNode>(node))
144
+ {
145
+ PTACallGraphEdge::CallInstSet callInstSet;
146
+ mssa->getPTA()->getPTACallGraph()->getDirCallSitesInvokingCallee(formalIn->getFun(),callInstSet);
147
+ for(PTACallGraphEdge::CallInstSet::iterator it = callInstSet.begin(), eit = callInstSet.end(); it!=eit; ++it)
148
+ {
149
+ const CallICFGNode* cs = *it;
150
+ if(!mssa->hasMU(cs))
151
+ continue;
152
+ ActualINSVFGNodeSet& actualIns = getActualINSVFGNodes(cs);
153
+ for(ActualINSVFGNodeSet::iterator ait = actualIns.begin(), aeit = actualIns.end(); ait!=aeit; ++ait)
154
+ {
155
+ const ActualINSVFGNode* actualIn = SVFUtil::cast<ActualINSVFGNode>(getSVFGNode(*ait));
156
+ f << "srcSVFGNodeID: " << nodeId << " => " << "dstSVFGNodeID: " << actualIn->getId() << " >= FormalINSVFGNode" << "\n";
157
+ }
158
+ }
159
+ }
160
+ else if(const FormalOUTSVFGNode* formalOut = SVFUtil::dyn_cast<FormalOUTSVFGNode>(node))
161
+ {
162
+ PTACallGraphEdge::CallInstSet callInstSet;
163
+ mssa->getPTA()->getPTACallGraph()->getDirCallSitesInvokingCallee(formalOut->getFun(),callInstSet);
164
+ for(PTACallGraphEdge::CallInstSet::iterator it = callInstSet.begin(), eit = callInstSet.end(); it!=eit; ++it)
165
+ {
166
+ const CallICFGNode* cs = *it;
167
+ if(!mssa->hasCHI(cs))
168
+ continue;
169
+ ActualOUTSVFGNodeSet& actualOuts = getActualOUTSVFGNodes(cs);
170
+ for(ActualOUTSVFGNodeSet::iterator ait = actualOuts.begin(), aeit = actualOuts.end(); ait!=aeit; ++ait)
171
+ {
172
+ const ActualOUTSVFGNode* actualOut = SVFUtil::cast<ActualOUTSVFGNode>(getSVFGNode(*ait));
173
+ f << "srcSVFGNodeID: " << nodeId << " => " << "dstSVFGNodeID: " << actualOut->getId() << " >= FormalOUTSVFGNode" << "\n";
174
+ }
175
+ }
176
+ NodeID def = getDef(formalOut->getMRVer());
177
+ f << "srcSVFGNodeID: " << nodeId << " => " << "dstSVFGNodeID: " << def << " >= FormalOUTSVFGNode | intra" << "\n";
178
+ }
179
+ else if(const ActualINSVFGNode* actualIn = SVFUtil::dyn_cast<ActualINSVFGNode>(node))
180
+ {
181
+ NodeID def = getDef(actualIn->getMRVer());
182
+ f << "srcSVFGNodeID: " << nodeId << " => " << "dstSVFGNodeID: " << def << " >= ActualINSVFGNode" << "\n";
183
+
184
+ }
185
+ else if(const MSSAPHISVFGNode* phiNode = SVFUtil::dyn_cast<MSSAPHISVFGNode>(node))
186
+ {
187
+ for (MemSSA::PHI::OPVers::const_iterator it = phiNode->opVerBegin(), eit = phiNode->opVerEnd();
188
+ it != eit; it++)
189
+ {
190
+ const MRVer* op = it->second;
191
+ NodeID def = getDef(op);
192
+ f << "srcSVFGNodeID: " << nodeId << " => " << "dstSVFGNodeID: " << def << " >= PHISVFGNode | MVER: {"<< *op << "}" << "\n";
193
+ }
194
+ }
195
+ }
196
+ // Job finish and close file
197
+ f.close();
198
+ if (f.good())
199
+ {
200
+ outs() << "\n";
201
+ return;
202
+ }
203
+ }
204
+
205
+ void SVFG::readFile(const string& filename)
206
+ {
207
+ outs() << "Loading SVFG analysis results from '" << filename << "'...";
208
+ ifstream F(filename.c_str());
209
+ if (!F.is_open())
210
+ {
211
+ outs() << " error opening file for reading!\n";
212
+ return;
213
+ }
214
+
215
+ PAGEdge::PAGEdgeSetTy& stores = getPAGEdgeSet(PAGEdge::Store);
216
+ for (PAGEdge::PAGEdgeSetTy::iterator iter = stores.begin(), eiter =
217
+ stores.end(); iter != eiter; ++iter)
218
+ {
219
+ StoreStmt* store = SVFUtil::cast<StoreStmt>(*iter);
220
+ const StmtSVFGNode* sNode = getStmtVFGNode(store);
221
+ for(CHISet::iterator pi = mssa->getCHISet(store).begin(), epi = mssa->getCHISet(store).end(); pi!=epi; ++pi)
222
+ setDef((*pi)->getResVer(),sNode);
223
+ }
224
+ //outer loop through each line in the file
225
+ string line;
226
+ // add nodes
227
+ stat->ATVFNodeStart();
228
+ while (F.good())
229
+ {
230
+ getline(F, line);
231
+ if (line.empty())
232
+ continue;
233
+ if (line.find("__Edges__") != std::string::npos)
234
+ break;
235
+
236
+ std::string s = line;
237
+ std::string delimiter = " >= ";
238
+ string temp;
239
+ int index = 0;
240
+ //implement delimiter to split string using ">="
241
+ size_t next = 0;
242
+ size_t last = 0;
243
+ size_t outer_last = 0;
244
+ size_t nextTemp; //size_t lastTemp;
245
+ NodeID id = 0;
246
+ string type;
247
+ string MR;
248
+ string basicBlock;
249
+ string opVer;
250
+ //inner loop through to get each element in the line
251
+ while ((next = s.find(delimiter, last)) != string::npos)
252
+ {
253
+ temp = s.substr(last, next-last);
254
+ last = next + 4;
255
+ outer_last = next + 4;
256
+ if(index == 0)
257
+ {
258
+ nextTemp = temp.find("SVFGNodeID: ") + 12;
259
+ id = atoi(temp.substr(nextTemp).c_str());
260
+ }
261
+ if(index == 1)
262
+ {
263
+ type = temp;
264
+ }
265
+ if(index > 1)
266
+ {
267
+ if(index == 2)
268
+ {
269
+ MR = temp;
270
+ }
271
+ if(index == 3)
272
+ {
273
+ basicBlock = temp;
274
+ }
275
+ }
276
+ index++;
277
+ }
278
+ MRVer* tempMRVer;
279
+ if(!MR.empty())
280
+ {
281
+ tempMRVer = getMRVERFromString(MR);
282
+ }
283
+ else
284
+ {
285
+ tempMRVer = getMRVERFromString("");
286
+ }
287
+ //add nodes using the variables we extracted
288
+ if(type == "FormalINSVFGNode")
289
+ {
290
+ outer_last = s.find("ICFGNodeID: ") + 12;
291
+ NodeID FunID = atoi(s.substr(outer_last).c_str());
292
+ addFormalINSVFGNode(SVFUtil::dyn_cast<FunEntryICFGNode>(pag->getICFG()->getICFGNode(FunID)), tempMRVer, id);
293
+ }
294
+ else if(type == "FormalOUTSVFGNode")
295
+ {
296
+ outer_last = s.find("ICFGNodeID: ") + 12;
297
+ NodeID FunID = atoi(s.substr(outer_last).c_str());
298
+ addFormalOUTSVFGNode(SVFUtil::dyn_cast<FunExitICFGNode>(pag->getICFG()->getICFGNode(FunID)), tempMRVer, id);
299
+ }
300
+ else if(type == "ActualINSVFGNode")
301
+ {
302
+ outer_last = s.find("ICFGNodeID: ") + 12;
303
+ NodeID CallSiteID = atoi(s.substr(outer_last).c_str());
304
+ addActualINSVFGNode(SVFUtil::dyn_cast<CallICFGNode>(pag->getICFG()->getICFGNode(CallSiteID)), tempMRVer, id);
305
+ }
306
+ else if(type == "ActualOUTSVFGNode")
307
+ {
308
+ outer_last = s.find("ICFGNodeID: ") + 12;
309
+ NodeID CallSiteID = atoi(s.substr(outer_last).c_str());
310
+ addActualOUTSVFGNode(SVFUtil::dyn_cast<CallICFGNode>(pag->getICFG()->getICFGNode(CallSiteID)), tempMRVer, id);
311
+ }
312
+ else if (type == "PHISVFGNode")
313
+ {
314
+ opVer = s.substr(outer_last);
315
+ next = opVer.find("{") + 1;
316
+ last = opVer.find(",}");
317
+ temp = opVer.substr(next, last);
318
+ Map<u32_t,const MRVer*> OPVers;
319
+ int index = 0;
320
+ while ((next = temp.find("{") + 1) != string::npos)
321
+ {
322
+ if (temp == ",}")
323
+ break;
324
+ last = temp.find("},");
325
+ string temp1;
326
+ temp1 = temp.substr(next, last-next);
327
+ MRVer* tempOPVer = getMRVERFromString(temp1);
328
+ OPVers.insert(make_pair(index, tempOPVer));
329
+ temp = temp.substr(last + 1);
330
+ index++;
331
+ }
332
+ next = basicBlock.find("ICFGNodeID: ") + 12;
333
+ temp = basicBlock.substr(next);
334
+ addIntraMSSAPHISVFGNode(pag->getICFG()->getICFGNode(atoi(temp.c_str())), OPVers.begin(), OPVers.end(), tempMRVer, id);
335
+ }
336
+ else
337
+ {
338
+ }
339
+
340
+ if (totalVFGNode < id)
341
+ totalVFGNode = id + 1;
342
+ }
343
+ stat->ATVFNodeEnd();
344
+
345
+ stat->indVFEdgeStart();
346
+ // Edges
347
+ while (F.good())
348
+ {
349
+ getline(F, line);
350
+ if (line.empty())
351
+ continue;
352
+
353
+ std::string s = line;
354
+ std::string delimiter = " >= ";
355
+ string temp;
356
+ // int index = 0;
357
+ size_t last = 0;
358
+ size_t next = 0; // size_t outer_last = 0;
359
+ string edge;
360
+ string attributes;
361
+
362
+ next = s.find(delimiter);
363
+
364
+ edge = s.substr(0, next);
365
+ attributes = s.substr(next + 4);
366
+
367
+ // extract nodeIDs for src and dst nodes
368
+ NodeID src;
369
+ NodeID dst;
370
+ next = edge.find("srcSVFGNodeID: ") + 15;
371
+ last = edge.find(" => ");
372
+ src = atoi(edge.substr(next, last-next).c_str());
373
+ next = edge.find("dstSVFGNodeID: ") + 15;
374
+ dst = atoi(edge.substr(next).c_str());
375
+
376
+ string type;
377
+ string attribute;
378
+ if (attributes.find(" | ") == string::npos)
379
+ type = attributes;
380
+ else
381
+ {
382
+ next = attributes.find(" | ");
383
+ type = attributes.substr(0, next);
384
+ attribute = attributes.substr(next + 3);
385
+ }
386
+
387
+ if(type == "FormalINSVFGNode")
388
+ {
389
+ const FormalINSVFGNode* formalIn = SVFUtil::cast<FormalINSVFGNode>(getSVFGNode(src));
390
+ const ActualINSVFGNode* actualIn = SVFUtil::cast<ActualINSVFGNode>(getSVFGNode(dst));
391
+ addInterIndirectVFCallEdge(actualIn,formalIn, getCallSiteID(actualIn->getCallSite(), formalIn->getFun()));
392
+ }
393
+ else if(type == "FormalOUTSVFGNode")
394
+ {
395
+ const FormalOUTSVFGNode* formalOut = SVFUtil::cast<FormalOUTSVFGNode>(getSVFGNode(src));
396
+ if (attribute.find("intra") != string::npos)
397
+ {
398
+ addIntraIndirectVFEdge(dst, src, formalOut->getMRVer()->getMR()->getPointsTo());
399
+ }
400
+ else
401
+ {
402
+ const ActualOUTSVFGNode* actualOut = SVFUtil::cast<ActualOUTSVFGNode>(getSVFGNode(dst));
403
+ addInterIndirectVFRetEdge(formalOut,actualOut,getCallSiteID(actualOut->getCallSite(), formalOut->getFun()));
404
+ }
405
+ }
406
+ else if(type == "ActualINSVFGNode")
407
+ {
408
+ const ActualINSVFGNode* actualIn = SVFUtil::cast<ActualINSVFGNode>(getSVFGNode(src));
409
+ addIntraIndirectVFEdge(dst,src, actualIn->getMRVer()->getMR()->getPointsTo());
410
+ }
411
+ else if(type == "ActualOUTSVFGNode")
412
+ {
413
+ // There's no need to connect actual out node to its definition site in the same function.
414
+ }
415
+ else if (type == "StoreNode" || type == "LoadNode" || type == "PHISVFGNode")
416
+ {
417
+ MRVer* tempMRVer;
418
+ tempMRVer = getMRVERFromString(attribute);
419
+ addIntraIndirectVFEdge(dst,src, tempMRVer->getMR()->getPointsTo());
420
+ }
421
+ else
422
+ {
423
+ }
424
+ }
425
+ stat->indVFEdgeEnd();
426
+ connectFromGlobalToProgEntry();
427
+ }
428
+
429
+ MRVer* SVFG::getMRVERFromString(const string& s)
430
+ {
431
+ if(s == "")
432
+ {
433
+ return NULL;
434
+ }
435
+ string temp;
436
+ size_t last = 0;
437
+ size_t next = 0;
438
+ MRVer* tempMRVer;
439
+ MemRegion* tempMemRegion;
440
+ MSSADEF* tempDef;
441
+ //{create Memory Region object
442
+ next = s.find("MemRegion: pts{") + 15;
443
+ last = s.find("} MRVERSION: ");
444
+ temp = s.substr(next, last-next);
445
+ // convert string to PointsTo
446
+ NodeBS dstPts;
447
+ string point;
448
+ stringstream ss(temp);
449
+ while (getline(ss, point, ' '))
450
+ {
451
+ istringstream sss(point);
452
+ NodeID obj;
453
+ sss >> obj;
454
+ dstPts.set(obj);
455
+ }
456
+ tempMemRegion = new MemRegion(dstPts);
457
+ // create mssdef
458
+ next = s.find("MSSADef: ") + 9;
459
+ last = s.find("} >=");
460
+ temp = s.substr(next, last-next);
461
+ // convert string to deftype
462
+ istringstream ss1(temp.substr(0, temp.find(", ")));
463
+ int obj1;
464
+ ss1 >> obj1;
465
+ MSSADEF::DEFTYPE defType = static_cast<MSSADEF::DEFTYPE>(obj1);
466
+ tempDef = new MSSADEF(defType, tempMemRegion);
467
+ // mrversion
468
+ next = s.find("MRVERSION: ") + 11;
469
+ last = s.find(" MSSADef:");
470
+ temp = s.substr(next, last-next);
471
+ // convert mrversion to nodeid
472
+ istringstream ss2(temp);
473
+ NodeID obj2;
474
+ ss2 >> obj2;
475
+ // create mrver
476
+ tempMRVer = new MRVer(tempMemRegion, obj2, tempDef);
477
+ return tempMRVer;
478
+ }
@@ -807,3 +807,10 @@ ModRefInfo MRGenerator::getModRefInfo(const CallICFGNode* cs1, const CallICFGNod
807
807
  else
808
808
  return ModRefInfo::NoModRef;
809
809
  }
810
+
811
+ std::ostream& SVF::operator<<(std::ostream &o, const MRVer& mrver)
812
+ {
813
+ o << "MRVERID: " << mrver.getID() <<" MemRegion: " << mrver.getMR()->dumpStr() << " MRVERSION: " << mrver.getSSAVersion() << " MSSADef: " << mrver.getDef()->getType() << ", "
814
+ << mrver.getDef()->getMR()->dumpStr() ;
815
+ return o;
816
+ }
@@ -471,6 +471,17 @@ llvm::cl::opt<bool> Options::OPTSVFG(
471
471
  llvm::cl::desc("Optimize SVFG to eliminate formal-in and actual-out")
472
472
  );
473
473
 
474
+ const llvm::cl::opt<std::string> Options::WriteSVFG(
475
+ "write-svfg",
476
+ llvm::cl::init(""),
477
+ llvm::cl::desc("Write SVFG's analysis results to a file")
478
+ );
479
+
480
+ const llvm::cl::opt<std::string> Options::ReadSVFG(
481
+ "read-svfg",
482
+ llvm::cl::init(""),
483
+ llvm::cl::desc("Read SVFG's analysis results from a file")
484
+ );
474
485
 
475
486
  // FSMPTA.cpp
476
487
  const llvm::cl::opt<bool> Options::UsePCG(
@@ -739,14 +750,6 @@ const llvm::cl::opt<bool> Options::TBHCAllReuse(
739
750
  );
740
751
 
741
752
 
742
- // TypeAnalysis.cpp
743
- const llvm::cl::opt<bool> Options::GenICFG(
744
- "gen-icfg",
745
- llvm::cl::init(true),
746
- llvm::cl::desc("Generate ICFG graph")
747
- );
748
-
749
-
750
753
  //WPAPass.cpp
751
754
  const llvm::cl::opt<bool> Options::AnderSVFG(
752
755
  "svfg",
@@ -46,7 +46,7 @@ using namespace std;
46
46
  void TypeAnalysis::initialize()
47
47
  {
48
48
  AndersenBase::initialize();
49
- if (Options::GenICFG)
49
+ if (Options::DumpICFG)
50
50
  {
51
51
  icfg = SVFIR::getPAG()->getICFG();
52
52
  icfg->dump("icfg_initial");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.463",
3
+ "version": "1.0.466",
4
4
  "description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
5
5
  "main": "index.js",
6
6
  "scripts": {