svf-tools 1.0.1205 → 1.0.1207

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 (127) hide show
  1. package/package.json +1 -1
  2. package/svf/include/AE/Svfexe/AEStat.h +88 -0
  3. package/svf/include/AE/Svfexe/AbsExtAPI.h +5 -0
  4. package/svf/include/AE/Svfexe/AbstractInterpretation.h +2 -60
  5. package/svf/lib/AE/Svfexe/AEDetector.cpp +4 -4
  6. package/svf/lib/AE/Svfexe/AEStat.cpp +163 -0
  7. package/svf/lib/AE/Svfexe/AbsExtAPI.cpp +56 -1
  8. package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +2 -193
  9. package/SVF-doxygen/doxygen.config +0 -2548
  10. package/SVF-doxygen/wiki/PAG.png +0 -0
  11. package/SVF-doxygen/wiki/andersen.png +0 -0
  12. package/SVF-doxygen/wiki/callgraph.png +0 -0
  13. package/SVF-doxygen/wiki/consG.png +0 -0
  14. package/SVF-doxygen/wiki/cpu2000-flto +0 -432
  15. package/SVF-doxygen/wiki/cpu2006-flto +0 -417
  16. package/SVF-doxygen/wiki/cpu2017-wllvm.cfg +0 -999
  17. package/SVF-doxygen/wiki/database.png +0 -0
  18. package/SVF-doxygen/wiki/framework.png +0 -0
  19. package/SVF-doxygen/wiki/help.png +0 -0
  20. package/SVF-doxygen/wiki/icfg.png +0 -0
  21. package/SVF-doxygen/wiki/mssa-cha.png +0 -0
  22. package/SVF-doxygen/wiki/pagedge.png +0 -0
  23. package/SVF-doxygen/wiki/pagnode.png +0 -0
  24. package/SVF-doxygen/wiki/pt.png +0 -0
  25. package/SVF-doxygen/wiki/setupcmake.png +0 -0
  26. package/SVF-doxygen/wiki/setupconfiguration.png +0 -0
  27. package/SVF-doxygen/wiki/setupdashboard.png +0 -0
  28. package/SVF-doxygen/wiki/setupdebug.png +0 -0
  29. package/SVF-doxygen/wiki/setupenv.png +0 -0
  30. package/SVF-doxygen/wiki/startup.png +0 -0
  31. package/SVF-doxygen/wiki/svf-stat.pdf +0 -0
  32. package/SVF-doxygen/wiki/svfg-framework.png +0 -0
  33. package/SVF-doxygen/wiki/svfg.png +0 -0
  34. package/SVF-doxygen/wiki/svfg_opt.png +0 -0
  35. package/SVF-doxygen/wiki/svfgedge-cha.png +0 -0
  36. package/SVF-doxygen/wiki/svfgnode-cha.png +0 -0
  37. package/SVF-doxygen/wiki/svfpic/README.md +0 -6
  38. package/SVF-doxygen/wiki/svfpic/ass-1debug1.png +0 -0
  39. package/SVF-doxygen/wiki/svfpic/ass-1debug2.png +0 -0
  40. package/SVF-doxygen/wiki/svfpic/build.jpg +0 -0
  41. package/SVF-doxygen/wiki/svfpic/cmd.png +0 -0
  42. package/SVF-doxygen/wiki/svfpic/connect1.jpg +0 -0
  43. package/SVF-doxygen/wiki/svfpic/connect2.png +0 -0
  44. package/SVF-doxygen/wiki/svfpic/connect3.png +0 -0
  45. package/SVF-doxygen/wiki/svfpic/connect4.jpg +0 -0
  46. package/SVF-doxygen/wiki/svfpic/connect5.jpg +0 -0
  47. package/SVF-doxygen/wiki/svfpic/connect6.png +0 -0
  48. package/SVF-doxygen/wiki/svfpic/connect7.jpg +0 -0
  49. package/SVF-doxygen/wiki/svfpic/continue.png +0 -0
  50. package/SVF-doxygen/wiki/svfpic/debug-new.png +0 -0
  51. package/SVF-doxygen/wiki/svfpic/debug-new2.png +0 -0
  52. package/SVF-doxygen/wiki/svfpic/debug1.jpeg +0 -0
  53. package/SVF-doxygen/wiki/svfpic/debug2.jpeg +0 -0
  54. package/SVF-doxygen/wiki/svfpic/debug3.png +0 -0
  55. package/SVF-doxygen/wiki/svfpic/debug4.png +0 -0
  56. package/SVF-doxygen/wiki/svfpic/debug5.jpeg +0 -0
  57. package/SVF-doxygen/wiki/svfpic/debug6.jpeg +0 -0
  58. package/SVF-doxygen/wiki/svfpic/docker_sys_requirement.png +0 -0
  59. package/SVF-doxygen/wiki/svfpic/docker_sys_requirements.png +0 -0
  60. package/SVF-doxygen/wiki/svfpic/dockerbuild.png +0 -0
  61. package/SVF-doxygen/wiki/svfpic/dockerbuild2.jpg +0 -0
  62. package/SVF-doxygen/wiki/svfpic/dockerbuild3.jpg +0 -0
  63. package/SVF-doxygen/wiki/svfpic/dockerbuild4.png +0 -0
  64. package/SVF-doxygen/wiki/svfpic/dockerbuild5.jpg +0 -0
  65. package/SVF-doxygen/wiki/svfpic/dockerbuildimage.png +0 -0
  66. package/SVF-doxygen/wiki/svfpic/dockercmd.png +0 -0
  67. package/SVF-doxygen/wiki/svfpic/dockercmd2.png +0 -0
  68. package/SVF-doxygen/wiki/svfpic/dockercontainer.png +0 -0
  69. package/SVF-doxygen/wiki/svfpic/dockerdb1.jpg +0 -0
  70. package/SVF-doxygen/wiki/svfpic/dockerdb10.jpeg +0 -0
  71. package/SVF-doxygen/wiki/svfpic/dockerdb2.jpg +0 -0
  72. package/SVF-doxygen/wiki/svfpic/dockerdb3.jpg +0 -0
  73. package/SVF-doxygen/wiki/svfpic/dockerdb4.jpg +0 -0
  74. package/SVF-doxygen/wiki/svfpic/dockerdb5.png +0 -0
  75. package/SVF-doxygen/wiki/svfpic/dockerdb6.jpeg +0 -0
  76. package/SVF-doxygen/wiki/svfpic/dockerdb7.png +0 -0
  77. package/SVF-doxygen/wiki/svfpic/dockerdb8.png +0 -0
  78. package/SVF-doxygen/wiki/svfpic/dockerdb9.jpeg +0 -0
  79. package/SVF-doxygen/wiki/svfpic/dockerfinshbuilt.png +0 -0
  80. package/SVF-doxygen/wiki/svfpic/dockerimage.png +0 -0
  81. package/SVF-doxygen/wiki/svfpic/dockernameImage.png +0 -0
  82. package/SVF-doxygen/wiki/svfpic/dockerpull.png +0 -0
  83. package/SVF-doxygen/wiki/svfpic/dockerpull2.png +0 -0
  84. package/SVF-doxygen/wiki/svfpic/download.jpg +0 -0
  85. package/SVF-doxygen/wiki/svfpic/extension1.jpeg +0 -0
  86. package/SVF-doxygen/wiki/svfpic/extension2.jpeg +0 -0
  87. package/SVF-doxygen/wiki/svfpic/graphviz.png +0 -0
  88. package/SVF-doxygen/wiki/svfpic/hellodb.png +0 -0
  89. package/SVF-doxygen/wiki/svfpic/hellodb2.png +0 -0
  90. package/SVF-doxygen/wiki/svfpic/hviz_0.png +0 -0
  91. package/SVF-doxygen/wiki/svfpic/hviz_1.png +0 -0
  92. package/SVF-doxygen/wiki/svfpic/hviz_2.png +0 -0
  93. package/SVF-doxygen/wiki/svfpic/installC:C++Ext.png +0 -0
  94. package/SVF-doxygen/wiki/svfpic/installCMakeExt.png +0 -0
  95. package/SVF-doxygen/wiki/svfpic/installRCext.png +0 -0
  96. package/SVF-doxygen/wiki/svfpic/installdockerext.png +0 -0
  97. package/SVF-doxygen/wiki/svfpic/launch1.png +0 -0
  98. package/SVF-doxygen/wiki/svfpic/openfile.png +0 -0
  99. package/SVF-doxygen/wiki/svfpic/pathfolder.png +0 -0
  100. package/SVF-doxygen/wiki/svfpic/restart.png +0 -0
  101. package/SVF-doxygen/wiki/svfpic/rundocker.png +0 -0
  102. package/SVF-doxygen/wiki/svfpic/runinCLI.png +0 -0
  103. package/SVF-doxygen/wiki/svfpic/screen.png +0 -0
  104. package/SVF-doxygen/wiki/svfpic/settings1.jpg +0 -0
  105. package/SVF-doxygen/wiki/svfpic/settings2.jpg +0 -0
  106. package/SVF-doxygen/wiki/svfpic/settings3.jpg +0 -0
  107. package/SVF-doxygen/wiki/svfpic/shortlists.png +0 -0
  108. package/SVF-doxygen/wiki/svfpic/start.png +0 -0
  109. package/SVF-doxygen/wiki/svfpic/start1.png +0 -0
  110. package/SVF-doxygen/wiki/svfpic/update0.png +0 -0
  111. package/SVF-doxygen/wiki/svfpic/verify_docker.png +0 -0
  112. package/SVF-doxygen/wiki/svfpic/vs_entry_window.png +0 -0
  113. package/SVF-doxygen/wiki/svfpic/wsl.png +0 -0
  114. package/SVF-doxygen/wiki/svfpic/wsl_1.png +0 -0
  115. package/SVF-doxygen/wiki/svfpic/wsl_2.png +0 -0
  116. package/SVF-doxygen/wiki/svfpic/wsl_3.png +0 -0
  117. package/SVF-doxygen/wiki/tools.png +0 -0
  118. package/SVF-doxygen/wiki/users.png +0 -0
  119. package/SVF-doxygen/wiki/vm1.png +0 -0
  120. package/SVF-doxygen/wiki/vm2.png +0 -0
  121. package/SVF-doxygen/wiki/vm3.png +0 -0
  122. package/SVF-doxygen/wiki/vm4.png +0 -0
  123. package/SVF-doxygen/wiki/vm5.png +0 -0
  124. package/SVF-doxygen/wiki/vscode_build_tasks.png +0 -0
  125. package/SVF-doxygen/wiki/vscode_cpp_extension.png +0 -0
  126. package/SVF-doxygen/wiki/vscode_debug_list.png +0 -0
  127. package/SVF-doxygen/wiki/vscode_dir_structure.png +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.1205",
