Skip to content

Commit

Permalink
TODO : WIP Probabilistic State
Browse files Browse the repository at this point in the history
  • Loading branch information
lahiri-phdworks committed Oct 3, 2020
1 parent c9d69aa commit f6c86e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
15 changes: 7 additions & 8 deletions lib/Core/ETree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "klee/Expr/Expr.h"
#include "klee/Expr/ExprPPrinter.h"
#include "klee/Support/OptionCategories.h"
#include <vector>

using namespace klee;
Expand Down Expand Up @@ -33,21 +32,20 @@ ETreeNode::ETreeNode(ETreeNode* parent, ProbExecState* state, ETreeNode* left, E

ETree::ETree(ProbExecState *initState) {
ETreeNode* rootNode = new ETreeNode(nullptr, initState);
// initState->execTreeNode = ETreeNodePtrUnique(rootNode);
root = ETreeNodePtr(rootNode);
current = root;
root->left = nullptr;
root->right = nullptr;
}

// TODO : Assign the current nodes correctly to the left and right states.
void ETree::forkState(ETreeNode *Node, bool forkflag, ProbExecState *leftState, ProbExecState *rightState) {
// Fork the state, create a left and right side execution nodes.
assert(Node && !(Node->left.get()) && !(Node->right.get()));
ETreeNode* tempLeft = new ETreeNode(Node, leftState);
ETreeNode* tempRight = new ETreeNode(Node, rightState);

Node->state->data = Node->state->data == "Start" ? Node->state->data : "Forked";
Node->state->data = Node->state->data == "Start" ? "Start" : "Forked";

Node->left = ETreeNodePtr(tempLeft);
Node->right = ETreeNodePtr(tempRight);

Expand All @@ -59,12 +57,11 @@ void ETree::forkState(ETreeNode *Node, bool forkflag, ProbExecState *leftState,
rightState->treeNode = (tempRight);
}

// FIXME : Update this correctly.
// We took a same decision as the PTree.cpp implementation.
// Based on the Solver result. (trueNode or falseNode)
this->current = forkflag ? Node->left : Node->right;
}

// TODO : Assign the current nodes correctly to states on removal.
}

void ETree::removeNode(ETreeNode *delNode) {
// Remove a ETreeNode from the ETree
assert(delNode && !delNode->right.get() && !delNode->left.get());
Expand Down Expand Up @@ -111,6 +108,7 @@ void ETree::dumpETree(llvm::raw_ostream &fileptr) {
: fileptr << "no_state";
fileptr << " [shape=ellipse, color=" << color << "];\n";

// If node has left, process left.
if (current->left.get()) {
fileptr << "\t" << "\"" << current->state->stateId << ", " << current->state->data << "\"" << " -> ";
fileptr << "\"" << current->left.get()->state->stateId;
Expand All @@ -120,6 +118,7 @@ void ETree::dumpETree(llvm::raw_ostream &fileptr) {
processing_stack.emplace_back(current->left.get());
}

// If node has right side, process right side.
if (current->right.get()) {
fileptr << "\t" << "\"" << current->state->stateId << ", " << current->state->data << "\"" << " -> ";
fileptr << "\"" << current->right.get()->state->stateId;
Expand Down
1 change: 0 additions & 1 deletion lib/Core/ProbExecState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "klee/Expr/Expr.h"
#include "klee/Expr/ExprPPrinter.h"
#include "klee/Support/OptionCategories.h"
#include <memory.h>

using namespace klee;
Expand Down
5 changes: 2 additions & 3 deletions lib/Core/ProbExecState.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
#include <unordered_map>

/**
* This is a custom execution Tree to store some information during
* execution. Later it can be extended to store path-specific execution state
* related information like the PTree implementation.
* This is a custom execution State to store some information during
* execution. It store information for probabilistic execution.
*/
namespace klee {

Expand Down

0 comments on commit f6c86e5

Please sign in to comment.