45 "symbolic abstraction test",
51 "abstract execution basic function test",
69 outs() <<
"hello print\n";
75 auto start_time = std::chrono::high_resolution_clock::now();
77 auto end_time = std::chrono::high_resolution_clock::now();
78 auto duration = std::chrono::duration_cast<std::chrono::microseconds>(
79 end_time - start_time);
80 outs() <<
"running time of RSY : " << duration.count()
87 auto start_time = std::chrono::high_resolution_clock::now();
89 auto end_time = std::chrono::high_resolution_clock::now();
90 auto duration = std::chrono::duration_cast<std::chrono::microseconds>(
91 end_time - start_time);
92 outs() <<
"running time of Bilateral: " << duration.count()
99 auto start_time = std::chrono::high_resolution_clock::now();
101 auto end_time = std::chrono::high_resolution_clock::now();
102 auto duration = std::chrono::duration_cast<std::chrono::microseconds>(
103 end_time - start_time);
104 outs() <<
"running time of BS : " << duration.count()
105 <<
" microseconds\n";
111 outs() <<
sucMsg(
"\t SUCCESS :") <<
"test1_1 start\n";
124 assert(res ==
Set<u32_t>({0, 1}) &&
"inconsistency occurs");
127 const Z3Expr& relExpr = relation[1];
129 const Z3Expr& phi = (relExpr && initExpr).simplify();
134 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
137 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
145 outs() <<
"test1_2 start\n";
159 assert(res ==
Set<u32_t>({0, 1}) &&
"inconsistency occurs");
162 const Z3Expr& relExpr = relation[1];
164 const Z3Expr& phi = (relExpr && initExpr).simplify();
169 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
172 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
180 outs() <<
"test2_1 start\n";
193 itv[2] = itv[1].getInterval() - itv[0].getInterval();
197 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
200 const Z3Expr& relExpr = relation[2] && relation[1];
202 const Z3Expr& phi = (relExpr && initExpr).simplify();
207 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
210 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
222 outs() <<
"test2_2 start\n";
235 itv[2] = itv[1].getInterval() - itv[0].getInterval();
240 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
243 const Z3Expr& relExpr = relation[2] && relation[1];
245 const Z3Expr& phi = (relExpr && initExpr).simplify();
250 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
253 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
265 outs() <<
"test2_3 start\n";
278 itv[2] = itv[1].getInterval() - itv[0].getInterval();
283 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
286 const Z3Expr& relExpr = relation[2] && relation[1];
288 const Z3Expr& phi = (relExpr && initExpr).simplify();
293 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
296 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
308 outs() <<
"test2_4 start\n";
321 itv[2] = itv[1].getInterval() - itv[0].getInterval();
326 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
329 const Z3Expr& relExpr = relation[2] && relation[1];
331 const Z3Expr& phi = (relExpr && initExpr).simplify();
336 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
339 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
351 outs() <<
"test2_5 start\n";
364 itv[2] = itv[1].getInterval() - itv[0].getInterval();
369 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
372 const Z3Expr& relExpr = relation[2] && relation[1];
374 const Z3Expr& phi = (relExpr && initExpr).simplify();
379 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
382 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
394 outs() <<
"test3_1 start\n";
407 itv[2] = itv[1].getInterval() / itv[0].getInterval();
411 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
414 const Z3Expr& relExpr = relation[2] && relation[1];
416 const Z3Expr& phi = (relExpr && initExpr).simplify();
421 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
424 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
436 outs() <<
"test3_2 start\n";
449 itv[2] = itv[1].getInterval() / itv[0].getInterval();
453 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
456 const Z3Expr& relExpr = relation[2] && relation[1];
458 const Z3Expr& phi = (relExpr && initExpr).simplify();
463 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
466 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
478 outs() <<
"test3_3 start\n";
491 itv[2] = itv[1].getInterval() / itv[0].getInterval();
495 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
498 const Z3Expr& relExpr = relation[2] && relation[1];
500 const Z3Expr& phi = (relExpr && initExpr).simplify();
505 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
508 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
519 outs() <<
"test3_4 start\n";
532 itv[2] = itv[1].getInterval() / itv[0].getInterval();
536 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
539 const Z3Expr& relExpr = relation[2] && relation[1];
541 const Z3Expr& phi = (relExpr && initExpr).simplify();
546 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
549 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
561 outs() <<
"test4_1 start\n";
574 itv[2] = itv[1].getInterval() / itv[0].getInterval();
578 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
581 const Z3Expr& relExpr = relation[2] && relation[1];
583 const Z3Expr& phi = (relExpr && initExpr).simplify();
585 outs() <<
"rsy done\n";
587 outs() <<
"bilateral done\n";
589 outs() <<
"bs done\n";
594 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
621 outs() <<
"start top\n";
842 for (
auto addr : as[3].getAddrs()) as.
store(addr, as[1]);
843 for (
auto addr : as[4].getAddrs()) as.
store(addr, as[2]);
847 for (
auto addr : as[3].getAddrs()) v3.
join_with(as.
load(addr));
848 for (
auto addr : as[4].getAddrs()) v4.
join_with(as.
load(addr));
858 char **arg_value =
new char *[argc + extraArgc];
859 for (; arg_num < argc; ++arg_num)
861 arg_value[arg_num] = argv[arg_num];
864 arg_value[arg_num++] = (
char*)
"-model-consts=true";
865 arg_value[arg_num++] = (
char*)
"-model-arrays=true";
866 arg_value[arg_num++] = (
char*)
"-pre-field-sensitive=false";
867 assert(arg_num == (argc + extraArgc) &&
"more extra arguments? Change the value of extraArgc");
869 std::vector<std::string> moduleNameVec;
871 arg_num, arg_value,
"Static Symbolic Execution",
"[options] <input-bitcode...>"
898 ae.
addDetector(std::make_unique<BufOverflowDetector>());
900 ae.
addDetector(std::make_unique<NullptrDerefDetector>());
int main(int argc, char **argv)
static Option< bool > SYMABS("symabs", "symbolic abstraction test", false)
static Option< bool > AETEST("aetest", "abstract execution basic function test", false)
static std::vector< std::string > parseOptions(int argc, char *argv[], std::string description, std::string callFormat)
virtual void runOnModule()
void addDetector(std::unique_ptr< AEDetector > detector)
static AbstractInterpretation & getAEInstance()
const VarToAbsValMap & getVarToVal() const
get var2val map
void store(u32_t addr, const AbstractValue &val)
void printAbstractState() const
bool eqVarToValMap(const VarToAbsValMap &lhs, const VarToAbsValMap &rhs) const
virtual AbstractValue & load(u32_t addr)
Map< u32_t, AbstractValue > VarToAbsValMap
AbstractState sliceState(Set< u32_t > &sl)
Copy some values and return a new IntervalExeState.
void join_with(const AbstractValue &other)
bool equals(const AbstractValue &rhs) const
static AndersenWaveDiff * createAndersenWaveDiff(SVFIR *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
static void releaseAndersenWaveDiff()
static BoundedInt minus_infinity()
Get minus infinity -inf.
static IntervalValue bottom()
Create the bottom IntervalValue [+inf, -inf].
static BoundedInt plus_infinity()
Get plus infinity +inf.
static IntervalValue top()
Create the IntervalValue [-inf, +inf].
static LLVMModuleSet * getLLVMModuleSet()
static void releaseLLVMModuleSet()
static void buildSVFModule(Module &mod)
static const Option< bool > NullDerefCheck
nullptr dereference checker, Default: false
static const Option< bool > BufferOverflowCheck
buffer overflow checker, Default: false
CallGraph * getCallGraph() const
Return call graph.
void extractSubVars(const Z3Expr &expr, Set< u32_t > &res)
Extract sub SVFVar IDs of a Z3Expr.
Z3Expr gamma_hat(const AbstractState &exeState) const
Return Z3Expr according to valToValMap.
AbstractState RSY(const AbstractState &domain, const Z3Expr &phi)
AbstractState bilateral(const AbstractState &domain, const Z3Expr &phi, u32_t descend_check=0)
AbstractState BS(const AbstractState &domain, const Z3Expr &phi)
void updateCallGraph(CallGraph *callgraph)
connect PAG edges based on callgraph
virtual SVFIR * build()
Start building SVFIR here.
static z3::context & getContext()
Get z3 context, singleton design here to make sure we only have one context.
AbstractState BS_time(AbstractState &inv, const Z3Expr &phi, RelationSolver &rs)
void testRelExeState1_2()
SymblicAbstractionTest()=default
void testRelExeState2_4()
void testRelExeState2_1()
void testRelExeState2_2()
void testRelExeState3_2()
~SymblicAbstractionTest()=default
void testRelExeState2_3()
void testRelExeState3_3()
AbstractState RSY_time(AbstractState &inv, const Z3Expr &phi, RelationSolver &rs)
void testRelExeState4_1()
void testRelExeState2_5()
void testRelExeState3_1()
void testRelExeState1_1()
AbstractState Bilateral_time(AbstractState &inv, const Z3Expr &phi, RelationSolver &rs)
static z3::context & getContext()
void testRelExeState3_4()
std::string sucMsg(const std::string &msg)
Returns successful message by converting a string into green string output.
std::ostream & outs()
Overwrite llvm::outs().
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set