svf-lib 1.0.1375 → 1.0.1376

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 (147) hide show
  1. package/SVF-osx/Release-build/svf-llvm/libSvfLLVM.a +0 -0
  2. package/SVF-osx/svf/include/include/AbstractExecution/AbstractValue.h +79 -0
  3. package/SVF-osx/svf/include/include/AbstractExecution/AddressValue.h +210 -0
  4. package/SVF-osx/svf/include/include/AbstractExecution/ExeState.h +223 -0
  5. package/SVF-osx/svf/include/include/AbstractExecution/IntervalExeState.h +425 -0
  6. package/SVF-osx/svf/include/include/AbstractExecution/IntervalValue.h +868 -0
  7. package/SVF-osx/svf/include/include/AbstractExecution/NumericLiteral.h +406 -0
  8. package/SVF-osx/svf/include/include/AbstractExecution/RelExeState.h +225 -0
  9. package/SVF-osx/svf/include/include/AbstractExecution/RelationSolver.h +68 -0
  10. package/SVF-osx/svf/include/include/AbstractExecution/SVFIR2ItvExeState.h +186 -0
  11. package/SVF-osx/svf/include/include/AbstractExecution/WTO.h +845 -0
  12. package/SVF-osx/svf/include/include/CFL/CFGNormalizer.h +84 -0
  13. package/SVF-osx/svf/include/include/CFL/CFLAlias.h +176 -0
  14. package/SVF-osx/svf/include/include/CFL/CFLBase.h +115 -0
  15. package/SVF-osx/svf/include/include/CFL/CFLData.h +316 -0
  16. package/SVF-osx/svf/include/include/CFL/CFLDataBuilder.h +91 -0
  17. package/SVF-osx/svf/include/include/CFL/CFLGramGraphChecker.h +74 -0
  18. package/SVF-osx/svf/include/include/CFL/CFLGrammar.h +468 -0
  19. package/SVF-osx/svf/include/include/CFL/CFLGrammar.txt +15 -0
  20. package/SVF-osx/svf/include/include/CFL/CFLGraphBuilder.h +193 -0
  21. package/SVF-osx/svf/include/include/CFL/CFLSolver.h +136 -0
  22. package/SVF-osx/svf/include/include/CFL/CFLStat.h +67 -0
  23. package/SVF-osx/svf/include/include/CFL/CFLVF.h +65 -0
  24. package/SVF-osx/svf/include/include/CFL/GrammarBuilder.h +100 -0
  25. package/SVF-osx/svf/include/include/CFL/PEGGrammar.txt +11 -0
  26. package/SVF-osx/svf/include/include/CFL/VFG.txt +7 -0
  27. package/SVF-osx/svf/include/include/DDA/ContextDDA.h +230 -0
  28. package/SVF-osx/svf/include/include/DDA/DDAClient.h +168 -0
  29. package/SVF-osx/svf/include/include/DDA/DDAPass.h +99 -0
  30. package/SVF-osx/svf/include/include/DDA/DDAStat.h +138 -0
  31. package/SVF-osx/svf/include/include/DDA/DDAVFSolver.h +789 -0
  32. package/SVF-osx/svf/include/include/DDA/FlowDDA.h +178 -0
  33. package/SVF-osx/svf/include/include/FastCluster/LICENSE.TXT +13 -0
  34. package/SVF-osx/svf/include/include/FastCluster/fastcluster.h +80 -0
  35. package/SVF-osx/svf/include/include/Graphs/CFLGraph.h +215 -0
  36. package/SVF-osx/svf/include/include/Graphs/CHG.h +351 -0
  37. package/SVF-osx/svf/include/include/Graphs/ConsG.h +408 -0
  38. package/SVF-osx/svf/include/include/Graphs/ConsGEdge.h +353 -0
  39. package/SVF-osx/svf/include/include/Graphs/ConsGNode.h +391 -0
  40. package/SVF-osx/svf/include/include/Graphs/DOTGraphTraits.h +188 -0
  41. package/SVF-osx/svf/include/include/Graphs/GenericGraph.h +620 -0
  42. package/SVF-osx/svf/include/include/Graphs/GraphPrinter.h +111 -0
  43. package/SVF-osx/svf/include/include/Graphs/GraphTraits.h +150 -0
  44. package/SVF-osx/svf/include/include/Graphs/GraphWriter.h +380 -0
  45. package/SVF-osx/svf/include/include/Graphs/ICFG.h +331 -0
  46. package/SVF-osx/svf/include/include/Graphs/ICFGEdge.h +264 -0
  47. package/SVF-osx/svf/include/include/Graphs/ICFGNode.h +523 -0
  48. package/SVF-osx/svf/include/include/Graphs/ICFGStat.h +164 -0
  49. package/SVF-osx/svf/include/include/Graphs/IRGraph.h +243 -0
  50. package/SVF-osx/svf/include/include/Graphs/PTACallGraph.h +471 -0
  51. package/SVF-osx/svf/include/include/Graphs/SVFG.h +490 -0
  52. package/SVF-osx/svf/include/include/Graphs/SVFGEdge.h +237 -0
  53. package/SVF-osx/svf/include/include/Graphs/SVFGNode.h +513 -0
  54. package/SVF-osx/svf/include/include/Graphs/SVFGOPT.h +362 -0
  55. package/SVF-osx/svf/include/include/Graphs/SVFGStat.h +273 -0
  56. package/SVF-osx/svf/include/include/Graphs/ThreadCallGraph.h +422 -0
  57. package/SVF-osx/svf/include/include/Graphs/VFG.h +664 -0
  58. package/SVF-osx/svf/include/include/Graphs/VFGEdge.h +295 -0
  59. package/SVF-osx/svf/include/include/Graphs/VFGNode.h +1197 -0
  60. package/SVF-osx/svf/include/include/MSSA/MSSAMuChi.h +722 -0
  61. package/SVF-osx/svf/include/include/MSSA/MemPartition.h +169 -0
  62. package/SVF-osx/svf/include/include/MSSA/MemRegion.h +491 -0
  63. package/SVF-osx/svf/include/include/MSSA/MemSSA.h +452 -0
  64. package/SVF-osx/svf/include/include/MSSA/SVFGBuilder.h +98 -0
  65. package/SVF-osx/svf/include/include/MTA/FSMPTA.h +270 -0
  66. package/SVF-osx/svf/include/include/MTA/LockAnalysis.h +517 -0
  67. package/SVF-osx/svf/include/include/MTA/MHP.h +565 -0
  68. package/SVF-osx/svf/include/include/MTA/MTA.h +101 -0
  69. package/SVF-osx/svf/include/include/MTA/MTAResultValidator.h +448 -0
  70. package/SVF-osx/svf/include/include/MTA/MTAStat.h +74 -0
  71. package/SVF-osx/svf/include/include/MTA/PCG.h +229 -0
  72. package/SVF-osx/svf/include/include/MTA/TCT.h +599 -0
  73. package/SVF-osx/svf/include/include/MemoryModel/AbstractPointsToDS.h +316 -0
  74. package/SVF-osx/svf/include/include/MemoryModel/ConditionalPT.h +878 -0
  75. package/SVF-osx/svf/include/include/MemoryModel/LocationSet.h +148 -0
  76. package/SVF-osx/svf/include/include/MemoryModel/MutablePointsToDS.h +1025 -0
  77. package/SVF-osx/svf/include/include/MemoryModel/PersistentPointsToCache.h +463 -0
  78. package/SVF-osx/svf/include/include/MemoryModel/PersistentPointsToDS.h +955 -0
  79. package/SVF-osx/svf/include/include/MemoryModel/PointerAnalysis.h +452 -0
  80. package/SVF-osx/svf/include/include/MemoryModel/PointerAnalysisImpl.h +590 -0
  81. package/SVF-osx/svf/include/include/MemoryModel/PointsTo.h +255 -0
  82. package/SVF-osx/svf/include/include/MemoryModel/SVFLoop.h +164 -0
  83. package/SVF-osx/svf/include/include/SABER/DoubleFreeChecker.h +76 -0
  84. package/SVF-osx/svf/include/include/SABER/FileChecker.h +82 -0
  85. package/SVF-osx/svf/include/include/SABER/LeakChecker.h +124 -0
  86. package/SVF-osx/svf/include/include/SABER/ProgSlice.h +313 -0
  87. package/SVF-osx/svf/include/include/SABER/SaberCheckerAPI.h +166 -0
  88. package/SVF-osx/svf/include/include/SABER/SaberCondAllocator.h +310 -0
  89. package/SVF-osx/svf/include/include/SABER/SaberSVFGBuilder.h +104 -0
  90. package/SVF-osx/svf/include/include/SABER/SrcSnkDDA.h +321 -0
  91. package/SVF-osx/svf/include/include/SABER/SrcSnkSolver.h +186 -0
  92. package/SVF-osx/svf/include/include/SVFIR/PAGBuilderFromFile.h +80 -0
  93. package/SVF-osx/svf/include/include/SVFIR/SVFIR.h +659 -0
  94. package/SVF-osx/svf/include/include/SVFIR/SVFModule.h +233 -0
  95. package/SVF-osx/svf/include/include/SVFIR/SVFStatements.h +1136 -0
  96. package/SVF-osx/svf/include/include/SVFIR/SVFType.h +527 -0
  97. package/SVF-osx/svf/include/include/SVFIR/SVFValue.h +1120 -0
  98. package/SVF-osx/svf/include/include/SVFIR/SVFVariables.h +721 -0
  99. package/SVF-osx/svf/include/include/SVFIR/SymbolTableInfo.h +597 -0
  100. package/SVF-osx/svf/include/include/Util/Annotator.h +180 -0
  101. package/SVF-osx/svf/include/include/Util/BitVector.h +55 -0
  102. package/SVF-osx/svf/include/include/Util/CallGraphBuilder.h +74 -0
  103. package/SVF-osx/svf/include/include/Util/Casting.h +426 -0
  104. package/SVF-osx/svf/include/include/Util/CommandLine.h +530 -0
  105. package/SVF-osx/svf/include/include/Util/CoreBitVector.h +214 -0
  106. package/SVF-osx/svf/include/include/Util/CppUtil.h +81 -0
  107. package/SVF-osx/svf/include/include/Util/CxtStmt.h +501 -0
  108. package/SVF-osx/svf/include/include/Util/DPItem.h +618 -0
  109. package/SVF-osx/svf/include/include/Util/ExtAPI.h +339 -0
  110. package/SVF-osx/svf/include/include/Util/ExtAPI.json +5707 -0
  111. package/SVF-osx/svf/include/include/Util/GraphReachSolver.h +186 -0
  112. package/SVF-osx/svf/include/include/Util/NodeIDAllocator.h +194 -0
  113. package/SVF-osx/svf/include/include/Util/Options.h +266 -0
  114. package/SVF-osx/svf/include/include/Util/PTAStat.h +65 -0
  115. package/SVF-osx/svf/include/include/Util/SCC.h +354 -0
  116. package/SVF-osx/svf/include/include/Util/SVFStat.h +100 -0
  117. package/SVF-osx/svf/include/include/Util/SVFUtil.h +660 -0
  118. package/SVF-osx/svf/include/include/Util/SparseBitVector.h +1202 -0
  119. package/SVF-osx/svf/include/include/Util/ThreadAPI.h +330 -0
  120. package/SVF-osx/svf/include/include/Util/WorkList.h +317 -0
  121. package/SVF-osx/svf/include/include/Util/Z3Expr.h +318 -0
  122. package/SVF-osx/svf/include/include/Util/cJSON.h +300 -0
  123. package/SVF-osx/svf/include/include/Util/iterator.h +407 -0
  124. package/SVF-osx/svf/include/include/Util/iterator_range.h +76 -0
  125. package/SVF-osx/svf/include/include/WPA/Andersen.h +416 -0
  126. package/SVF-osx/svf/include/include/WPA/AndersenPWC.h +160 -0
  127. package/SVF-osx/svf/include/include/WPA/CSC.h +95 -0
  128. package/SVF-osx/svf/include/include/WPA/FlowSensitive.h +317 -0
  129. package/SVF-osx/svf/include/include/WPA/Steensgaard.h +126 -0
  130. package/SVF-osx/svf/include/include/WPA/TypeAnalysis.h +83 -0
  131. package/SVF-osx/svf/include/include/WPA/VersionedFlowSensitive.h +287 -0
  132. package/SVF-osx/svf/include/include/WPA/WPAFSSolver.h +254 -0
  133. package/SVF-osx/svf/include/include/WPA/WPAPass.h +119 -0
  134. package/SVF-osx/svf/include/include/WPA/WPASolver.h +205 -0
  135. package/SVF-osx/svf/include/include/WPA/WPAStat.h +222 -0
  136. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/BasicTypes.h +250 -0
  137. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/BreakConstantExpr.h +94 -0
  138. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/CHGBuilder.h +73 -0
  139. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/DCHG.h +484 -0
  140. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/GEPTypeBridgeIterator.h +183 -0
  141. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/ICFGBuilder.h +106 -0
  142. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMLoopAnalysis.h +61 -0
  143. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMModule.h +360 -0
  144. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMUtil.h +466 -0
  145. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/SVFIRBuilder.h +417 -0
  146. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/SymbolTableBuilder.h +110 -0
  147. package/package.json +1 -1
