00001 //===-- StatsTracker.h ------------------------------------------*- C++ -*-===// 00002 // 00003 // The KLEE Symbolic Virtual Machine 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 #ifndef KLEE_STATSTRACKER_H 00011 #define KLEE_STATSTRACKER_H 00012 00013 #include "CallPathManager.h" 00014 00015 #include <iostream> 00016 #include <set> 00017 00018 namespace llvm { 00019 class BranchInst; 00020 class Function; 00021 class Instruction; 00022 } 00023 00024 namespace klee { 00025 class ExecutionState; 00026 class Executor; 00027 class InstructionInfoTable; 00028 class InterpreterHandler; 00029 class KInstruction; 00030 class StackFrame; 00031 00032 class StatsTracker { 00033 friend class WriteStatsTimer; 00034 friend class WriteIStatsTimer; 00035 00036 Executor &executor; 00037 std::string objectFilename; 00038 00039 std::ostream *statsFile, *istatsFile; 00040 double startWallTime; 00041 00042 unsigned numBranches; 00043 unsigned fullBranches, partialBranches; 00044 00045 CallPathManager callPathManager; 00046 00047 bool updateMinDistToUncovered; 00048 00049 public: 00050 static bool useStatistics(); 00051 00052 private: 00053 void updateStateStatistics(uint64_t addend); 00054 void writeStatsHeader(); 00055 void writeStatsLine(); 00056 void writeIStats(); 00057 00058 public: 00059 StatsTracker(Executor &_executor, std::string _objectFilename, 00060 bool _updateMinDistToUncovered); 00061 ~StatsTracker(); 00062 00063 // called after a new StackFrame has been pushed (for callpath tracing) 00064 void framePushed(ExecutionState &es, StackFrame *parentFrame); 00065 00066 // called after a StackFrame has been popped 00067 void framePopped(ExecutionState &es); 00068 00069 // called when some side of a branch has been visited. it is 00070 // imperative that this be called when the statistics index is at 00071 // the index for the branch itself. 00072 void markBranchVisited(ExecutionState *visitedTrue, 00073 ExecutionState *visitedFalse); 00074 00075 // called when execution is done and stats files should be flushed 00076 void done(); 00077 00078 // process stats for a single instruction step, es is the state 00079 // about to be stepped 00080 void stepInstruction(ExecutionState &es); 00081 00083 double elapsed(); 00084 00085 void computeReachableUncovered(); 00086 }; 00087 00088 uint64_t computeMinDistToUncovered(const KInstruction *ki, 00089 uint64_t minDistAtRA); 00090 00091 } 00092 00093 #endif
1.5.8