10
10
#define KLEE_INTERPRETER_H
11
11
12
12
#include " TerminationTypes.h"
13
+ #include " klee/Module/Annotation.h"
13
14
14
15
#include " klee/Module/SarifReport.h"
15
16
@@ -32,6 +33,7 @@ class BasicBlock;
32
33
class Function ;
33
34
class LLVMContext ;
34
35
class Module ;
36
+ class Type ;
35
37
class raw_ostream ;
36
38
class raw_fd_ostream ;
37
39
} // namespace llvm
@@ -66,6 +68,13 @@ using FLCtoOpcode = std::unordered_map<
66
68
std::unordered_map<
67
69
unsigned , std::unordered_map<unsigned , std::unordered_set<unsigned >>>>;
68
70
71
+ enum class MockStrategy {
72
+ None, // No mocks are generated
73
+ Naive, // For each function call new symbolic value is generated
74
+ Deterministic, // Each function is treated as uninterpreted function in SMT.
75
+ // Compatible with Z3 solver only
76
+ };
77
+
69
78
class Interpreter {
70
79
public:
71
80
enum class GuidanceKind {
@@ -82,21 +91,32 @@ class Interpreter {
82
91
std::string LibraryDir;
83
92
std::string EntryPoint;
84
93
std::string OptSuffix;
94
+ std::string MainCurrentName;
95
+ std::string MainNameAfterMock;
96
+ std::string AnnotationsFile;
85
97
bool Optimize;
86
98
bool Simplify;
87
99
bool CheckDivZero;
88
100
bool CheckOvershift;
101
+ bool AnnotateOnlyExternal;
89
102
bool WithFPRuntime;
90
103
bool WithPOSIXRuntime;
91
104
92
105
ModuleOptions (const std::string &_LibraryDir,
93
106
const std::string &_EntryPoint, const std::string &_OptSuffix,
94
- bool _Optimize, bool _Simplify, bool _CheckDivZero,
95
- bool _CheckOvershift, bool _WithFPRuntime,
107
+ const std::string &_MainCurrentName,
108
+ const std::string &_MainNameAfterMock,
109
+ const std::string &_AnnotationsFile, bool _Optimize,
110
+ bool _Simplify, bool _CheckDivZero, bool _CheckOvershift,
111
+ bool _AnnotateOnlyExternal, bool _WithFPRuntime,
96
112
bool _WithPOSIXRuntime)
97
113
: LibraryDir(_LibraryDir), EntryPoint(_EntryPoint),
98
- OptSuffix (_OptSuffix), Optimize(_Optimize), Simplify(_Simplify),
99
- CheckDivZero(_CheckDivZero), CheckOvershift(_CheckOvershift),
114
+ OptSuffix (_OptSuffix), MainCurrentName(_MainCurrentName),
115
+ MainNameAfterMock(_MainNameAfterMock),
116
+ AnnotationsFile(_AnnotationsFile), Optimize(_Optimize),
117
+ Simplify(_Simplify), CheckDivZero(_CheckDivZero),
118
+ CheckOvershift(_CheckOvershift),
119
+ AnnotateOnlyExternal(_AnnotateOnlyExternal),
100
120
WithFPRuntime(_WithFPRuntime), WithPOSIXRuntime(_WithPOSIXRuntime) {}
101
121
};
102
122
@@ -115,10 +135,11 @@ class Interpreter {
115
135
unsigned MakeConcreteSymbolic;
116
136
GuidanceKind Guidance;
117
137
nonstd::optional<SarifReport> Paths;
138
+ enum MockStrategy MockStrategy;
118
139
119
140
InterpreterOptions (nonstd::optional<SarifReport> Paths)
120
141
: MakeConcreteSymbolic(false ), Guidance(GuidanceKind::NoGuidance),
121
- Paths (std::move(Paths)) {}
142
+ Paths (std::move(Paths)), MockStrategy(MockStrategy::None) {}
122
143
};
123
144
124
145
protected:
@@ -141,13 +162,13 @@ class Interpreter {
141
162
// / module
142
163
// / \return The final module after it has been optimized, checks
143
164
// / inserted, and modified for interpretation.
144
- virtual llvm::Module *
145
- setModule ( std::vector<std::unique_ptr<llvm::Module>> &userModules,
146
- std::vector<std::unique_ptr<llvm::Module>> &libsModules,
147
- const ModuleOptions &opts,
148
- std::set<std::string> &&mainModuleFunctions ,
149
- std::set<std::string> &&mainModuleGlobals ,
150
- FLCtoOpcode &&origInstructions ) = 0 ;
165
+ virtual llvm::Module *setModule (
166
+ std::vector<std::unique_ptr<llvm::Module>> &userModules,
167
+ std::vector<std::unique_ptr<llvm::Module>> &libsModules,
168
+ const ModuleOptions &opts, std::set<std::string> &&mainModuleFunctions ,
169
+ std::set<std::string> &&mainModuleGlobals, FLCtoOpcode &&origInstructions ,
170
+ const std::set<std::string> &ignoredExternals ,
171
+ std::vector<std::pair<std::string, std::string>> redefinitions ) = 0;
151
172
152
173
// supply a tree stream writer which the interpreter will use
153
174
// to record the concrete path (as a stream of '0' and '1' bytes).
0 commit comments