@@ -0,0 +1,79 @@
1
+ //===- AbstractValue.h --Abstract Value for domains---------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2022> <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
+ * AbstractValue.h
24
+ *
25
+ * Created on: Aug 4, 2022
26
+ * Author: Xiao Cheng, Jiawei Wang
27
+ *
28
+ */
29
+
30
+ #ifndef Z3_EXAMPLE_ABSTRACTVALUE_H
31
+ #define Z3_EXAMPLE_ABSTRACTVALUE_H
32
+
33
+ #include <type_traits>
34
+ #include <string>
35
+ #include "SVFIR/SVFValue.h"
36
+
37
+ namespace SVF
38
+ {
39
+
40
+ class IntervalValue;
41
+
42
+ /*!
43
+ * Base class of abstract value
44
+ */
45
+ class AbstractValue
46
+ {
47
+ public:
48
+ /// Abstract value kind
49
+ enum AbstractValueK
50
+ {
51
+ IntervalK, ConcreteK, AddressK
52
+ };
53
+ private:
54
+ AbstractValueK _kind;
55
+
56
+ public:
57
+ AbstractValue(AbstractValueK kind) : _kind(kind) {}
58
+
59
+ virtual ~AbstractValue() = default;
60
+
61
+ AbstractValue(const AbstractValue &) noexcept = default;
62
+
63
+ AbstractValue(AbstractValue &&) noexcept = default;
64
+
65
+ AbstractValue &operator=(const AbstractValue &) noexcept = default;
66
+
67
+ AbstractValue &operator=(AbstractValue &&) noexcept = default;
68
+
69
+ inline AbstractValueK getAbstractValueKind() const
70
+ {
71
+ return _kind;
72
+ }
73
+
74
+ virtual bool isTop() const = 0;
75
+
76
+ virtual bool isBottom() const = 0;
77
+ }; // end class AbstractValue
78
+ } // end namespace SVF
79
+ #endif //Z3_EXAMPLE_ABSTRACTVALUE_H
@@ -0,0 +1,210 @@
1
+ //===- AddressValue.h ----Address Value Sets-------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2022> <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
+ * AddressValue.h
24
+ *
25
+ * Created on: Jul 9, 2022
26
+ * Author: Xiao Cheng
27
+ *
28
+ */
29
+
30
+ #ifndef Z3_EXAMPLE_ADDRESSVALUE_H
31
+ #define Z3_EXAMPLE_ADDRESSVALUE_H
32
+
33
+ #define AddressMask 0x7f000000
34
+ #define FlippedAddressMask (AddressMask^0xffffffff)
35
+
36
+ #include "AbstractExecution/AbstractValue.h"
37
+ #include "SVFIR/SVFIR.h"
38
+
39
+ namespace SVF
40
+ {
41
+ class AddressValue : public AbstractValue
42
+ {
43
+ public:
44
+ typedef Set<u32_t> AddrSet;
45
+ private:
46
+ AddrSet _addrs;
47
+ public:
48
+ /// Default constructor
49
+ AddressValue() : AbstractValue(AddressK) {}
50
+
51
+ /// Constructor
52
+ AddressValue(const Set<u32_t> &addrs) : AbstractValue(AddressK), _addrs(addrs) {}
53
+
54
+ AddressValue(u32_t addr) : AbstractValue(AddressK), _addrs({addr}) {}
55
+
56
+ /// Default destructor
57
+ ~AddressValue() = default;
58
+
59
+ /// Copy constructor
60
+ AddressValue(const AddressValue &other) : AbstractValue(AddressK), _addrs(other._addrs) {}
61
+
62
+ /// Move constructor
63
+ AddressValue(AddressValue &&other) noexcept: AbstractValue(AddressK), _addrs(std::move(other._addrs)) {}
64
+
65
+ /// Copy operator=
66
+ AddressValue &operator=(const AddressValue &other)
67
+ {
68
+ if (!this->equals(other))
69
+ {
70
+ _addrs = other._addrs;
71
+ AbstractValue::operator=(other);
72
+ }
73
+ return *this;
74
+ }
75
+
76
+ /// Move operator=
77
+ AddressValue &operator=(AddressValue &&other) noexcept
78
+ {
79
+ if (this != &other)
80
+ {
81
+ _addrs = std::move(other._addrs);
82
+ AbstractValue::operator=(std::move(other));
83
+ }
84
+ return *this;
85
+ }
86
+
87
+ bool equals(const AddressValue &rhs) const
88
+ {
89
+ return _addrs == rhs._addrs;
90
+ }
91
+
92
+ bool operator==(const AddressValue &rhs) const
93
+ {
94
+ return _addrs == rhs._addrs;
95
+ }
96
+
97
+ /// Operator !=
98
+ bool operator!=(const AddressValue &rhs) const
99
+ {
100
+ return _addrs != rhs._addrs;
101
+ }
102
+
103
+ AddrSet::const_iterator begin() const
104
+ {
105
+ return _addrs.cbegin();
106
+ }
107
+
108
+ AddrSet::const_iterator end() const
109
+ {
110
+ return _addrs.cend();
111
+ }
112
+
113
+ bool empty() const
114
+ {
115
+ return _addrs.empty();
116
+ }
117
+
118
+ u32_t size() const
119
+ {
120
+ return _addrs.size();
121
+ }
122
+
123
+ std::pair<AddressValue::AddrSet::iterator, bool> insert(u32_t id)
124
+ {
125
+ return _addrs.insert(id);
126
+ }
127
+
128
+ const AddrSet &getVals() const
129
+ {
130
+ return _addrs;
131
+ }
132
+
133
+ void setVals(const AddrSet &vals)
134
+ {
135
+ _addrs = vals;
136
+ }
137
+
138
+ /// Current AddressValue joins with another AddressValue
139
+ void join_with(const AddressValue &other)
140
+ {
141
+ _addrs.insert(other.begin(), other.end());
142
+ }
143
+
144
+ /// Return a intersected AddressValue
145
+ void meet_with(const AddressValue &other)
146
+ {
147
+ AddrSet s;
148
+ for (const auto &id: other._addrs)
149
+ {
150
+ if (_addrs.find(id) != _addrs.end())
151
+ {
152
+ s.insert(id);
153
+ }
154
+ }
155
+ _addrs = std::move(s);
156
+ }
157
+
158
+ /// Return true if the AddressValue contains n
159
+ bool contains(u32_t id) const
160
+ {
161
+ return _addrs.count(id);
162
+ }
163
+
164
+ bool hasIntersect(const AddressValue &other)
165
+ {
166
+ AddressValue v = *this;
167
+ v.meet_with(other);
168
+ return !v.empty();
169
+ }
170
+
171
+ inline bool isTop() const override
172
+ {
173
+ return *this == getVirtualMemAddress(PAG::getPAG()->getBlackHoleObj()->getId());
174
+ }
175
+
176
+ inline bool isBottom() const override
177
+ {
178
+ return empty();
179
+ }
180
+
181
+ inline void setTop()
182
+ {
183
+ *this = getVirtualMemAddress(PAG::getPAG()->getBlackHoleObj()->getId());
184
+ }
185
+
186
+ inline void setBottom()
187
+ {
188
+ _addrs.clear();
189
+ }
190
+
191
+ /// The physical address starts with 0x7f...... + idx
192
+ static inline u32_t getVirtualMemAddress(u32_t idx)
193
+ {
194
+ return AddressMask + idx;
195
+ }
196
+
197
+ /// Check bit value of val start with 0x7F000000, filter by 0xFF000000
198
+ static inline bool isVirtualMemAddress(u32_t val)
199
+ {
200
+ return (val & 0xff000000) == AddressMask;
201
+ }
202
+
203
+ /// Return the internal index if idx is an address otherwise return the value of idx
204
+ static inline u32_t getInternalID(u32_t idx)
205
+ {
206
+ return (idx & FlippedAddressMask);
207
+ }
208
+ };
209
+ } // end namespace SVF
210
+ #endif //Z3_EXAMPLE_ADDRESSVALUE_H
@@ -0,0 +1,223 @@
1
+ //===- ExeState.h ----General Execution States-------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2022> <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
+ * ExeState.h
24
+ *
25
+ * Created on: Aug 4, 2022
26
+ * Author: Xiao Cheng
27
+ *
28
+ */
29
+
30
+
31
+ #ifndef Z3_EXAMPLE_EXESTATE_H
32
+ #define Z3_EXAMPLE_EXESTATE_H
33
+
34
+ #include "AbstractExecution/AddressValue.h"
35
+ #include "AbstractExecution/NumericLiteral.h"
36
+ #include "Util/Z3Expr.h"
37
+
38
+ namespace SVF
39
+ {
40
+
41
+ class IntervalExeState;
42
+
43
+ /*!
44
+ * Base execution state
45
+ */
46
+ class ExeState
47
+ {
48
+ friend class SVFIR2ItvExeState;
49
+
50
+ public:
51
+
52
+ typedef AddressValue VAddrs;
53
+ typedef Map<u32_t, VAddrs> VarToVAddrs;
54
+ /// Execution state kind
55
+ enum ExeState_TYPE
56
+ {
57
+ IntervalK, ConcreteK
58
+ };
59
+ private:
60
+ ExeState_TYPE _kind;
61
+
62
+ public:
63
+ ExeState(ExeState_TYPE kind) : _kind(kind) {}
64
+
65
+ virtual ~ExeState() = default;
66
+
67
+ ExeState(const ExeState &rhs) : _varToVAddrs(rhs._varToVAddrs),
68
+ _locToVAddrs(rhs._locToVAddrs) {}
69
+
70
+ ExeState(ExeState &&rhs) noexcept: _varToVAddrs(std::move(rhs._varToVAddrs)),
71
+ _locToVAddrs(std::move(rhs._locToVAddrs)) {}
72
+
73
+ ExeState &operator=(const ExeState &rhs)
74
+ {
75
+ if(*this != rhs)
76
+ {
77
+ _varToVAddrs = rhs._varToVAddrs;
78
+ _locToVAddrs = rhs._locToVAddrs;
79
+ }
80
+ return *this;
81
+ }
82
+
83
+ ExeState &operator=(ExeState &&rhs) noexcept
84
+ {
85
+ if (this != &rhs)
86
+ {
87
+ _varToVAddrs = std::move(rhs._varToVAddrs);
88
+ _locToVAddrs = std::move(rhs._locToVAddrs);
89
+ }
90
+ return *this;
91
+ }
92
+
93
+ bool operator==(const ExeState &rhs) const;
94
+
95
+ inline bool operator!=(const ExeState &rhs) const
96
+ {
97
+ return !(*this == rhs);
98
+ }
99
+
100
+ bool equals(const ExeState *other) const
101
+ {
102
+ return false;
103
+ }
104
+
105
+ /// Make all value join with the other
106
+ void joinWith(const ExeState &other);
107
+
108
+ /// Make all value meet with the other
109
+ void meetWith(const ExeState &other);
110
+
111
+ virtual u32_t hash() const;
112
+
113
+ /// Print values of all expressions
114
+ virtual void printExprValues(std::ostream &oss) const {}
115
+
116
+ virtual std::string toString() const
117
+ {
118
+ return "";
119
+ }
120
+
121
+ inline ExeState_TYPE getExeStateKind() const
122
+ {
123
+ return _kind;
124
+ }
125
+
126
+ inline virtual const VarToVAddrs &getVarToVAddrs() const
127
+ {
128
+ return _varToVAddrs;
129
+ }
130
+
131
+ inline virtual const VarToVAddrs &getLocToVAddrs() const
132
+ {
133
+ return _locToVAddrs;
134
+ }
135
+
136
+ inline virtual bool inVarToAddrsTable(u32_t id) const
137
+ {
138
+ return _varToVAddrs.find(id) != _varToVAddrs.end();
139
+ }
140
+
141
+ inline virtual bool inLocToAddrsTable(u32_t id) const
142
+ {
143
+ return _locToVAddrs.find(id) != _locToVAddrs.end();
144
+ }
145
+
146
+ virtual VAddrs &getVAddrs(u32_t id)
147
+ {
148
+ return _varToVAddrs[id];
149
+ }
150
+
151
+ inline virtual void storeVAddrs(u32_t addr, const VAddrs &vaddrs)
152
+ {
153
+ assert(isVirtualMemAddress(addr) && "not virtual address?");
154
+ if(isNullPtr(addr)) return;
155
+ u32_t objId = getInternalID(addr);
156
+ _locToVAddrs[objId] = vaddrs;
157
+ }
158
+
159
+ inline virtual VAddrs &loadVAddrs(u32_t addr)
160
+ {
161
+ assert(isVirtualMemAddress(addr) && "not virtual address?");
162
+ u32_t objId = getInternalID(addr);
163
+ return _locToVAddrs[objId];
164
+ }
165
+
166
+ inline bool isNullPtr(u32_t addr)
167
+ {
168
+ return getInternalID(addr) == 0;
169
+ }
170
+
171
+ protected:
172
+ VarToVAddrs _varToVAddrs{{0, getVirtualMemAddress(0)}};
173
+ VarToVAddrs _locToVAddrs;
174
+
175
+ protected:
176
+
177
+ static bool eqVarToVAddrs(const VarToVAddrs &lhs, const VarToVAddrs &rhs)
178
+ {
179
+ if (lhs.size() != rhs.size()) return false;
180
+ for (const auto &item: lhs)
181
+ {
182
+ auto it = rhs.find(item.first);
183
+ if (it == rhs.end())
184
+ return false;
185
+ if (item.second != it->second)
186
+ {
187
+ return false;
188
+ }
189
+ }
190
+ return true;
191
+ }
192
+
193
+ public:
194
+ static z3::context &getContext()
195
+ {
196
+ return Z3Expr::getContext();
197
+ }
198
+
199
+ /// The physical address starts with 0x7f...... + idx
200
+ static inline u32_t getVirtualMemAddress(u32_t idx)
201
+ {
202
+ return AddressValue::getVirtualMemAddress(idx);
203
+ }
204
+
205
+ /// Check bit value of val start with 0x7F000000, filter by 0xFF000000
206
+ static inline bool isVirtualMemAddress(u32_t val)
207
+ {
208
+ return AddressValue::isVirtualMemAddress(val);
209
+ }
210
+
211
+ /// Return the internal index if idx is an address otherwise return the value of idx
212
+ static inline u32_t getInternalID(u32_t idx)
213
+ {
214
+ return AddressValue::getInternalID(idx);
215
+ }
216
+
217
+
218
+ }; // end class ExeState
219
+
220
+
221
+
222
+ } // end namespace SVF
223
+ #endif //Z3_EXAMPLE_EXESTATE_H