3
+ "version": "1.0.1207",
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": {
@@ -0,0 +1,88 @@
1
+ //===- AEStat.h -- Statistics for Abstract Execution----------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-> <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 Affero 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 Affero General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU Affero General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ #pragma once
24
+ #include "SVFIR/SVFType.h"
25
+ #include "Util/SVFUtil.h"
26
+ #include "Util/SVFStat.h"
27
+ #include <string>
28
+
29
+ namespace SVF
30
+ {
31
+
32
+ class AbstractInterpretation;
33
+
34
+ /// AEStat: Statistic for AE
35
+ class AEStat : public SVFStat
36
+ {
37
+ public:
38
+ void countStateSize();
39
+ AEStat(AbstractInterpretation* ae) : _ae(ae)
40
+ {
41
+ startTime = getClk(true);
42
+ }
43
+ ~AEStat()
44
+ {
45
+ }
46
+ inline std::string getMemUsage()
47
+ {
48
+ u32_t vmrss, vmsize;
49
+ return SVFUtil::getMemoryUsageKB(&vmrss, &vmsize) ? std::to_string(vmsize) + "KB" : "cannot read memory usage";
50
+ }
51
+
52
+ void finializeStat();
53
+ void performStat() override;
54
+
55
+ public:
56
+ AbstractInterpretation* _ae;
57
+ s32_t count{0};
58
+ std::string memory_usage;
59
+ std::string memUsage;
60
+
61
+
62
+ u32_t& getFunctionTrace()
63
+ {
64
+ if (generalNumMap.count("Function_Trace") == 0)
65
+ {
66
+ generalNumMap["Function_Trace"] = 0;
67
+ }
68
+ return generalNumMap["Function_Trace"];
69
+ }
70
+ u32_t& getBlockTrace()
71
+ {
72
+ if (generalNumMap.count("Block_Trace") == 0)
73
+ {
74
+ generalNumMap["Block_Trace"] = 0;
75
+ }
76
+ return generalNumMap["Block_Trace"];
77
+ }
78
+ u32_t& getICFGNodeTrace()
79
+ {
80
+ if (generalNumMap.count("ICFG_Node_Trace") == 0)
81
+ {
82
+ generalNumMap["ICFG_Node_Trace"] = 0;
83
+ }
84
+ return generalNumMap["ICFG_Node_Trace"];
85
+ }
86
+ };
87
+
88
+ } // namespace SVF
@@ -108,6 +108,11 @@ public:
108
108
  */
