 |
|
 |
|
| Files: |
1 |
|
Branches Taken: |
77.3% |
17 / 22 |
| Generated: |
2009-05-17 22:47 |
|
Branches Executed: |
81.8% |
18 / 22 |
| |
|
Line Coverage: |
88.5% |
23 / 26 |
| |
 |
|
 |
1 : /* -*- mode: c++; c-basic-offset: 2; -*- */
2 :
3 : #include "Common.h"
4 :
5 : #include "CoreStats.h"
6 : #include "MemoryManager.h"
7 :
8 : #include "klee/ExecutionState.h"
9 : #include "klee/Expr.h"
10 : #include "klee/Memory.h"
11 : #include "klee/Solver.h"
12 :
13 : #include "llvm/Support/CommandLine.h"
14 :
15 : using namespace klee;
16 :
17 : /***/
18 :
19 206: MemoryManager::~MemoryManager() {
766490: branch 0 taken
206: branch 1 taken
206: branch 2 taken
206: branch 3 taken
20 1533598: while (!objects.empty()) {
21 1532980: MemoryObject *mo = objects.back();
22 766490: objects.pop_back();
766490: branch 0 taken
0: branch 1 not taken
766490: branch 4 taken
766490: branch 5 taken
23 766490: delete mo;
24 : }
25 412: }
26 :
27 : MemoryObject *MemoryManager::allocate(uint64_t size, bool isLocal, bool isGlobal,
28 765768: const llvm::Value *allocSite) {
1: branch 0 taken
765767: branch 1 taken
29 765768: if (size>10*1024*1024) {
30 1: klee_warning_once(0, "failing large alloc: %u bytes", (unsigned) size);
31 1: return 0;
32 : }
33 765767: uint64_t address = (uint64_t) (unsigned long) malloc((unsigned) size);
0: branch 0 not taken
765767: branch 1 taken
34 765767: if (!address)
35 0: return 0;
36 :
37 : ++stats::allocations;
38 : MemoryObject *res = new MemoryObject(address, size, isLocal, isGlobal, false,
39 1531534: allocSite);
40 765767: objects.push_back(res);
41 765767: return res;
42 : }
43 :
44 : MemoryObject *MemoryManager::allocateFixed(uint64_t address, uint64_t size,
45 723: const llvm::Value *allocSite) {
16875: branch 0 taken
723: branch 1 taken
46 19044: for (objects_ty::iterator it = objects.begin(), ie = objects.end();
47 : it != ie; ++it) {
48 16875: MemoryObject *mo = *it;
49 : assert(!(address+size > mo->address && address < mo->address+mo->size) &&
16018: branch 0 taken
857: branch 1 taken
0: branch 2 not taken
16018: branch 3 taken
50 16875: "allocated an overlapping object");
51 : }
52 :
53 : ++stats::allocations;
54 : MemoryObject *res = new MemoryObject(address, size, false, true, true,
55 1446: allocSite);
56 723: objects.push_back(res);
57 723: return res;
58 : }
59 :
60 0: void MemoryManager::deallocate(const MemoryObject *mo) {
61 0: assert(0);
103: branch 0 taken
0: branch 1 not taken
103: branch 2 taken
0: branch 3 not taken
62 206: }
Generated: 2009-05-17 22:47 by zcov