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 {
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&);
175 bool executionFailed()
const;
185 InstructionSemantics::BaseSemantics::StatePtr copyOutgoingState()
const;
187 class BorrowedOutgoingState {
188 friend class PathNode;
190 PathNode*
const node;
192 const InstructionSemantics::BaseSemantics::StatePtr state;
194 BorrowedOutgoingState() =
delete;
195 BorrowedOutgoingState& operator=(
const BorrowedOutgoingState&) =
delete;
196 BorrowedOutgoingState(PathNode*,
const InstructionSemantics::BaseSemantics::StatePtr&);
198 ~BorrowedOutgoingState();
220 BorrowedOutgoingState borrowOutgoingState();
229 void releaseOutgoingState();
238 void appendTag(
const TagPtr&);
239 void appendTags(
const std::vector<TagPtr>&);
245 size_t nTags()
const;
250 std::vector<TagPtr> tags()
const;
257 double processingTime()
const;
264 void incrementProcessingTime(
double seconds);
276 std::string printableName()
const;
281 void toYamlHeader(
const SettingsPtr&, std::ostream&,
const std::string &prefix)
const;
284 void toYamlSteps(
const SettingsPtr&, std::ostream&,
const std::string &prefix,
285 size_t stepOrigin,
size_t maxSteps)
const;
288 std::vector<Sarif::LocationPtr> toSarif(
size_t maxSteps)
const;
291 void restoreOutgoingState(
const InstructionSemantics::BaseSemantics::StatePtr&);
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.