klee
StatsTracker.h
Go to the documentation of this file.
1//===-- StatsTracker.h ------------------------------------------*- C++ -*-===//
2//
3// The KLEE Symbolic Virtual Machine
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef KLEE_STATSTRACKER_H
11#define KLEE_STATSTRACKER_H
12
13#include "CallPathManager.h"
14#include "klee/System/Time.h"
15
16#include <memory>
17#include <set>
18#include <sqlite3.h>
19
20namespace llvm {
21 class BranchInst;
22 class Function;
23 class Instruction;
24 class raw_fd_ostream;
25}
26
27namespace klee {
28 class ExecutionState;
29 class Executor;
30 class InstructionInfoTable;
31 class InterpreterHandler;
32 struct KInstruction;
33 struct StackFrame;
34
36 friend class WriteStatsTimer;
37 friend class WriteIStatsTimer;
38
40 std::string objectFilename;
41
42 std::unique_ptr<llvm::raw_fd_ostream> istatsFile;
43 ::sqlite3 *statsFile = nullptr;
44 ::sqlite3_stmt *transactionBeginStmt = nullptr;
45 ::sqlite3_stmt *transactionEndStmt = nullptr;
46 ::sqlite3_stmt *insertStmt = nullptr;
47 std::uint32_t statsCommitEvery;
48 std::uint32_t statsWriteCount = 0;
50
51 unsigned numBranches;
53
55
57
58 public:
59 static bool useStatistics();
60 static bool useIStats();
61
62 private:
63 void updateStateStatistics(uint64_t addend);
64 void writeStatsHeader();
65 void writeStatsLine();
66 void writeIStats();
67
68 public:
69 StatsTracker(Executor &_executor, std::string _objectFilename,
70 bool _updateMinDistToUncovered);
72
73 StatsTracker(const StatsTracker &other) = delete;
74 StatsTracker(StatsTracker &&other) noexcept = delete;
75 StatsTracker &operator=(const StatsTracker &other) = delete;
76 StatsTracker &operator=(StatsTracker &&other) noexcept = delete;
77
78 // called after a new StackFrame has been pushed (for callpath tracing)
79 void framePushed(ExecutionState &es, StackFrame *parentFrame);
80
81 // called after a StackFrame has been popped
83
84 // called when some side of a branch has been visited. it is
85 // imperative that this be called when the statistics index is at
86 // the index for the branch itself.
87 void markBranchVisited(ExecutionState *visitedTrue,
88 ExecutionState *visitedFalse);
89
90 // called when execution is done and stats files should be flushed
91 void done();
92
93 // process stats for a single instruction step, es is the state
94 // about to be stepped
96
99
101 };
102
103 uint64_t computeMinDistToUncovered(const KInstruction *ki,
104 uint64_t minDistAtRA);
105
106}
107
108#endif /* KLEE_STATSTRACKER_H */
ExecutionState representing a path under exploration.
StatsTracker(const StatsTracker &other)=delete
void updateStateStatistics(uint64_t addend)
unsigned fullBranches
Definition: StatsTracker.h:52
friend class WriteIStatsTimer
Definition: StatsTracker.h:37
static bool useStatistics()
CallPathManager callPathManager
Definition: StatsTracker.h:54
std::string objectFilename
Definition: StatsTracker.h:40
unsigned numBranches
Definition: StatsTracker.h:51
std::uint32_t statsCommitEvery
Definition: StatsTracker.h:47
void markBranchVisited(ExecutionState *visitedTrue, ExecutionState *visitedFalse)
::sqlite3_stmt * transactionBeginStmt
Definition: StatsTracker.h:44
bool updateMinDistToUncovered
Definition: StatsTracker.h:56
Executor & executor
Definition: StatsTracker.h:39
void stepInstruction(ExecutionState &es)
time::Point startWallTime
Definition: StatsTracker.h:49
friend class WriteStatsTimer
Definition: StatsTracker.h:36
StatsTracker & operator=(StatsTracker &&other) noexcept=delete
void computeReachableUncovered()
StatsTracker & operator=(const StatsTracker &other)=delete
static bool useIStats()
::sqlite3_stmt * transactionEndStmt
Definition: StatsTracker.h:45
std::uint32_t statsWriteCount
Definition: StatsTracker.h:48
std::unique_ptr< llvm::raw_fd_ostream > istatsFile
Definition: StatsTracker.h:42
time::Span elapsed()
Return duration since execution start.
void framePopped(ExecutionState &es)
StatsTracker(Executor &_executor, std::string _objectFilename, bool _updateMinDistToUncovered)
unsigned partialBranches
Definition: StatsTracker.h:52
::sqlite3 * statsFile
Definition: StatsTracker.h:43
StatsTracker(StatsTracker &&other) noexcept=delete
::sqlite3_stmt * insertStmt
Definition: StatsTracker.h:46
void framePushed(ExecutionState &es, StackFrame *parentFrame)
Definition: main.cpp:291
uint64_t computeMinDistToUncovered(const KInstruction *ki, uint64_t minDistAtRA)