109
109
  AbstractState& getAbsStateFromTrace(const ICFGNode* node);
110
110
 
111
+ void collectCheckPoint();
112
+ void checkPointAllSet();
113
+
114
+ Set<const CallICFGNode*> checkpoints; // for CI check
115
+
111
116
  protected:
112
117
  SVFIR* svfir; ///< Pointer to the SVF intermediate representation.
113
118
  ICFG* icfg; ///< Pointer to the interprocedural control flow graph.
@@ -34,8 +34,8 @@
34
34
  #include "AE/Svfexe/AEDetector.h"
35
35
  #include "AE/Svfexe/PreAnalysis.h"
36
36
  #include "AE/Svfexe/AbsExtAPI.h"
37
+ #include "AE/Svfexe/AEStat.h"
37
38
  #include "Util/SVFBugReport.h"
38
- #include "Util/SVFStat.h"
39
39
  #include "Graphs/SCC.h"
40
40
  #include "Graphs/CallGraph.h"
41
41
  #include <deque>
@@ -49,60 +49,6 @@ class AEAPI;
49
49
 
50
50
  template<typename T> class FILOWorkList;
51
51
 
52
- /// AEStat: Statistic for AE
53
- class AEStat : public SVFStat
54
- {
55
- public:
56
- void countStateSize();
57
- AEStat(AbstractInterpretation* ae) : _ae(ae)
58
- {
59
- startTime = getClk(true);
60
- }
61
- ~AEStat()
62
- {
63
- }
64
- inline std::string getMemUsage()
65
- {
66
- u32_t vmrss, vmsize;
67
- return SVFUtil::getMemoryUsageKB(&vmrss, &vmsize) ? std::to_string(vmsize) + "KB" : "cannot read memory usage";
68
- }
69
-
70
- void finializeStat();
71
- void performStat() override;
72
-
73
- public:
74
- AbstractInterpretation* _ae;
75
- s32_t count{0};
76
- std::string memory_usage;
77
- std::string memUsage;
78
-
79
-
80
- u32_t& getFunctionTrace()
81
- {
82
- if (generalNumMap.count("Function_Trace") == 0)
83
- {
84
- generalNumMap["Function_Trace"] = 0;
85
- }
86
- return generalNumMap["Function_Trace"];
87
- }
88
- u32_t& getBlockTrace()
89
- {
90
- if (generalNumMap.count("Block_Trace") == 0)
91
- {
92
- generalNumMap["Block_Trace"] = 0;
93
- }
94
- return generalNumMap["Block_Trace"];
95
- }
96
- u32_t& getICFGNodeTrace()
97
- {
98
- if (generalNumMap.count("ICFG_Node_Trace") == 0)
99
- {
100
- generalNumMap["ICFG_Node_Trace"] = 0;
101
- }
102
- return generalNumMap["ICFG_Node_Trace"];
103
- }
104
- };
105
-
106
52
  /// AbstractInterpretation is same as Abstract Execution
