18
18
#include " klee/Statistics/TimerStatIncrementer.h"
19
19
20
20
#include " CoreStats.h"
21
+ #include < cstring>
21
22
22
23
namespace klee {
23
24
llvm::cl::OptionCategory
@@ -384,15 +385,15 @@ bool AddressSpace::resolve(ExecutionState &state, TimingSolver *solver,
384
385
// transparently avoid screwing up symbolics (if the byte is symbolic
385
386
// then its concrete cache byte isn't being used) but is just a hack.
386
387
387
- void AddressSpace::copyOutConcretes (const Assignment &assignment ) {
388
+ void AddressSpace::copyOutConcretes () {
388
389
for (const auto &object : objects) {
389
390
auto &mo = object.first ;
390
391
auto &os = object.second ;
391
392
if (ref<ConstantExpr> sizeExpr =
392
393
dyn_cast<ConstantExpr>(mo->getSizeExpr ())) {
393
394
if (!mo->isUserSpecified && !os->readOnly &&
394
395
sizeExpr->getZExtValue () != 0 ) {
395
- copyOutConcrete (mo, os.get (), assignment );
396
+ copyOutConcrete (mo, os.get ());
396
397
}
397
398
}
398
399
}
@@ -407,27 +408,19 @@ ref<ConstantExpr> toConstantExpr(ref<Expr> expr) {
407
408
}
408
409
409
410
void AddressSpace::copyOutConcrete (const MemoryObject *mo,
410
- const ObjectState *os,
411
- const Assignment &assignment) const {
412
- if (ref<ConstantExpr> addressExpr =
413
- dyn_cast<ConstantExpr>(mo->getBaseExpr ())) {
414
- auto address =
415
- reinterpret_cast <std::uint8_t *>(addressExpr->getZExtValue ());
416
- AssignmentEvaluator evaluator (assignment, false );
417
- if (ref<ConstantExpr> sizeExpr =
418
- dyn_cast<ConstantExpr>(mo->getSizeExpr ())) {
419
- size_t moSize = sizeExpr->getZExtValue ();
420
- std::vector<uint8_t > concreteStore (moSize);
421
- for (size_t i = 0 ; i < moSize; i++) {
422
- auto byte = evaluator.visit (os->readValue8 (i));
423
- concreteStore[i] = cast<ConstantExpr>(byte)->getZExtValue (Expr::Int8);
424
- }
425
- std::memcpy (address, concreteStore.data (), moSize);
411
+ const ObjectState *os) const {
412
+
413
+ if (auto addressExpr = dyn_cast<ConstantExpr>(mo->getBaseExpr ())) {
414
+ if (auto sizeExpr = dyn_cast<ConstantExpr>(mo->getSizeExpr ())) {
415
+ auto address =
416
+ reinterpret_cast <std::uint8_t *>(addressExpr->getZExtValue ());
417
+ auto size = sizeExpr->getZExtValue ();
418
+ std::memcpy (address, os->valueOS .concreteStore ->data (), size);
426
419
}
427
420
}
428
421
}
429
422
430
- bool AddressSpace::copyInConcretes (const Assignment &assignment ) {
423
+ bool AddressSpace::copyInConcretes () {
431
424
for (auto &obj : objects) {
432
425
const MemoryObject *mo = obj.first ;
433
426
@@ -436,8 +429,7 @@ bool AddressSpace::copyInConcretes(const Assignment &assignment) {
436
429
437
430
if (ref<ConstantExpr> arrayConstantAddress =
438
431
dyn_cast<ConstantExpr>(mo->getBaseExpr ())) {
439
- if (!copyInConcrete (mo, os.get (), arrayConstantAddress->getZExtValue (),
440
- assignment))
432
+ if (!copyInConcrete (mo, os.get (), arrayConstantAddress->getZExtValue ()))
441
433
return false ;
442
434
}
443
435
}
@@ -447,24 +439,17 @@ bool AddressSpace::copyInConcretes(const Assignment &assignment) {
447
439
}
448
440
449
441
bool AddressSpace::copyInConcrete (const MemoryObject *mo, const ObjectState *os,
450
- uint64_t src_address,
451
- const Assignment &assignment) {
452
- AssignmentEvaluator evaluator (assignment, false );
442
+ uint64_t src_address) {
453
443
auto address = reinterpret_cast <std::uint8_t *>(src_address);
454
- size_t moSize =
455
- cast<ConstantExpr>(evaluator.visit (mo->getSizeExpr ()))->getZExtValue ();
456
- std::vector<uint8_t > concreteStore (moSize);
457
- for (size_t i = 0 ; i < moSize; i++) {
458
- auto byte = evaluator.visit (os->readValue8 (i));
459
- concreteStore[i] = cast<ConstantExpr>(byte)->getZExtValue (8 );
460
- }
461
- if (memcmp (address, concreteStore.data (), moSize) != 0 ) {
444
+ size_t moSize = cast<ConstantExpr>(mo->getSizeExpr ())->getZExtValue ();
445
+
446
+ if (memcmp (address, os->valueOS .concreteStore ->data (), moSize) != 0 ) {
462
447
if (os->readOnly ) {
463
448
return false ;
464
449
} else {
465
450
ObjectState *wos = getWriteable (mo, os);
466
451
for (size_t i = 0 ; i < moSize; i++) {
467
- wos->write (i, ConstantExpr::create ( address[i], Expr::Int8) );
452
+ wos->write8 (i, address[i]);
468
453
}
469
454
}
470
455
}
0 commit comments