1#ifndef ROSE_BinaryAnalysis_ModelChecker_PathNode_H
2#define ROSE_BinaryAnalysis_ModelChecker_PathNode_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_MODEL_CHECKER
6#include <Rose/BinaryAnalysis/ModelChecker/BasicTypes.h>
7#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/BasicTypes.h>
8#include <Rose/BinaryAnalysis/SmtSolver.h>
9#include <Rose/BinaryAnalysis/SymbolicExpression.h>
12namespace BinaryAnalysis {
13namespace ModelChecker {
23class PathNode:
public std::enable_shared_from_this<PathNode> {
26 using Ptr = PathNodePtr;
30 const ExecutionUnitPtr executionUnit_;
32 mutable SAWYER_THREAD_TRAITS::Mutex mutex_;
43 InstructionSemantics::BaseSemantics::StatePtr incomingState_;
44 InstructionSemantics::BaseSemantics::StatePtr outgoingState_;
46 bool executionFailed_ =
false;
47 std::vector<SymbolicExpression::Ptr> assertions_;
48 SmtSolver::Evidence evidence_;
49 std::vector<TagPtr> tags_;
51 double processingTime_ = NAN;
52 double sortKey_ = NAN;
60 PathNode(
const ExecutionUnitPtr&);
65 PathNode(
const Ptr &parent,
const ExecutionUnitPtr&,
const SymbolicExpression::Ptr &assertion,
66 const SmtSolver::Evidence&,
const InstructionSemantics::BaseSemantics::StatePtr &parentOutgoingState);
77 static Ptr instance(
const ExecutionUnitPtr&);
86 static Ptr instance(
const Ptr &parent,
const ExecutionUnitPtr&,
const SymbolicExpression::Ptr &assertion,
87 const SmtSolver::Evidence&,
const InstructionSemantics::BaseSemantics::StatePtr &parentOutgoingState);
106 double sortKey()
const;
107 void sortKey(
double);
128 ExecutionUnitPtr executionUnit()
const;
136 size_t nSteps()
const;
144 void assertion(
const SymbolicExpression::Ptr&);
149 std::vector<SymbolicExpression::Ptr> assertions()
const;
156 SmtSolver::Evidence evidence()
const;
167 void execute(
const SettingsPtr&,
const SemanticCallbacksPtr&,
const InstructionSemantics::BaseSemantics::RiscOperatorsPtr&,
168 const SmtSolver::Ptr&);
183 bool executionFailed()
const;
193 InstructionSemantics::BaseSemantics::StatePtr copyOutgoingState()
const;
195 class BorrowedOutgoingState {
196 friend class PathNode;
198 PathNode*
const node;
200 const InstructionSemantics::BaseSemantics::StatePtr state;
202 BorrowedOutgoingState() =
delete;
203 BorrowedOutgoingState& operator=(
const BorrowedOutgoingState&) =
delete;
204 BorrowedOutgoingState(PathNode*,
const InstructionSemantics::BaseSemantics::StatePtr&);
206 ~BorrowedOutgoingState();
228 BorrowedOutgoingState borrowOutgoingState();
237 void releaseOutgoingState();
246 void appendTag(
const TagPtr&);
247 void appendTags(
const std::vector<TagPtr>&);
253 size_t nTags()
const;
258 std::vector<TagPtr> tags()
const;
265 double processingTime()
const;
272 void incrementProcessingTime(
double seconds);
284 std::string printableName()
const;
289 void toYamlHeader(
const SettingsPtr&, std::ostream&,
const std::string &prefix)
const;
292 void toYamlSteps(
const SettingsPtr&, std::ostream&,
const std::string &prefix,
293 size_t stepOrigin,
size_t maxSteps)
const;
296 std::vector<Sarif::LocationPtr> toSarif(
size_t maxSteps)
const;
299 void restoreOutgoingState(
const InstructionSemantics::BaseSemantics::StatePtr&);
301 std::pair<InstructionSemantics::BaseSemantics::StatePtr, bool>
302 incomingState_NS(
const SettingsPtr&,
const SemanticCallbacksPtr&,
const InstructionSemantics::BaseSemantics::RiscOperatorsPtr&,
303 const SmtSolver::Ptr&);
Holds a value or nothing.
Sawyer::SharedPointer< Node > Ptr
Reference counting pointer.
Id id(const std::string &name)
Returns the ID for an attribute name.