46 "symbolic abstraction test",
52 "abstract execution basic function test",
70 outs() <<
"hello print\n";
76 auto start_time = std::chrono::high_resolution_clock::now();
78 auto end_time = std::chrono::high_resolution_clock::now();
79 auto duration = std::chrono::duration_cast<std::chrono::microseconds>(
80 end_time - start_time);
81 outs() <<
"running time of RSY : " << duration.count()
88 auto start_time = std::chrono::high_resolution_clock::now();
90 auto end_time = std::chrono::high_resolution_clock::now();
91 auto duration = std::chrono::duration_cast<std::chrono::microseconds>(
92 end_time - start_time);
93 outs() <<
"running time of Bilateral: " << duration.count()
100 auto start_time = std::chrono::high_resolution_clock::now();
102 auto end_time = std::chrono::high_resolution_clock::now();
103 auto duration = std::chrono::duration_cast<std::chrono::microseconds>(
104 end_time - start_time);
105 outs() <<
"running time of BS : " << duration.count()
106 <<
" microseconds\n";
112 outs() <<
sucMsg(
"\t SUCCESS :") <<
"test1_1 start\n";
125 assert(res ==
Set<u32_t>({0, 1}) &&
"inconsistency occurs");
128 const Z3Expr& relExpr = relation[1];
130 const Z3Expr& phi = (relExpr && initExpr).simplify();
135 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
138 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
146 outs() <<
"test1_2 start\n";
160 assert(res ==
Set<u32_t>({0, 1}) &&
"inconsistency occurs");
163 const Z3Expr& relExpr = relation[1];
165 const Z3Expr& phi = (relExpr && initExpr).simplify();
170 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
173 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
181 outs() <<
"test2_1 start\n";
194 itv[2] = itv[1].getInterval() - itv[0].getInterval();
198 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
201 const Z3Expr& relExpr = relation[2] && relation[1];
203 const Z3Expr& phi = (relExpr && initExpr).simplify();
208 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
211 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
223 outs() <<
"test2_2 start\n";
236 itv[2] = itv[1].getInterval() - itv[0].getInterval();
241 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
244 const Z3Expr& relExpr = relation[2] && relation[1];
246 const Z3Expr& phi = (relExpr && initExpr).simplify();
251 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
254 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
266 outs() <<
"test2_3 start\n";
279 itv[2] = itv[1].getInterval() - itv[0].getInterval();
284 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
287 const Z3Expr& relExpr = relation[2] && relation[1];
289 const Z3Expr& phi = (relExpr && initExpr).simplify();
294 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
297 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
309 outs() <<
"test2_4 start\n";
322 itv[2] = itv[1].getInterval() - itv[0].getInterval();
327 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
330 const Z3Expr& relExpr = relation[2] && relation[1];
332 const Z3Expr& phi = (relExpr && initExpr).simplify();
337 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
340 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
352 outs() <<
"test2_5 start\n";
365 itv[2] = itv[1].getInterval() - itv[0].getInterval();
370 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
373 const Z3Expr& relExpr = relation[2] && relation[1];
375 const Z3Expr& phi = (relExpr && initExpr).simplify();
380 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
383 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
395 outs() <<
"test3_1 start\n";
408 itv[2] = itv[1].getInterval() / itv[0].getInterval();
412 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
415 const Z3Expr& relExpr = relation[2] && relation[1];
417 const Z3Expr& phi = (relExpr && initExpr).simplify();
422 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
425 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
437 outs() <<
"test3_2 start\n";
450 itv[2] = itv[1].getInterval() / itv[0].getInterval();
454 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
457 const Z3Expr& relExpr = relation[2] && relation[1];
459 const Z3Expr& phi = (relExpr && initExpr).simplify();
464 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
467 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
479 outs() <<
"test3_3 start\n";
492 itv[2] = itv[1].getInterval() / itv[0].getInterval();
496 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
499 const Z3Expr& relExpr = relation[2] && relation[1];
501 const Z3Expr& phi = (relExpr && initExpr).simplify();
506 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
509 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
520 outs() <<
"test3_4 start\n";
533 itv[2] = itv[1].getInterval() / itv[0].getInterval();
537 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
540 const Z3Expr& relExpr = relation[2] && relation[1];
542 const Z3Expr& phi = (relExpr && initExpr).simplify();
547 assert(resRSY == resBS && resBS == resBilateral &&
"inconsistency occurs");
550 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
562 outs() <<
"test4_1 start\n";
575 itv[2] = itv[1].getInterval() / itv[0].getInterval();
579 assert(res ==
Set<u32_t>({0, 1, 2}) &&
"inconsistency occurs");
582 const Z3Expr& relExpr = relation[2] && relation[1];
584 const Z3Expr& phi = (relExpr && initExpr).simplify();
586 outs() <<
"rsy done\n";
588 outs() <<
"bilateral done\n";
590 outs() <<
"bs done\n";
595 outs() << r.first <<
" " << r.second.getInterval() <<
"\n";
622 outs() <<
"start top\n";
636 const s64_t intMin = std::numeric_limits<s64_t>::min();
637 const s64_t intMax = std::numeric_limits<s64_t>::max();
646 assert((-minValue).is_plus_infinity());
647 assert(abs(minValue).is_plus_infinity());
650 assert((minusOne +
BoundedInt(-intMax)).equal(minValue));
651 assert((maxValue + one).is_plus_infinity());
652 assert((minValue + minusOne).is_minus_infinity());
655 assert((minValue - minValue).equal(zero));
656 assert((maxValue - maxValue).equal(zero));
657 assert((maxValue - minValue).is_plus_infinity());
658 assert((minValue - maxValue).is_minus_infinity());
661 assert((one * minValue).equal(minValue));
662 assert((minValue * one).equal(minValue));
663 assert((minusOne * minValue).is_plus_infinity());
667 assert((minValue / one).equal(minValue));
668 assert((minValue / minusOne).is_plus_infinity());
669 assert((minValue % minusOne).equal(zero));
674 const s64_t intMin = std::numeric_limits<s64_t>::min();
675 const s64_t intMax = std::numeric_limits<s64_t>::max();
683 assert(issueResult.
equals(issueExpected));
689 assert(reverseResult.
equals(reverseExpected));
913 for (
auto addr : as[3].getAddrs()) as.
store(addr, as[1]);
914 for (
auto addr : as[4].getAddrs()) as.
store(addr, as[2]);
918 for (
auto addr : as[3].getAddrs()) v3.
join_with(as.
load(addr));
919 for (
auto addr : as[4].getAddrs()) v4.
join_with(as.
load(addr));
929 char **arg_value =
new char *[argc + extraArgc];
930 for (; arg_num < argc; ++arg_num)
932 arg_value[arg_num] = argv[arg_num];
935 arg_value[arg_num++] = (
char*)
"-model-consts=true";
936 arg_value[arg_num++] = (
char*)
"-model-arrays=true";
937 arg_value[arg_num++] = (
char*)
"-pre-field-sensitive=false";
938 assert(arg_num == (argc + extraArgc) &&
"more extra arguments? Change the value of extraArgc");
940 std::vector<std::string> moduleNameVec;
942 arg_num, arg_value,
"Static Symbolic Execution",
"[options] <input-bitcode...>"
971 ae.
addDetector(std::make_unique<BufOverflowDetector>());
973 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)
void testBoundedIntBoundaryArithmetic()
void testIntervalBoundaryArithmetic()
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(PAG *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
static void releaseAndersenWaveDiff()
A class representing a bounded 64-bit integer.
static BoundedInt plus_infinity()
static BoundedInt minus_infinity()
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.
bool equals(const IntervalValue &other) const
Equality comparison.
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
virtual PAG * build()
Start building PAG here.
void updateCallGraph(CallGraph *callgraph)
connect PAG edges based on callgraph
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)
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