107
53
  class AbstractInterpretation
108
54
  {
@@ -163,7 +109,7 @@ public:
163
109
  detectors.push_back(std::move(detector));
164
110
  }
165
111
 
166
- Set<const CallICFGNode*> checkpoints; // for CI check
112
+
167
113
 
168
114
  /**
169
115
  * @brief Retrieves the abstract state from the trace for a given ICFG node.
@@ -286,10 +232,6 @@ private:
286
232
  bool isSwitchBranchFeasible(const SVFVar* var, s64_t succ,
287
233
  AbstractState& as);
288
234
 
289
-
290
- void collectCheckPoint();
291
- void checkPointAllSet();
292
-
293
235
  void updateStateOnAddr(const AddrStmt *addr);
294
236
 
295
237
  void updateStateOnBinary(const BinaryOPStmt *binary);
@@ -119,7 +119,7 @@ void BufOverflowDetector::handleStubFunctions(const SVF::CallICFGNode* callNode)
119
119
  if (funcName == "SAFE_BUFACCESS")
120
120
  {
121
121
  // void SAFE_BUFACCESS(void* data, int size);
122
- AbstractInterpretation::getAEInstance().checkpoints.erase(callNode);
122
+ AbstractInterpretation::getAEInstance().getUtils()->checkpoints.erase(callNode);
123
123
  if (callNode->arg_size() < 2)
124
124
  return;
125
125
  AbstractState& as =
@@ -150,7 +150,7 @@ void BufOverflowDetector::handleStubFunctions(const SVF::CallICFGNode* callNode)
150
150
  else if (funcName == "UNSAFE_BUFACCESS")
151
151
  {
152
152
  // void UNSAFE_BUFACCESS(void* data, int size);
153
- AbstractInterpretation::getAEInstance().checkpoints.erase(callNode);
153
+ AbstractInterpretation::getAEInstance().getUtils()->checkpoints.erase(callNode);
154
154
  if (callNode->arg_size() < 2) return;
155
155
  AbstractState&as = AbstractInterpretation::getAEInstance().getAbsStateFromTrace(callNode);
156
156
  u32_t size_id = callNode->getArgument(1)->getId();
@@ -588,7 +588,7 @@ void NullptrDerefDetector::handleStubFunctions(const CallICFGNode* callNode)
588
588
  if (funcName == "UNSAFE_LOAD")
589
589
  {
590
590
  // void UNSAFE_LOAD(void* ptr);
591
- AbstractInterpretation::getAEInstance().checkpoints.erase(callNode);
591
+ AbstractInterpretation::getAEInstance().getUtils()->checkpoints.erase(callNode);
592
592
  if (callNode->arg_size() < 1)
593
593
  return;
594
594
  AbstractState& as = AbstractInterpretation::getAEInstance().getAbsStateFromTrace(callNode);
@@ -612,7 +612,7 @@ void NullptrDerefDetector::handleStubFunctions(const CallICFGNode* callNode)
612
612
  else if (funcName == "SAFE_LOAD")
613
613
  {
614
614
  // void SAFE_LOAD(void* ptr);
615
- AbstractInterpretation::getAEInstance().checkpoints.erase(callNode);
615
+ AbstractInterpretation::getAEInstance().getUtils()->checkpoints.erase(callNode);
616
616
  if (callNode->arg_size() < 1) return;
617
617
  AbstractState&as = AbstractInterpretation::getAEInstance().getAbsStateFromTrace(callNode);
618
618
  const SVFVar* arg0Val = callNode->getArgument(0);
@@ -0,0 +1,163 @@
1
+ //===- AEStat.cpp -- Statistics for Abstract Execution----------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-> <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 Affero 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 Affero General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU Affero General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ #include "AE/Svfexe/AEStat.h"
24
+ #include "AE/Svfexe/AbstractInterpretation.h"
25
+ #include "SVFIR/SVFIR.h"
26
+
27
+ using namespace SVF;
28
+ using namespace SVFUtil;
29
+
30
+ // count the size of memory map
31
+ void AEStat::countStateSize()
32
+ {
33
+ if (count == 0)
34
+ {
35
+ generalNumMap["ES_Var_AVG_Num"] = 0;
36
+ generalNumMap["ES_Loc_AVG_Num"] = 0;
37
+ generalNumMap["ES_Var_Addr_AVG_Num"] = 0;
38
+ generalNumMap["ES_Loc_Addr_AVG_Num"] = 0;
39
+ }
40
+ ++count;
41
+ }
42
+
43
+ void AEStat::finializeStat()
44
+ {
45
+ memUsage = getMemUsage();
46
+ if (count > 0)
47
+ {
48
+ generalNumMap["ES_Var_AVG_Num"] /= count;
49
+ generalNumMap["ES_Loc_AVG_Num"] /= count;
50
+ generalNumMap["ES_Var_Addr_AVG_Num"] /= count;
51
+ generalNumMap["ES_Loc_Addr_AVG_Num"] /= count;
52
+ }
53
+ generalNumMap["SVF_STMT_NUM"] = count;
54
+
55
+ u32_t totalICFGNodes = _ae->svfir->getICFG()->nodeNum;
56
+ generalNumMap["ICFG_Node_Num"] = totalICFGNodes;
57
+
58
+ // Calculate coverage: use allAnalyzedNodes which tracks all nodes across all entry points
59
+ u32_t analyzedNodes = _ae->allAnalyzedNodes.size();
60
+ generalNumMap["Analyzed_ICFG_Node_Num"] = analyzedNodes;
61
+
62
+ // Coverage percentage (stored as integer percentage * 100 for precision)
63
+ if (totalICFGNodes > 0)
64
+ {
65
+ double coveragePercent = (double)analyzedNodes / (double)totalICFGNodes * 100.0;
66
+ generalNumMap["ICFG_Coverage_Percent"] = (u32_t)(coveragePercent * 100); // Store as percentage * 100
67
+ }
68
+ else
69
+ {
70
+ generalNumMap["ICFG_Coverage_Percent"] = 0;
71
+ }
72
+
73
+ u32_t callSiteNum = 0;
74
+ u32_t extCallSiteNum = 0;
75
+ Set<const FunObjVar *> funs;
76
+ Set<const FunObjVar *> analyzedFuns;
77
+ for (const auto &it: *_ae->svfir->getICFG())
78
+ {
79
+ if (it.second->getFun())
80
+ {
81
+ funs.insert(it.second->getFun());
82
+ // Check if this node was analyzed (across all entry points)
83
+ if (_ae->allAnalyzedNodes.find(it.second) != _ae->allAnalyzedNodes.end())
84
+ {
85
+ analyzedFuns.insert(it.second->getFun());
86
+ }
87
+ }
88
+ if (const CallICFGNode *callNode = dyn_cast<CallICFGNode>(it.second))
89
+ {
90
+ if (!isExtCall(callNode))
91
+ {
92
+ callSiteNum++;
93
+ }
94
+ else
95
+ {
96
+ extCallSiteNum++;
97
+ }
98
+ }
99
+ }
100
+ generalNumMap["Func_Num"] = funs.size();
101
+ generalNumMap["Analyzed_Func_Num"] = analyzedFuns.size();
102
+
103
+ // Function coverage percentage
104
+ if (funs.size() > 0)
105
+ {
106
+ double funcCoveragePercent = (double)analyzedFuns.size() / (double)funs.size() * 100.0;
107
+ generalNumMap["Func_Coverage_Percent"] = (u32_t)(funcCoveragePercent * 100); // Store as percentage * 100
108
+ }
109
+ else
110
+ {
111
+ generalNumMap["Func_Coverage_Percent"] = 0;
112
+ }
113
+
114
+ generalNumMap["EXT_CallSite_Num"] = extCallSiteNum;
115
+ generalNumMap["NonEXT_CallSite_Num"] = callSiteNum;
116
+ timeStatMap["Total_Time(sec)"] = (double)(endTime - startTime) / TIMEINTERVAL;
117
+
118
+ }
119
+
120
+ void AEStat::performStat()
121
+ {
122
+ std::string fullName(_ae->moduleName);
123
+ std::string name;
124
+ std::string moduleName;
125
+ if (fullName.find('/') == std::string::npos)
126
+ {
127
+ std::string name = fullName;
128
+ moduleName = name.substr(0, fullName.find('.'));
129
+ }
130
+ else
131
+ {
132
+ std::string name = fullName.substr(fullName.find('/'), fullName.size());
133
+ moduleName = name.substr(0, fullName.find('.'));
134
+ }
135
+
136
+ SVFUtil::outs() << "\n************************\n";
137
+ SVFUtil::outs() << "################ (program : " << moduleName << ")###############\n";
138
+ SVFUtil::outs().flags(std::ios::left);
139
+ unsigned field_width = 30;
140
+ for (NUMStatMap::iterator it = generalNumMap.begin(), eit = generalNumMap.end(); it != eit; ++it)
141
+ {
142
+ // Special handling for percentage fields (stored as percentage * 100)
143
+ if (it->first == "ICFG_Coverage_Percent" || it->first == "Func_Coverage_Percent")
144
+ {
145
+ double percent = (double)it->second / 100.0;
146
+ std::cout << std::setw(field_width) << it->first << std::fixed << std::setprecision(2) << percent << "%\n";
147
+ }
148
+ else
149
+ {
150
+ std::cout << std::setw(field_width) << it->first << it->second << "\n";
151
+ }
152
+ }
153
+ SVFUtil::outs() << "-------------------------------------------------------\n";
154
+ for (TIMEStatMap::iterator it = timeStatMap.begin(), eit = timeStatMap.end(); it != eit; ++it)
155
+ {
156
+ // format out put with width 20 space
157
+ SVFUtil::outs() << std::setw(field_width) << it->first << it->second << "\n";
158
+ }
159
+ SVFUtil::outs() << "Memory usage: " << memUsage << "\n";
160
+
161
+ SVFUtil::outs() << "#######################################################" << std::endl;
162
+ SVFUtil::outs().flush();
163
+ }
@@ -76,7 +76,7 @@ void AbsExtAPI::initExtFunMap()
76
76
 
77
77
  auto sse_svf_assert = [this](const CallICFGNode* callNode)
78
78
  {
79
- AbstractInterpretation::getAEInstance().checkpoints.erase(callNode);
79
+ checkpoints.erase(callNode);
80
80
  u32_t arg0 = callNode->getArgument(0)->getId();
81
81
  AbstractState&as = getAbsStateFromTrace(callNode);
82
82
  if (as[arg0].getInterval().equals(IntervalValue(1, 1)))
@@ -348,6 +348,61 @@ AbstractState& AbsExtAPI::getAbsStateFromTrace(const SVF::ICFGNode* node)
348
348
  }
349
349
  }
350
350
 
351
+ void AbsExtAPI::collectCheckPoint()
352
+ {
353
+ // traverse every ICFGNode
354
+ Set<std::string> ae_checkpoint_names = {"svf_assert"};
355
+ Set<std::string> buf_checkpoint_names = {"UNSAFE_BUFACCESS", "SAFE_BUFACCESS"};
356
+ Set<std::string> nullptr_checkpoint_names = {"UNSAFE_LOAD", "SAFE_LOAD"};
357
+
358
+ for (auto it = svfir->getICFG()->begin(); it != svfir->getICFG()->end(); ++it)
359
+ {
360
+ const ICFGNode* node = it->second;
361
+ if (const CallICFGNode *call = SVFUtil::dyn_cast<CallICFGNode>(node))
362
+ {
363
+ if (const FunObjVar *fun = call->getCalledFunction())
364
+ {
365
+ if (ae_checkpoint_names.find(fun->getName()) !=
366
+ ae_checkpoint_names.end())
367
+ {
368
+ checkpoints.insert(call);
369
+ }
370
+ if (Options::BufferOverflowCheck())
371
+ {
372
+ if (buf_checkpoint_names.find(fun->getName()) !=
373
+ buf_checkpoint_names.end())
374
+ {
375
+ checkpoints.insert(call);
376
+ }
377
+ }
378
+ if (Options::NullDerefCheck())
379
+ {
380
+ if (nullptr_checkpoint_names.find(fun->getName()) !=
381
+ nullptr_checkpoint_names.end())
382
+ {
383
+ checkpoints.insert(call);
384
+ }
385
+ }
386
+ }
387
+ }
388
+ }
389
+ }
390
+
391
+ void AbsExtAPI::checkPointAllSet()
392
+ {
393
+ if (checkpoints.size() == 0)
394
+ {
395
+ return;
396
+ }
397
+ else
398
+ {
399
+ SVFUtil::errs() << SVFUtil::errMsg("At least one svf_assert has not been checked!!") << "\n";
400
+ for (const CallICFGNode* call: checkpoints)
401
+ SVFUtil::errs() << call->toString() + "\n";
402
+ assert(false);
403
+ }
404
+ }
405
+
351
406
  std::string AbsExtAPI::strRead(AbstractState& as, const SVFVar* rhs)
352
407
  {
353
408
  // sse read string nodeID->string
@@ -55,10 +55,10 @@ void AbstractInterpretation::runOnModule(ICFG *_icfg)
55
55
  preAnalysis->initWTO();
56
56
 
57
57
  /// collect checkpoint
58
- collectCheckPoint();
58
+ utils->collectCheckPoint();
59
59
 
60
60
  analyse();
61
- checkPointAllSet();
61
+ utils->checkPointAllSet();
62
62
  stat->endClk();
63
63
  stat->finializeStat();
64
64
  if (Options::PStat())
@@ -1168,197 +1168,6 @@ void AbstractInterpretation::setTopToObjInRecursion(const CallICFGNode *callNode
1168
1168
  }
1169
1169
  }
1170
1170
 
1171
- // count the size of memory map
1172
- void AEStat::countStateSize()
1173
- {
1174
- if (count == 0)
1175
- {
1176
- generalNumMap["ES_Var_AVG_Num"] = 0;
1177
- generalNumMap["ES_Loc_AVG_Num"] = 0;
1178
- generalNumMap["ES_Var_Addr_AVG_Num"] = 0;
1179
- generalNumMap["ES_Loc_Addr_AVG_Num"] = 0;
1180
- }
1181
- ++count;
1182
- }
1183
-
1184
- void AEStat::finializeStat()
1185
- {
1186
- memUsage = getMemUsage();
1187
- if (count > 0)
1188
- {
1189
- generalNumMap["ES_Var_AVG_Num"] /= count;
1190
- generalNumMap["ES_Loc_AVG_Num"] /= count;
1191
- generalNumMap["ES_Var_Addr_AVG_Num"] /= count;
1192
- generalNumMap["ES_Loc_Addr_AVG_Num"] /= count;
1193
- }
1194
- generalNumMap["SVF_STMT_NUM"] = count;
1195
-
1196
- u32_t totalICFGNodes = _ae->svfir->getICFG()->nodeNum;
1197
- generalNumMap["ICFG_Node_Num"] = totalICFGNodes;
1198
-
1199
- // Calculate coverage: use allAnalyzedNodes which tracks all nodes across all entry points
1200
- u32_t analyzedNodes = _ae->allAnalyzedNodes.size();
1201
- generalNumMap["Analyzed_ICFG_Node_Num"] = analyzedNodes;
1202
-
1203
- // Coverage percentage (stored as integer percentage * 100 for precision)
1204
- if (totalICFGNodes > 0)
1205
- {
1206
- double coveragePercent = (double)analyzedNodes / (double)totalICFGNodes * 100.0;
1207
- generalNumMap["ICFG_Coverage_Percent"] = (u32_t)(coveragePercent * 100); // Store as percentage * 100
1208
- }
1209
- else
1210
- {
1211
- generalNumMap["ICFG_Coverage_Percent"] = 0;
1212
- }
1213
-
1214
- u32_t callSiteNum = 0;
1215
- u32_t extCallSiteNum = 0;
1216
- Set<const FunObjVar *> funs;
1217
- Set<const FunObjVar *> analyzedFuns;
1218
- for (const auto &it: *_ae->svfir->getICFG())
1219
- {
1220
- if (it.second->getFun())
1221
- {
1222
- funs.insert(it.second->getFun());
1223
- // Check if this node was analyzed (across all entry points)
1224
- if (_ae->allAnalyzedNodes.find(it.second) != _ae->allAnalyzedNodes.end())
1225
- {
1226
- analyzedFuns.insert(it.second->getFun());
1227
- }
1228
- }
1229
- if (const CallICFGNode *callNode = dyn_cast<CallICFGNode>(it.second))
1230
- {
1231
- if (!isExtCall(callNode))
1232
- {
1233
- callSiteNum++;
1234
- }
1235
- else
1236
- {
1237
- extCallSiteNum++;
1238
- }
1239
- }
1240
- }
1241
- generalNumMap["Func_Num"] = funs.size();
1242
- generalNumMap["Analyzed_Func_Num"] = analyzedFuns.size();
1243
-
1244
- // Function coverage percentage
1245
- if (funs.size() > 0)
1246
- {
1247
- double funcCoveragePercent = (double)analyzedFuns.size() / (double)funs.size() * 100.0;
1248
- generalNumMap["Func_Coverage_Percent"] = (u32_t)(funcCoveragePercent * 100); // Store as percentage * 100
1249
- }
1250
- else
1251
- {
1252
- generalNumMap["Func_Coverage_Percent"] = 0;
1253
- }
1254
-
1255
- generalNumMap["EXT_CallSite_Num"] = extCallSiteNum;
1256
- generalNumMap["NonEXT_CallSite_Num"] = callSiteNum;
1257
- timeStatMap["Total_Time(sec)"] = (double)(endTime - startTime) / TIMEINTERVAL;
1258
-
1259
- }
1260
-
1261
- void AEStat::performStat()
1262
- {
1263
- std::string fullName(_ae->moduleName);
1264
- std::string name;
1265
- std::string moduleName;
1266
- if (fullName.find('/') == std::string::npos)
1267
- {
1268
- std::string name = fullName;
1269
- moduleName = name.substr(0, fullName.find('.'));
1270
- }
1271
- else
1272
- {
1273
- std::string name = fullName.substr(fullName.find('/'), fullName.size());
1274
- moduleName = name.substr(0, fullName.find('.'));
1275
- }
1276
-
1277
- SVFUtil::outs() << "\n************************\n";
1278
- SVFUtil::outs() << "################ (program : " << moduleName << ")###############\n";
1279
- SVFUtil::outs().flags(std::ios::left);
1280
- unsigned field_width = 30;
1281
- for (NUMStatMap::iterator it = generalNumMap.begin(), eit = generalNumMap.end(); it != eit; ++it)
1282
- {
1283
- // Special handling for percentage fields (stored as percentage * 100)
1284
- if (it->first == "ICFG_Coverage_Percent" || it->first == "Func_Coverage_Percent")
1285
- {
1286
- double percent = (double)it->second / 100.0;
1287
- std::cout << std::setw(field_width) << it->first << std::fixed << std::setprecision(2) << percent << "%\n";
1288
- }
1289
- else
1290
- {
1291
- std::cout << std::setw(field_width) << it->first << it->second << "\n";
1292
- }
1293
- }
1294
- SVFUtil::outs() << "-------------------------------------------------------\n";
1295
- for (TIMEStatMap::iterator it = timeStatMap.begin(), eit = timeStatMap.end(); it != eit; ++it)
1296
- {
1297
- // format out put with width 20 space
1298
- SVFUtil::outs() << std::setw(field_width) << it->first << it->second << "\n";
1299
- }
1300
- SVFUtil::outs() << "Memory usage: " << memUsage << "\n";
1301
-
1302
- SVFUtil::outs() << "#######################################################" << std::endl;
1303
- SVFUtil::outs().flush();
1304
- }
1305
-
1306
- void AbstractInterpretation::collectCheckPoint()
1307
- {
1308
- // traverse every ICFGNode
1309
- Set<std::string> ae_checkpoint_names = {"svf_assert"};
1310
- Set<std::string> buf_checkpoint_names = {"UNSAFE_BUFACCESS", "SAFE_BUFACCESS"};
1311
- Set<std::string> nullptr_checkpoint_names = {"UNSAFE_LOAD", "SAFE_LOAD"};
1312
-
1313
- for (auto it = svfir->getICFG()->begin(); it != svfir->getICFG()->end(); ++it)
1314
- {
1315
- const ICFGNode* node = it->second;
1316
- if (const CallICFGNode *call = SVFUtil::dyn_cast<CallICFGNode>(node))
1317
- {
1318
- if (const FunObjVar *fun = call->getCalledFunction())
1319
- {
1320
- if (ae_checkpoint_names.find(fun->getName()) !=
1321
- ae_checkpoint_names.end())
1322
- {
1323
- checkpoints.insert(call);
1324
- }
1325
- if (Options::BufferOverflowCheck())
1326
- {
1327
- if (buf_checkpoint_names.find(fun->getName()) !=
1328
- buf_checkpoint_names.end())
1329
- {
1330
- checkpoints.insert(call);
1331
- }
1332
- }
1333
- if (Options::NullDerefCheck())
1334
- {
1335
- if (nullptr_checkpoint_names.find(fun->getName()) !=
1336
- nullptr_checkpoint_names.end())
1337
- {
1338
- checkpoints.insert(call);
1339
- }
1340
- }
1341
- }
1342
- }
1343
- }
1344
- }
1345
-
1346
- void AbstractInterpretation::checkPointAllSet()
1347
- {
1348
- if (checkpoints.size() == 0)
1349
- {
1350
- return;
1351
- }
1352
- else
1353
- {
1354
- SVFUtil::errs() << SVFUtil::errMsg("At least one svf_assert has not been checked!!") << "\n";
1355
- for (const CallICFGNode* call: checkpoints)
1356
- SVFUtil::errs() << call->toString() + "\n";
1357
- assert(false);
1358
- }
1359
-
1360
- }
1361
-
1362
1171
  void AbstractInterpretation::updateStateOnGep(const GepStmt *gep)
1363
1172
  {
1364
1173
  AbstractState& as = getAbsStateFromTrace(gep->getICFGNode());