ROSE  0.11.145.0
SemanticCallbacks.h
1 #ifndef ROSE_BinaryAnalysis_ModelChecker_SemanticCallbacks_H
2 #define ROSE_BinaryAnalysis_ModelChecker_SemanticCallbacks_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_MODEL_CHECKER
5 
6 #include <Rose/BinaryAnalysis/ModelChecker/Types.h>
7 
8 #include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/BasicTypes.h>
9 #include <Rose/BinaryAnalysis/SmtSolver.h>
10 #include <Rose/Yaml.h>
11 
12 #ifdef ROSE_HAVE_YAMLCPP
13 #include <yaml-cpp/yaml.h>
14 #endif
15 
16 namespace Rose {
17 namespace BinaryAnalysis {
18 namespace ModelChecker {
19 
25 class SemanticCallbacks {
26 public:
28  using Ptr = SemanticCallbacksPtr;
29 
30 private:
31  const SettingsPtr mcSettings_; // model checker settings
32 
33 protected:
34  SemanticCallbacks() = delete;
35  explicit SemanticCallbacks(const SettingsPtr&);
36 public:
37  virtual ~SemanticCallbacks();
38 
39 public:
41  // Functions for creating the semantics framework
43 
50  virtual void reset() {}
51 
57  SettingsPtr mcSettings() const;
58 
69 
76  virtual InstructionSemantics::BaseSemantics::RegisterStatePtr createInitialRegisters() = 0;
77 
84  virtual InstructionSemantics::BaseSemantics::MemoryStatePtr createInitialMemory() = 0;
85 
93  virtual InstructionSemantics::BaseSemantics::StatePtr createInitialState();
94 
112  virtual InstructionSemantics::BaseSemantics::RiscOperatorsPtr createRiscOperators() = 0;
113 
124  virtual SmtSolverPtr createSolver() = 0;
125 
138  virtual void attachModelCheckerSolver(const InstructionSemantics::BaseSemantics::RiscOperatorsPtr&,
139  const SmtSolverPtr&) {}
140 
149  virtual void initializeState(const InstructionSemantics::BaseSemantics::RiscOperatorsPtr&);
150 
158  createDispatcher(const InstructionSemantics::BaseSemantics::RiscOperatorsPtr&) = 0;
159 
161  // State query functions
163 
171  instructionPointer(const InstructionSemantics::BaseSemantics::RiscOperatorsPtr&) = 0;
172 
176  struct CodeAddresses {
178  std::set<rose_addr_t> addresses;
179  bool isComplete = true;
180  };
181 
188  virtual CodeAddresses nextCodeAddresses(const InstructionSemantics::BaseSemantics::RiscOperatorsPtr&);
189 
191  // Execution tree functions
193 
203  virtual std::vector<TagPtr>
204  preExecute(const ExecutionUnitPtr&, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr&);
205 
215  virtual std::vector<TagPtr>
216  postExecute(const ExecutionUnitPtr&, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr&);
217 
219  struct NextUnit {
220  ExecutionUnitPtr unit;
221  SymbolicExpression::Ptr assertion;
222  SmtSolver::Evidence evidence;
223  };
224 
240  virtual std::vector<NextUnit>
241  nextUnits(const PathPtr&, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr&, const SmtSolverPtr&) = 0;
242 
244  // Path creation functions.
246 
257 #ifdef ROSE_HAVE_YAMLCPP
258  virtual std::list<ExecutionUnitPtr>
259  parsePath(const YAML::Node&, const std::string &sourceName) = 0;
260 #endif
261  virtual std::list<ExecutionUnitPtr>
262  parsePath(const Yaml::Node&, const std::string &sourceName) = 0;
264 };
265 
266 } // namespace
267 } // namespace
268 } // namespace
269 
270 #endif
271 #endif
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
boost::shared_ptr< RegisterState > RegisterStatePtr
Shared-ownership pointer to a register state.
Main namespace for the ROSE library.
boost::shared_ptr< State > StatePtr
Shared-ownership pointer to a semantic state.
boost::shared_ptr< Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
Sawyer::Container::Map< std::string, SymbolicExpression::Ptr > Evidence
Evidence of satisfiability.
Definition: SmtSolver.h:566
Sawyer::SharedPointer< Node > Ptr
Reference counting pointer.
std::shared_ptr< SmtSolver > SmtSolverPtr
Reference counting pointer.