 |
|
 |
|
| Files: |
1 |
|
Branches Taken: |
80.8% |
21 / 26 |
| Generated: |
2009-05-17 22:47 |
|
Branches Executed: |
69.2% |
18 / 26 |
| |
|
Line Coverage: |
87.5% |
35 / 40 |
| |
 |
|
 |
1 : #include "CallPathManager.h"
2 :
3 : #include "klee/Statistics.h"
4 :
5 : #include <map>
6 : #include <vector>
7 : #include "llvm/Function.h"
8 : #include "llvm/Support/Streams.h"
9 :
10 : #include "klee/Internal/FIXME/sugar.h"
11 :
12 : using namespace llvm;
13 : using namespace klee;
14 :
15 : ///
16 :
17 : CallPathNode::CallPathNode(CallPathNode *_parent,
18 : Instruction *_callSite,
19 542: Function *_function)
20 : : parent(_parent),
21 : callSite(_callSite),
22 : function(_function),
23 1084: count(0) {
24 542: }
25 :
26 0: void CallPathNode::print() {
27 : llvm::cerr << " (Function: " << this->function->getName() << ", "
28 : << "Callsite: " << callSite << ", "
29 0: << "Count: " << this->count << ")";
0: branch 0 not taken
0: branch 1 not taken
0: branch 2 not taken
0: branch 3 not taken
30 0: if (parent && parent->callSite) {
31 : llvm::cerr << ";\n";
32 0: parent->print();
33 : }
34 : else llvm::cerr << "\n";
35 0: }
36 :
37 : ///
38 :
39 103: CallPathManager::CallPathManager() : root(0, 0, 0) {
40 103: }
41 :
42 103: CallPathManager::~CallPathManager() {
439: branch 0 taken
103: branch 1 taken
103: branch 2 taken
103: branch 3 taken
43 748: foreach(it, paths.begin(), paths.end())
439: branch 0 taken
0: branch 1 not taken
439: branch 4 taken
439: branch 5 taken
44 439: delete *it;
45 206: }
46 :
47 105: void CallPathManager::getSummaryStatistics(CallSiteSummaryTable &results) {
48 : results.clear();
49 :
464: branch 0 taken
105: branch 1 taken
50 779: foreach(it, paths.begin(), paths.end())
51 928: (*it)->summaryStatistics = (*it)->statistics;
52 :
53 : // compute summary bottom up, while building result table
464: branch 0 taken
105: branch 1 taken
54 779: foreach(it, paths.rbegin(), paths.rend()) {
55 464: CallPathNode *cp = *it;
56 464: cp->parent->summaryStatistics += cp->summaryStatistics;
57 :
58 928: CallSiteInfo &csi = results[cp->callSite][cp->function];
59 464: csi.count += cp->count;
60 464: csi.statistics += cp->summaryStatistics;
61 : }
62 105: }
63 :
64 :
65 : CallPathNode *CallPathManager::computeCallPath(CallPathNode *parent,
66 : Instruction *cs,
67 441: Function *f) {
1092: branch 0 taken
439: branch 1 taken
68 1531: for (CallPathNode *p=parent; p; p=p->parent)
105: branch 0 taken
987: branch 1 taken
2: branch 2 taken
103: branch 3 taken
69 1092: if (cs==p->callSite && f==p->function)
70 2: return p;
71 :
72 439: CallPathNode *cp = new CallPathNode(parent, cs, f);
73 439: paths.push_back(cp);
74 439: return cp;
75 : }
76 :
77 : CallPathNode *CallPathManager::getCallPath(CallPathNode *parent,
78 : Instruction *cs,
79 1056: Function *f) {
80 : std::pair<Instruction*,Function*> key(cs, f);
103: branch 0 taken
953: branch 1 taken
81 1056: if (!parent)
82 103: parent = &root;
83 :
84 1056: let(it, parent->children.find(key));
441: branch 0 taken
615: branch 1 taken
85 2112: if (it==parent->children.end()) {
86 441: CallPathNode *cp = computeCallPath(parent, cs, f);
87 882: parent->children.insert(std::make_pair(key, cp));
88 441: return cp;
89 : } else {
90 615: return it->second;
91 : }
92 : }
93 :
Generated: 2009-05-17 22:47 by zcov