klee
PTree.h
Go to the documentation of this file.
1//===-- PTree.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_PTREE_H
11#define KLEE_PTREE_H
12
14#include "klee/Expr/Expr.h"
16#include "llvm/ADT/PointerIntPair.h"
17
18namespace klee {
19 class ExecutionState;
20 class PTreeNode;
21 /* PTreeNodePtr is used by the Random Path Searcher object to efficiently
22 record which PTreeNode belongs to it. PTree is a global structure that
23 captures all states, whereas a Random Path Searcher might only care about
24 a subset. The integer part of PTreeNodePtr is a bitmask (a "tag") of which
25 Random Path Searchers PTreeNode belongs to. */
26 constexpr int PtrBitCount = 3;
27 using PTreeNodePtr = llvm::PointerIntPair<PTreeNode *, PtrBitCount, uint8_t>;
28
29 class PTreeNode {
30 public:
31 PTreeNode *parent = nullptr;
32
36
37 PTreeNode(const PTreeNode&) = delete;
39 ~PTreeNode() = default;
40 };
41
42 class PTree {
43 // Number of registered ID
45
46 public:
48 explicit PTree(ExecutionState *initialState);
49 ~PTree() = default;
50
51 void attach(PTreeNode *node, ExecutionState *leftState,
52 ExecutionState *rightState, BranchType reason);
53 void remove(PTreeNode *node);
54 void dump(llvm::raw_ostream &os);
55 std::uint8_t getNextId() {
56 std::uint8_t id = 1 << registeredIds++;
58 klee_error("PTree cannot support more than %d RandomPathSearchers",
60 }
61 return id;
62 }
63 };
64}
65
66#endif /* KLEE_PTREE_H */
BranchType
Reason an ExecutionState forked.
Definition: BranchTypes.h:48
ExecutionState representing a path under exploration.
~PTreeNode()=default
ExecutionState * state
Definition: PTree.h:35
PTreeNode(const PTreeNode &)=delete
PTreeNode * parent
Definition: PTree.h:31
PTreeNodePtr right
Definition: PTree.h:34
PTreeNodePtr left
Definition: PTree.h:33
void attach(PTreeNode *node, ExecutionState *leftState, ExecutionState *rightState, BranchType reason)
Definition: PTree.cpp:39
PTreeNodePtr root
Definition: PTree.h:47
int registeredIds
Definition: PTree.h:44
~PTree()=default
void dump(llvm::raw_ostream &os)
Definition: PTree.cpp:95
std::uint8_t getNextId()
Definition: PTree.h:55
PTree(ExecutionState *initialState)
Definition: PTree.cpp:34
void remove(PTreeNode *node)
Definition: PTree.cpp:55
Definition: main.cpp:291
llvm::PointerIntPair< PTreeNode *, PtrBitCount, uint8_t > PTreeNodePtr
Definition: PTree.h:27
constexpr int PtrBitCount
Definition: PTree.h:26
void klee_error(const char *msg,...) __attribute__((format(printf