-
Notifications
You must be signed in to change notification settings - Fork 1
/
prompt_diff_loopbound.patch
2933 lines (2815 loc) · 117 KB
/
prompt_diff_loopbound.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/include/klee/Constraints.h b/include/klee/Constraints.h
index 87069f8..eb35d03 100755
--- a/include/klee/Constraints.h
+++ b/include/klee/Constraints.h
@@ -44,6 +44,8 @@ public:
ref<Expr> simplifyExpr(ref<Expr> e) const;
void addConstraint(ref<Expr> e);
+ //muqi
+ void dump_constraints();
bool empty() const {
return constraints.empty();
diff --git a/include/klee/ExecutionState.h b/include/klee/ExecutionState.h
index fa88891..a9ace73 100755
--- a/include/klee/ExecutionState.h
+++ b/include/klee/ExecutionState.h
@@ -335,6 +335,7 @@ public:
/// @brief Weight assigned for importance of this state. Can be
/// used for searchers to decide what paths to explore
double weight;
+ std::vector< llvm::Instruction*> history_br_instructions;
/// @brief Exploration depth, i.e., number of times KLEE branched for this state
unsigned depth;
diff --git a/include/klee/Expr.h b/include/klee/Expr.h
index 212053b..ac0c534 100755
--- a/include/klee/Expr.h
+++ b/include/klee/Expr.h
@@ -24,6 +24,10 @@
#include <vector>
#include <map>
+#include <string>
+#include <mutex>
+
+
namespace llvm {
class Type;
class raw_ostream;
@@ -38,6 +42,9 @@ class ObjectState;
template<class T> class ref;
+//muqi
+extern std::string klee_muqi_compare_file_path;
+extern std::mutex mtx;
/// Class representing symbolic expressions.
/**
@@ -1001,9 +1008,11 @@ public:
private:
llvm::APInt value;
- ConstantExpr(const llvm::APInt &v) : value(v) {}
+ //ConstantExpr(const llvm::APInt &v) : value(v) {}
public:
+ //muqi
+ ConstantExpr(const llvm::APInt &v) : value(v) {}
~ConstantExpr() {}
Width getWidth() const { return value.getBitWidth(); }
diff --git a/include/klee/Internal/Support/ErrorHandling.h b/include/klee/Internal/Support/ErrorHandling.h
index 2945169..3d8588a 100755
--- a/include/klee/Internal/Support/ErrorHandling.h
+++ b/include/klee/Internal/Support/ErrorHandling.h
@@ -16,6 +16,17 @@
#endif
#endif
+//muqi
+#include "klee/Internal/Support/ErrorHandling.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/IR/Instruction.h"
+#include "llvm/IR/Function.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/raw_ostream.h"
+
+
#include <stdio.h>
namespace klee {
@@ -23,6 +34,11 @@ namespace klee {
extern FILE *klee_warning_file;
extern FILE *klee_message_file;
+//muqi
+extern FILE *klee_muqi_file;
+extern FILE *klee_muqi_compare_file;
+extern FILE *klee_muqi_compare_file_test;
+
/// Print "KLEE: ERROR: " followed by the msg in printf format and a
/// newline on stderr and to warnings.txt, then exit with an error.
void klee_error(const char *msg, ...)
@@ -32,6 +48,15 @@ void klee_error(const char *msg, ...)
/// newline on stderr and to messages.txt.
void klee_message(const char *msg, ...) __attribute__((format(printf, 1, 2)));
+
+//muqi
+void klee_muqi(const char *msg, ...) __attribute__((format(printf, 1, 2)));
+
+void klee_muqi_compare(const char *msg, ...) __attribute__((format(printf, 1, 2)));
+
+void klee_muqi_compare_test(const char *function_name, const char *msg, ...);
+
+
/// Print "KLEE: " followed by the msg in printf format and a
/// newline to messages.txt.
void klee_message_to_file(const char *msg, ...)
diff --git a/lib/Core/AddressSpace.cpp b/lib/Core/AddressSpace.cpp
index 62f1fa7..2efced4 100755
--- a/lib/Core/AddressSpace.cpp
+++ b/lib/Core/AddressSpace.cpp
@@ -12,6 +12,8 @@
#include "Memory.h"
#include "TimingSolver.h"
+#include "klee/Internal/Support/ErrorHandling.h"
+
#include "klee/Expr.h"
#include "klee/TimerStatIncrementer.h"
diff --git a/lib/Core/ExecutionState.cpp b/lib/Core/ExecutionState.cpp
index c48e1a5..50a0c8f 100755
--- a/lib/Core/ExecutionState.cpp
+++ b/lib/Core/ExecutionState.cpp
@@ -22,6 +22,10 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"
+//muqi
+#include "llvm/ADT/APInt.h"
+#include "klee/Internal/Support/ErrorHandling.h"
+
#include <iomanip>
#include <sstream>
#include <cassert>
@@ -244,6 +248,24 @@ ExecutionState::~ExecutionState() {
cur_mergehandler->removeOpenState(this);
}
+ //muqi
+ klee_muqi("Inside ExecutionState::~ExecutionState() \n");
+ int temp = 0;
+ klee_muqi("the address of stack will be poped are: \n");
+ for (std::vector<StackFrame>::iterator it = stack.begin() ; it != stack.end(); ++it){
+ //(*it).locals->value.get()->dump();
+ for (std::vector<const MemoryObject *>::iterator temp_it = (*it).allocas.begin(); temp_it != (*it).allocas.end(); ++ temp_it){
+ auto temp_address = reinterpret_cast<std::uint8_t*>((*temp_it)->address);
+ llvm::APInt outputtemp1 = llvm::APInt(Context::get().getPointerWidth(), (*temp_it)->address);
+ ConstantExpr *output = new ConstantExpr(outputtemp1);
+ //output->dump();
+ klee_muqi("address of mo memoryobject is %u\n",temp_address);
+ }
+ temp ++;
+ }
+ klee_muqi("the number of stackframe will be poped is %d\n",temp);
+ klee_muqi("double check by stack.size, the number of stackframe is %d", stack.size());
+ klee_muqi("\n End of ExecutionState::~ExecutionState() printing \n");
while (!stack.empty()) popFrame();
}
@@ -834,8 +856,9 @@ void ExecutionState::updateLCMState() {
}
else if (seq->getType() == identifier) {
if (curr != 0 ) {
- Identifier *id = dynamic_cast<Identifier*>(seq);
- assert(id);
+ // Identifier *id = dynamic_cast<Identifier*>(seq);
+ Identifier *id = static_cast<Identifier*>(seq);
+ assert(id);
llvm::outs() << " next step " << id->getValue() << " to execute " << "\n";
Function *func = moduleHandle->getFunction(id->getValue());
//initiateAsync(func);
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index 54e659c..04856cf 100755
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -82,6 +82,18 @@
#include "klee/Internal/Support/CompressionStream.h"
#endif
+//muqi
+#include "llvm/ADT/APInt.h"
+#include "llvm/IR/Metadata.h"
+#include "llvm/IR/DebugInfoMetadata.h"
+#ifdef ENABLE_Z3
+#include "./Z3Builder.h"
+#endif
+#define Muqi_DEBUG;
+#define Muqi_support_foreverloop;
+#define Muqi_external_call;
+#define Muqi_out_of_bound_pointer;
+
#include <cassert>
#include <algorithm>
#include <iomanip>
@@ -1123,6 +1135,7 @@ bool isLoopBoundExcluded(std::string s, std::string fname) {
return false;
}
+/*
void addForkFreq(ExecutionState &state, std::string inst, bool isTrue) {
long s = (long)&state;
std::map<std::string, unsigned> m;
@@ -1165,7 +1178,25 @@ unsigned getForkFreq(ExecutionState &state, std::string inst, bool isTrue) {
else return 0;
}
}
+*/
+void addForkFreq(ExecutionState *state, llvm::Instruction* inst) {
+ state->history_br_instructions.push_back(inst);
+}
+unsigned getForkFreq(ExecutionState &state, llvm::Instruction* inst) {
+ unsigned result = 0;
+ for (auto i = state.history_br_instructions.begin(); i != state.history_br_instructions.end(); ++i){
+ if (*i == inst){
+ result= result + 1;
+ }
+ }
+ return result;
+}
+void showForkfreq(ExecutionState &state){
+ for (auto i = state.history_br_instructions.begin(); i != state.history_br_instructions.end(); ++i){
+ llvm::errs() << "\nhistory instruction " << **i << "\n";
+ }
+}
std::string getAsyncFunction(std::string fn) {
@@ -1806,7 +1837,13 @@ bool isAllocTypeLazyInit(Type *t, bool &single, int &count) {
}
}
if (t->getPrimitiveSizeInBits()) {
- count = primArraySize;
+ //count = primArraySize;
+
+ //muqi 256&8 we want the size of array be 256 bytes
+ count == 256*8/t->getPrimitiveSizeInBits();
+ if (count == 0)
+ count = 1;
+
single = false;
return true;
}
@@ -1849,7 +1886,14 @@ void collectEmbeddedPointerTypes(Type *t, std::vector<std::string> &lazyTypes, s
else if (t->getPrimitiveSizeInBits()) {
if (pointerType) {
lazyTypes.push_back(rso.str());
- lazyInitNumInstances[rso.str()] = primArraySize;
+ //lazyInitNumInstances[rso.str()] = primArraySize;
+
+ //muqi 256&8 we want the size of array be 256 bytes
+ int temp_count = 256*8/t->getPrimitiveSizeInBits();
+ if (temp_count == 0)
+ temp_count = 1;
+
+ lazyInitNumInstances[rso.str()] = temp_count;
}
}
@@ -2590,9 +2634,14 @@ void Executor::branch(ExecutionState &state,
addConstraint(*result[i], conditions[i]);
}
+//muqi
Executor::StatePair
Executor::fork(ExecutionState ¤t, ref<Expr> condition, bool isInternal) {
+ KInstruction *currentInstruction = current.prevPC;
+ Instruction *i = currentInstruction->inst;
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Executor::StatePair Executor::fork");
+ klee_muqi("in the fork of Executor::\n");
Solver::Validity res;
std::map< ExecutionState*, std::vector<SeedInfo> >::iterator it =
@@ -2621,6 +2670,10 @@ Executor::fork(ExecutionState ¤t, ref<Expr> condition, bool isInternal) {
bool success = solver->getValue(current, condition, value);
assert(success && "FIXME: Unhandled solver failure");
(void) success;
+ //start of symbolic execution 151515
+ klee_muqi("in if condition of !isSeeding && !isa<ConstantExpr>(condition) && \n");
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nIn if condition of !isSeeding && !isa<ConstantExpr>(condition) &&");
+
addConstraint(current, EqExpr::create(value, condition));
current.lastConstraint = EqExpr::create(value, condition);
condition = value;
@@ -2653,10 +2706,14 @@ Executor::fork(ExecutionState ¤t, ref<Expr> condition, bool isInternal) {
// add constraints
if(branch) {
res = Solver::True;
+ klee_muqi("in if condition of isSeeding, branch is true \n");
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside fork, First branch");
addConstraint(current, condition);
current.lastConstraint = condition;
} else {
res = Solver::False;
+ klee_muqi("in if condition of isSeeding, branch is false \n");
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside fork, Second branch");
addConstraint(current, Expr::createIsZero(condition));
current.lastConstraint = Expr::createIsZero(condition);
}
@@ -2680,10 +2737,16 @@ Executor::fork(ExecutionState ¤t, ref<Expr> condition, bool isInternal) {
TimerStatIncrementer timer(stats::forkTime);
if (theRNG.getBool()) {
+ klee_muqi("in if condition of not isSeeding, branch is true \n");
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside fork, First branch");
+
addConstraint(current, condition);
res = Solver::True;
current.lastConstraint = condition;
} else {
+ klee_muqi("in if condition of not isSeeding, branch is false \n");
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside fork, Second branch");
+
addConstraint(current, Expr::createIsZero(condition));
res = Solver::False;
current.lastConstraint = Expr::createIsZero(condition);
@@ -2718,6 +2781,9 @@ Executor::fork(ExecutionState ¤t, ref<Expr> condition, bool isInternal) {
assert(trueSeed || falseSeed);
res = trueSeed ? Solver::True : Solver::False;
+ klee_muqi("in Fix branch in only-replay-seed mode, if we don't have both true \n");
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside fork, Fix branch in only-replay-seed mode");
+
addConstraint(current, trueSeed ? condition : Expr::createIsZero(condition));
if (trueSeed)
current.lastConstraint = condition;
@@ -2816,8 +2882,19 @@ Executor::fork(ExecutionState ¤t, ref<Expr> condition, bool isInternal) {
}
}
+ #ifndef Muqi_support_foreverloop
+ klee_muqi("Add constraint for trueStatement final\n");
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nAdd constraint for trueStatement ");
+ #endif
+
addConstraint(*trueState, condition);
trueState->lastConstraint = condition;
+
+ #ifndef Muqi_support_foreverloop
+ klee_muqi("Add constraint for falseStatement final\n");
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nAdd constraint for falseStatement ");
+ #endif
+
addConstraint(*falseState, Expr::createIsZero(condition));
falseState->lastConstraint = Expr::createIsZero(condition);
// Kinda gross, do we even really still want this option?
@@ -3128,9 +3205,11 @@ void Executor::executeCall(ExecutionState &state,
klee_error("unknown intrinsic: %s", f->getName().data());
}
- if (InvokeInst *ii = dyn_cast<InvokeInst>(i))
+ if (InvokeInst *ii = dyn_cast<InvokeInst>(i)){
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nfunction declared, executeCall named: %s, transferToBasicBlock ",f->getName().data());
transferToBasicBlock(ii->getNormalDest(), i->getParent(), state);
successorsPaths->insert(&state);
+ }
} else {
/* SYSREL extension */
@@ -3174,9 +3253,14 @@ void Executor::executeCall(ExecutionState &state,
// instead of the actual instruction, since we can't make a KInstIterator
// from just an instruction (unlike LLVM).
KFunction *kf = kmodule->functionMap[f];
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nfunction not declared, executeCall named: %s, state.pc ++ ", f->getName().data());
+ klee_muqi("Inside Executor::executeCall, state.pc before is %d", state.pc);
+
state.pushFrame(state.prevPC, kf);
state.pc = kf->instructions;
-
+
+ klee_muqi("Inside Executor::executeCall, state.pc after is %d", state.pc);
+
if (recordStackTraces)
recordStackTrace(state);
@@ -3384,11 +3468,96 @@ static inline const llvm::fltSemantics * fpWidthToSemantics(unsigned width) {
}
}
+//muqi
+void muqi_transfertoblock_info(BasicBlock *BB_src,BasicBlock *BB_dest,Instruction *inst_src, Instruction *inst_dest){
+ //muqi: add for identifing the block will be executed
+ Function *Func;
+ if (BB_src){
+ Func = BB_src->getFirstNonPHI()->getFunction();
+ int temp_BB = 0;
+ int BB_src_num = -1;
+ int BB_dest_num = -1;
+ for (Function::iterator BB_temp = Func->begin(), E = Func->end(); BB_temp != E; ++BB_temp) {
+ if (BB_src == (&*BB_temp)){
+ BB_src_num = temp_BB;
+ }
+ if (BB_dest == (&*BB_temp)){
+ BB_dest_num = temp_BB;
+ }
+ temp_BB ++;
+ }
+ klee_muqi_compare_test(Func->getName().data(),"\nTransferTobasic (used for lifter.ll), BB from %d to %d ", BB_src_num, BB_dest_num );
+ //muqi: add end
+ //muqi: have the metadata of line number
+ DILocation *Loc;
+ unsigned Line_src = 2147483647;
+ unsigned Line_des = 2147483647;
+ //find the line info for source of BB
+ if (Loc = BB_src->getFirstNonPHI()->getDebugLoc()) {
+ Line_src = Loc->getLine();
+ }
+ //if first line of BB has some errors, find the instruction line being executed.
+ if (Line_src == 2147483647 && inst_src) {
+ if (Loc = inst_src->getDebugLoc()) {
+ Line_src = Loc->getLine();
+ }
+ }
+
+ //find the line info for destination of BB
+ if(BB_dest == NULL) {
+ Line_des = 2147483647;
+ }else{
+ if (Loc = BB_dest->getFirstNonPHI()->getDebugLoc()){
+ Line_des = Loc->getLine();
+ }
+ }
+
+ if (Line_des == 2147483647 && inst_dest) {
+ if (Loc = inst_dest->getDebugLoc()) {
+ Line_des = Loc->getLine();
+ }
+ }
+ klee_muqi_compare_test(Func->getName().data(),"\nTransferTobasic (used for generatedc.ll), Linenumber of instruction in c file from %d to %d ", Line_src, Line_des );
+ klee_muqi("\nTransferTobasic (used for lifter.ll), BB from %d to %d ", BB_src_num, BB_dest_num );
+ klee_muqi("\nTransferTobasic (used for generatedc.ll), Linenumber of instruction in c file from %d to %d ", Line_src, Line_des );
+ //muqi: add end
+ }else {
+ Func = NULL;
+ klee_muqi_compare_test("unknown","\nTransferTobasic (used for lifter.ll), BB from -1 to -1 ");
+ klee_muqi_compare_test("unknown","\nTransferTobasic (used for generatedc.ll), Linenumber of instruction in c file from 2147483647 to 2147483647 ");
+ klee_muqi("\nTransferTobasic (used for lifter.ll), BB from -1 to -1 ");
+ klee_muqi("\nTransferTobasic (used for generatedc.ll), Linenumber of instruction in c file from 2147483647 to 2147483647 ");
+
+ }
+
+
+
+}
+
+//muqi
+std::vector<Instruction *> vector_i;
+std::vector<ExecutionState *>vector_state;
+std::vector<KInstruction *>vector_ki;
+std::vector<ref<Expr> >vector_constantexpr;
+std::vector<BasicBlock *> vector_BB_symbolized;
+
+
void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
state.stackFrameBeforeExecInst = state.stack.size() - 1;
Instruction *i = ki->inst;
+
+ //muqi
+ std::string temp_out = i->getOpcodeName();
+ klee_muqi("current instruction for this instruction is %d", state.prevPC);
+ klee_muqi("next instruction for this instruction is %d", state.pc);
+ klee_muqi("current Function name is: %s", i->getFunction()->getName());
+
+ klee_muqi("Instruction is: %s; ", temp_out.c_str());
+ const InstructionInfo *temp_info = ki->info;
+ klee_muqi("corresponding assembly line is %d \n", temp_info->assemblyLine);
+
switch (i->getOpcode()) {
// Control flow
case Instruction::Ret: {
@@ -3402,7 +3571,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
/* SYSREL EXTENSION */
state.checkAndSetPMCallbackCompleted(ri->getParent()->getParent()->getName());
/* SYSREL EXTENSION */
-
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Ret ");
llvm::outs() << "handling return for function " << ri->getParent()->getParent()->getName() << "\n";
if (!isVoidReturn) {
result = eval(ki, 0, state).value;
@@ -3424,6 +3593,12 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
generateValuedInstruction(state, ki);
if (state.stack.size() <= 1) {
+ muqi_transfertoblock_info(i->getParent(),NULL,i,NULL);
+ klee_muqi("\nInside Ret, state.stack.size() is 1\n");
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Ret state.pc ++");
+ klee_muqi("\nInside Ret, state.pc ++ , state.pc before is %d", state.pc);
+
+
assert(!caller && "caller set on initial stack frame");
/* SYSREL extension */
@@ -3503,6 +3678,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
}
/* SYSREL extension */
} else {
+ klee_muqi("\nInside Ret, state.stack.size() is more than one\n");
state.stackFrameBeforeExecInst = state.stack.size() - 1;
state.popFrame();
@@ -3511,13 +3687,26 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
if (InvokeInst *ii = dyn_cast<InvokeInst>(caller)) {
llvm::outs() << "returning to basic block of " << (*caller) << "\n";
+ //muqi
+ muqi_transfertoblock_info(caller->getParent(),ii->getNormalDest(),i,caller);
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Ret transferToBasicBlock ");
+ klee_muqi("\nInside Instruction::Ret transferToBasicBlock ");
+
transferToBasicBlock(ii->getNormalDest(), caller->getParent(), state);
} else {
+ //muqi
+ muqi_transfertoblock_info(i->getParent(),caller->getParent(),i,caller);
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Ret state.pc ++");
+ klee_muqi("\nInside Ret, state.pc ++ , state.pc before is %d", state.pc);
+
state.pc = kcaller;
++state.pc;
+
+ klee_muqi("\nInside Ret, state.pc ++ , state.pc after is %d", state.pc);
+
llvm::outs() << "returning to " << (*state.pc->inst) << "\n";
}
-
+ klee_muqi("In ret, Function name is: %s", caller->getFunction()->getName());
if (!isVoidReturn) {
Type *t = caller->getType();
if (t != Type::getVoidTy(i->getContext())) {
@@ -3544,31 +3733,136 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
// We check that the return value has no users instead of
// checking the type, since C defaults to returning int for
// undeclared functions.
- /* SYSREL extension */
- llvm::errs() << "Warning: return void when caller expected a result\n";
+ /* SYSREL extension */
+ //muqi
+ result = ConstantExpr::alloc(0, Expr::Int64);
+ bindLocal(kcaller, state, result);
+ klee_warning("Injected fake return for function: %s",
+ ri->getFunction()->getName().str().c_str());
+
+ //llvm::errs() << "Warning: return void when caller expected a result\n";
/* SYSREL extension */
}
- }
+ }
+
+//muqi
+ if (result.isNull() == true ){
+ result = ConstantExpr::alloc(0, Expr::Int64);
+ }
+ result->dump();
+ #ifdef ENABLE_Z3
+ Z3Builder temp_build = Z3Builder(false,NULL);
+ //Z3ASTHandle result_z3 = temp_build.construct(result);
+ int *width = (int *)malloc(sizeof(int));
+ *width = 0;
+ Z3ASTHandle result_z3 = temp_build.construct_muqi(result,width);
+ llvm::errs()<<"after result dumped, *width is:" << *width<<"\n";
+ if (*width == 1){
+
+ *width = 64;
+ result = SelectExpr::create(result,ConstantExpr::create(1,64),ConstantExpr::create(0,64));
+ result_z3 = temp_build.construct_muqi(result,width);
+ }
+ while (*width < 64 && *width != 1){
+ //concat the result to 64bits
+ result = ConcatExpr::create(ConstantExpr::create(0,8),result);
+ result_z3 = temp_build.construct_muqi(result,width);
+ llvm::errs()<<"after result dumped, *width is:" << *width<<"\n";
+ }
+ result_z3.dump();
+
+ #endif
+
break;
}
case Instruction::Br: {
BranchInst *bi = cast<BranchInst>(i);
if (bi->isUnconditional()) {
- transferToBasicBlock(bi->getSuccessor(0), bi->getParent(), state);
- successorsPaths->insert(&state);
+ //muqi add loopbound here, since the loop use unconditional branch to back to previous label, which generates the loop
+ //possible error??
+ Function *func_unconditon = i->getParent()->getParent();
+ bool lbe_uncondition = isLoopBoundExcluded(state.prevPC->getSourceLocation(), func_unconditon->getName());
+ llvm::errs() << "loop bound= " << loopBound << " excl? " << lbe_uncondition << "\n";
+
+ if (loopBound && !lbe_uncondition) {
+ unsigned tc;
+ tc = getForkFreq(state, i);
+ showForkfreq(state);
+ addForkFreq(&state, i);
+ if (tc >= loopBound) {
+ llvm::errs() << "path terminated early due to reaching bound for unconditional branches\n";
+ terminateStateEarly(state, "Loop Bound for unconditional reached\n");
+ //muqi, we give a fake return value
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Ret");
+ //klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Br uncondition transferToBasicBlock ");
+ muqi_transfertoblock_info(i->getParent(),NULL,i,NULL);
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Ret state.pc ++");
+ ref<Expr> fake_result =NULL;
+ fake_result = ConstantExpr::alloc(0, Expr::Int64);
+ fake_result->dump();
+ Z3Builder temp_build = Z3Builder(false,NULL);
+ int *width = (int *)malloc(sizeof(int));
+ *width = 64;
+ #ifdef ENABLE_Z3
+ Z3ASTHandle fake_result_z3 = temp_build.construct_muqi(fake_result,width);
+ fake_result_z3.dump();
+ #endif
+ }
+ else{
+ klee_muqi("br in Unconditional \n");
+ klee_muqi("br is %d \n", bi);
+ klee_muqi("br transfer from %d to %d\n", bi->getParent(), bi->getSuccessor(0));
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nbr in Unconditional ");
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Br uncondition transferToBasicBlock ");
+ //muqi: add for identifing the block will be executed
+ muqi_transfertoblock_info(i->getParent(),bi->getSuccessor(0),i,NULL);
+ transferToBasicBlock(bi->getSuccessor(0), bi->getParent(), state);
+ successorsPaths->insert(&state);
+ }
+ }
+ else{
+ klee_muqi("br in Unconditional \n");
+ klee_muqi("br is %d \n", bi);
+ klee_muqi("br transfer from %d to %d\n", bi->getParent(), bi->getSuccessor(0));
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nbr in Unconditional ");
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Br uncondition transferToBasicBlock ");
+ //muqi: add for identifing the block will be executed
+ muqi_transfertoblock_info(i->getParent(),bi->getSuccessor(0),i,NULL);
+ transferToBasicBlock(bi->getSuccessor(0), bi->getParent(), state);
+ successorsPaths->insert(&state);
+ }
+
} else {
// FIXME: Find a way that we don't have this hidden dependency.
+ klee_muqi("br in conditional \n");
+ klee_muqi("br is %d \n", bi);
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nbr in conditional ");
assert(bi->getCondition() == bi->getOperand(0) &&
"Wrong operand index!");
ref<Expr> cond = eval(ki, 0, state).value;
+
+ Expr *temp = cond.get();
+ // cond = optimizer.optimizeExpr(cond, false);
Executor::StatePair branches = fork(state, cond, false);
+
+ #ifdef Muqi_support_foreverloop
+ ref<Expr> cond_to_log = cond;
+ if (branches.first){
+ cond_to_log = branches.first->lastConstraint;
+ }
+ #endif
- if (branches.first)
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nFork finished");
+ klee_muqi("Fork finished\n");
+ if (branches.first){
branches.first->lastBranchInstConstraint = branches.first->lastConstraint;
+ branches.first->history_br_instructions = state.history_br_instructions;
+ }
+ if (branches.second){
- if (branches.second)
branches.second->lastBranchInstConstraint = branches.second->lastConstraint;
-
+ branches.second->history_br_instructions = state.history_br_instructions;
+ }
// NOTE: There is a hidden dependency here, markBranchVisited
// requires that we still be in the context of the branch
// instruction (it reuses its statistic id). Should be cleaned
@@ -3582,7 +3876,18 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
bool lbe = isLoopBoundExcluded(state.prevPC->getSourceLocation(), func->getName());
//llvm::errs() << "loop bound= " << loopBound << " excl? " << lbe << "\n";
if (loopBound && !lbe) {
+ tc = getForkFreq(state, i);
+ fc = tc;
+
if (branches.first) {
+ addForkFreq(branches.first, i);
+ }
+
+ if (branches.second) {
+ addForkFreq(branches.second, i);
+ }
+ /*
+ if (branches.first) {
addForkFreq(state,getSourceWithContext(state, state.prevPC), true);
}
@@ -3591,31 +3896,94 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
}
tc = getForkFreq(state, getSourceWithContext(state, state.prevPC), true);
fc = getForkFreq(state, getSourceWithContext(state, state.prevPC), false);
- llvm::errs() << "forked at " << state.prevPC->getSourceLocation() << " true branch " << tc << " times\n";
+ */
+ llvm::errs() << "forked at " << state.prevPC->getSourceLocation() << " true branch " << tc << " times\n";
llvm::errs() << "forked at " << state.prevPC->getSourceLocation() << " false branch " << fc << " times\n";
if (branches.first && branches.second) {
- if (fc > loopBound && tc > loopBound) {
+ vector_BB_symbolized.push_back(i->getParent());
+ llvm:errs() << "i->getParent()" << i->getParent() <<"\n";
+ if (fc >= loopBound && tc >= loopBound) {
// terminate state
llvm::errs() << "path terminated early due to reaching bound for both branches\n";
terminateStateEarly(state, "Loop Bound for both successors reached\n");
- }
+
+ //we need to pop the addstates, since in previous fork(), we "addedStates.push_back(falseState);"!!!
+ addedStates.pop_back();
+
+ //muqi, we give a fake return value
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Ret");
+ //klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Br uncondition transferToBasicBlock ");
+ muqi_transfertoblock_info(i->getParent(),NULL,i,NULL);
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Ret state.pc ++");
+ ref<Expr> fake_result =NULL;
+ fake_result = ConstantExpr::alloc(0, Expr::Int64);
+ fake_result->dump();
+ Z3Builder temp_build = Z3Builder(false,NULL);
+ int *width = (int *)malloc(sizeof(int));
+ *width = 64;
+ #ifdef ENABLE_Z3
+ Z3ASTHandle fake_result_z3 = temp_build.construct_muqi(fake_result,width);
+ fake_result_z3.dump();
+ #endif
+ }
+ /*
else if (tc > loopBound) {
llvm::errs() << "path terminated for the true branch\n";
terminateStateEarly(*branches.first, "Loop Bound for true successor reached\n");
+
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\n1Inside Instruction::Br condition second transferToBasicBlock ");
+ klee_muqi("\nInside Instruction::Br condition second transferToBasicBlock ");
+ //muqi: add for identifing the block will be executed
+ muqi_transfertoblock_info(i->getParent(),bi->getSuccessor(1),i,NULL);
+
transferToBasicBlock(bi->getSuccessor(1), bi->getParent(), *branches.second);
successorsPaths->insert(branches.second);
}
else if (fc > loopBound) {
llvm::errs() << "path terminated for the false branch\n";
terminateStateEarly(*branches.second, "Loop Bound for false successor reached\n");
- transferToBasicBlock(bi->getSuccessor(0), bi->getParent(), *branches.first);
+
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\n2Inside Instruction::Br condition first transferToBasicBlock ");
+ klee_muqi("\nInside Instruction::Br condition first transferToBasicBlock ");
+ //muqi: add for identifing the block will be executed
+ muqi_transfertoblock_info(i->getParent(),bi->getSuccessor(0),i,NULL);
+
+ transferToBasicBlock(bi->getSuccessor(0), bi->getParent(), *branches.first);
successorsPaths->insert(branches.first);
- }
+ }*/
else {
- transferToBasicBlock(bi->getSuccessor(0), bi->getParent(), *branches.first);
+
+ #ifdef Muqi_support_foreverloop
+ klee_muqi("Add constraint for trueStatement final\n");
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nAdd constraint for trueStatement ");
+
+ #if defined(Muqi_DEBUG)
+ cond_to_log->dump();
+ #ifdef ENABLE_Z3
+ Z3Builder temp_build = Z3Builder(false,NULL);
+ Z3ASTHandle result_z3 = temp_build.construct(cond_to_log);
+ result_z3.dump();
+ #endif
+
+ #endif
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::3Br condition first transferToBasicBlock ");
+ klee_muqi("\nInside Instruction::Br condition first transferToBasicBlock ");
+ //muqi: add for identifing the block will be executed
+ muqi_transfertoblock_info(i->getParent(),bi->getSuccessor(0),i,NULL);
+ #endif
+
+ transferToBasicBlock(bi->getSuccessor(0), bi->getParent(), *branches.first);
successorsPaths->insert(branches.first);
- transferToBasicBlock(bi->getSuccessor(1), bi->getParent(), *branches.second);
+
+ #ifdef Muqi_support_foreverloop
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::4Br condition second transferToBasicBlock ");
+ klee_muqi("\nInside Instruction::Br condition second transferToBasicBlock ");
+ //muqi: add for identifing the block will be executed
+ muqi_transfertoblock_info(i->getParent(),bi->getSuccessor(1),i,NULL);
+ #endif
+
+ transferToBasicBlock(bi->getSuccessor(1), bi->getParent(), *branches.second);
successorsPaths->insert(branches.second);
singleSuccessor = false;
bool abort = false;
@@ -3635,24 +4003,78 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
}
else {
if (branches.first) {
- if (tc > loopBound) {
- llvm::errs() << "branching to the false successor due to reaching loop bound for the true branch\n";
- transferToBasicBlock(bi->getSuccessor(1), bi->getParent(), *branches.first);
- successorsPaths->insert(branches.first);
+ if (tc >= loopBound) {
+ //muqi, we give a fake return value
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Ret");
+ //klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Br uncondition transferToBasicBlock ");
+ muqi_transfertoblock_info(i->getParent(),NULL,i,NULL);
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Ret state.pc ++");
+ ref<Expr> fake_result =NULL;
+ fake_result = ConstantExpr::alloc(0, Expr::Int64);
+ fake_result->dump();
+ Z3Builder temp_build = Z3Builder(false,NULL);
+ int *width = (int *)malloc(sizeof(int));
+ *width = 64;
+ #ifdef ENABLE_Z3
+ Z3ASTHandle fake_result_z3 = temp_build.construct_muqi(fake_result,width);
+ fake_result_z3.dump();
+ #endif
+
+ //llvm::errs() << "branching to the false successor due to reaching loop bound for the true branch\n";
+ llvm::errs() << "path terminated for the true branch2 instead of branching to the false successor due to reaching loop bound for the true branch\n";
+ terminateStateEarly(*branches.first, "Loop Bound for true successor reached\n");
+
+ //muqi we do not want to run false successor anymore.
+ //transferToBasicBlock(bi->getSuccessor(1), bi->getParent(), *branches.first);
+ transferToBasicBlock(bi->getSuccessor(0), bi->getParent(), *branches.first);
+
+ //llvm::errs() << "branching to the false successor due to reaching loop bound for the true branch\n";
+ //transferToBasicBlock(bi->getSuccessor(1), bi->getParent(), *branches.first);
+ successorsPaths->insert(branches.first);
+
}
else {
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::6Br condition first transferToBasicBlock ");
+ klee_muqi("\nInside Instruction::Br condition first transferToBasicBlock ");
+ //muqi: add for identifing the block will be executed
+ muqi_transfertoblock_info(i->getParent(),bi->getSuccessor(0),i,NULL);
transferToBasicBlock(bi->getSuccessor(0), bi->getParent(), *branches.first);
successorsPaths->insert(branches.first);
}
}
if (branches.second) {
- if (fc > loopBound) {
- //llvm::errs() << "path terminated for the false branch\n";
- //terminateStateEarly(*branches.second, "Loop Bound for false successor reached\n");
+ if (fc >= loopBound) {
+ //muqi, we give a fake return value
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Ret");
+ //klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Br uncondition transferToBasicBlock ");
+ muqi_transfertoblock_info(i->getParent(),NULL,i,NULL);
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Ret state.pc ++");
+ ref<Expr> fake_result =NULL;
+ fake_result = ConstantExpr::alloc(0, Expr::Int64);
+ fake_result->dump();
+ Z3Builder temp_build = Z3Builder(false,NULL);
+ int *width = (int *)malloc(sizeof(int));
+ *width = 64;
+ #ifdef ENABLE_Z3
+ Z3ASTHandle fake_result_z3 = temp_build.construct_muqi(fake_result,width);
+ fake_result_z3.dump();
+ #endif
+
+ llvm::errs() << "path terminated for the false branch\n";
+ terminateStateEarly(*branches.second, "Loop Bound for false successor reached\n");
transferToBasicBlock(bi->getSuccessor(0), bi->getParent(), *branches.second);
successorsPaths->insert(branches.second);
}
- else {
+ else {
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::8Br condition second transferToBasicBlock ");
+ klee_muqi("\nInside Instruction::Br condition second transferToBasicBlock ");
+ //muqi: add for identifing the block will be executed
+ muqi_transfertoblock_info(i->getParent(),bi->getSuccessor(0),i,NULL);
+ //added by muqi to fix double loop
+ llvm::errs() << "path terminated for the false branch2\n";
+ //terminateStateEarly(*branches.second, "Loop Bound for false successor reached\n");
+ //transferToBasicBlock(bi->getSuccessor(0), bi->getParent(), *branches.second);
+
transferToBasicBlock(bi->getSuccessor(1), bi->getParent(), *branches.second);
successorsPaths->insert(branches.second);
}
@@ -3661,10 +4083,20 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
}
else {
if (branches.first) {
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Br condition first transferToBasicBlock ");
+ klee_muqi("\nInside Instruction::Br condition first transferToBasicBlock ");
+ //muqi: add for identifing the block will be executed
+ muqi_transfertoblock_info(i->getParent(),bi->getSuccessor(0),i,NULL);
+
transferToBasicBlock(bi->getSuccessor(0), bi->getParent(), *branches.first);
successorsPaths->insert(branches.first);
}
if (branches.second) {
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Br condition second transferToBasicBlock ");
+ klee_muqi("\nInside Instruction::Br condition second transferToBasicBlock ");
+ //muqi: add for identifing the block will be executed
+ muqi_transfertoblock_info(i->getParent(),bi->getSuccessor(1),i,NULL);
+
transferToBasicBlock(bi->getSuccessor(1), bi->getParent(), *branches.second);
successorsPaths->insert(branches.second);
}
@@ -3693,13 +4125,20 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
}
case Instruction::IndirectBr: {
// implements indirect branch to a label within the current function
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::IndirectBr");
+
const auto bi = cast<IndirectBrInst>(i);
auto address = eval(ki, 0, state).value;
address = toUnique(state, address);
// concrete address
if (const auto CE = dyn_cast<ConstantExpr>(address.get())) {
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::IndirectBr first transferToBasicBlock ");
+
const auto bb_address = (BasicBlock *) CE->getZExtValue(Context::get().getPointerWidth());
+
+ //muqi: add for identifing the block will be executed
+ muqi_transfertoblock_info(i->getParent(),bb_address,i,NULL);
transferToBasicBlock(bb_address, bi->getParent(), state);
successorsPaths->insert(&state);
break;
@@ -3759,6 +4198,10 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
assert(targets.size() == branches.size());
for (std::vector<ExecutionState *>::size_type k = 0; k < branches.size(); ++k) {
if (branches[k]) {
+
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::IndirectBr for loop transferToBasicBlock ");
+ //muqi: add for identifing the block will be executed
+ muqi_transfertoblock_info(i->getParent(),targets[k],i,NULL);
transferToBasicBlock(targets[k], bi->getParent(), *branches[k]);
successorsPaths->insert(branches[k]);
}
@@ -3767,6 +4210,8 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
break;
}
case Instruction::Switch: {
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Switch");
+
SwitchInst *si = cast<SwitchInst>(i);
ref<Expr> cond = eval(ki, 0, state).value;
BasicBlock *bb = si->getParent();
@@ -3778,6 +4223,13 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
llvm::IntegerType *Ty = cast<IntegerType>(si->getCondition()->getType());
ConstantInt *ci = ConstantInt::get(Ty, CE->getZExtValue());
unsigned index = si->findCaseValue(ci).getSuccessorIndex();
+
+
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Switch first transferToBasicBlock ");
+
+ //muqi: add for identifing the block will be executed
+ muqi_transfertoblock_info(si->getParent(),si->getSuccessor(index),i,NULL);
+
transferToBasicBlock(si->getSuccessor(index), si->getParent(), state);
successorsPaths->insert(&state);
} else {
@@ -3877,6 +4329,11 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
it != ie; ++it) {
ExecutionState *es = *bit;
if (es) {
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Switch second transferToBasicBlock ");
+ //muqi: add for identifing the block will be executed
+ muqi_transfertoblock_info(bb,*it,i,NULL);
+
+
transferToBasicBlock(*it, bb, *es);
successorsPaths->insert(es);
}
@@ -3885,14 +4342,35 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
}
break;
}
- case Instruction::Unreachable:
+ case Instruction::Unreachable:{
// Note that this is not necessarily an internal bug, llvm will
// generate unreachable instructions in cases where it knows the
// program will crash. So it is effectively a SEGV or internal
// error.
- terminateStateOnExecError(state, "reached \"unreachable\" instruction");
- break;
+ //original
+ //terminateStateOnExecError(state, "reached \"unreachable\" instruction");
+
+ //muqi add for abort()
+ terminateStateEarly(state, "Instruction::Unreachable: termiantes state\n");
+
+ //muqi, we give a fake return value
+ klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Ret");
+ //klee_muqi_compare_test(i->getFunction()->getName().data(),"\nInside Instruction::Br uncondition transferToBasicBlock ");