1010#define KLEE_INTERPRETER_H
1111
1212#include " TerminationTypes.h"
13+ #include " klee/Module/Annotation.h"
1314
1415#include " klee/Module/SarifReport.h"
1516
@@ -32,6 +33,7 @@ class BasicBlock;
3233class Function ;
3334class LLVMContext ;
3435class Module ;
36+ class Type ;
3537class raw_ostream ;
3638class raw_fd_ostream ;
3739} // namespace llvm
@@ -66,6 +68,13 @@ using FLCtoOpcode = std::unordered_map<
6668 std::unordered_map<
6769 unsigned , std::unordered_map<unsigned , std::unordered_set<unsigned >>>>;
6870
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+
6978class Interpreter {
7079public:
7180 enum class GuidanceKind {
@@ -82,21 +91,32 @@ class Interpreter {
8291 std::string LibraryDir;
8392 std::string EntryPoint;
8493 std::string OptSuffix;
94+ std::string MainCurrentName;
95+ std::string MainNameAfterMock;
96+ std::string AnnotationsFile;
8597 bool Optimize;
8698 bool Simplify;
8799 bool CheckDivZero;
88100 bool CheckOvershift;
101+ bool AnnotateOnlyExternal;
89102 bool WithFPRuntime;
90103 bool WithPOSIXRuntime;
91104
92105 ModuleOptions (const std::string &_LibraryDir,
93106 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,
96112 bool _WithPOSIXRuntime)
97113 : 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),
100120 WithFPRuntime(_WithFPRuntime), WithPOSIXRuntime(_WithPOSIXRuntime) {}
101121 };
102122
@@ -115,10 +135,11 @@ class Interpreter {
115135 unsigned MakeConcreteSymbolic;
116136 GuidanceKind Guidance;
117137 nonstd::optional<SarifReport> Paths;
138+ enum MockStrategy MockStrategy;
118139
119140 InterpreterOptions (nonstd::optional<SarifReport> Paths)
120141 : MakeConcreteSymbolic(false ), Guidance(GuidanceKind::NoGuidance),
121- Paths (std::move(Paths)) {}
142+ Paths (std::move(Paths)), MockStrategy(MockStrategy::None) {}
122143 };
123144
124145protected:
@@ -141,13 +162,13 @@ class Interpreter {
141162 // / module
142163 // / \return The final module after it has been optimized, checks
143164 // / 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;
151172
152173 // supply a tree stream writer which the interpreter will use
153174 // to record the concrete path (as a stream of '0' and '1' bytes).
0 commit comments