ROSE  0.11.50.0
BaseSemantics/MemoryCellState.h
1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics2_BaseSemantics_MemoryCellState_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics2_BaseSemantics_MemoryCellState_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
5 
6 #include <Rose/BinaryAnalysis/InstructionSemantics2/BaseSemantics/MemoryCell.h>
7 #include <Rose/BinaryAnalysis/InstructionSemantics2/BaseSemantics/MemoryState.h>
8 #include <Rose/BinaryAnalysis/InstructionSemantics2/BaseSemantics/Types.h>
9 
10 #include <boost/serialization/access.hpp>
11 #include <boost/serialization/base_object.hpp>
12 #include <boost/serialization/export.hpp>
13 
14 namespace Rose {
15 namespace BinaryAnalysis {
16 namespace InstructionSemantics2 {
17 namespace BaseSemantics {
18 
20 typedef boost::shared_ptr<class MemoryCellState> MemoryCellStatePtr;
21 
25 class MemoryCellState: public MemoryState {
26 public:
28  using Super = MemoryState;
29 
32 
33 protected:
34  MemoryCellPtr protocell; // prototypical memory cell used for its virtual constructors
35  MemoryCellPtr latestWrittenCell_; // the cell whose value was most recently written to, if any
36 
37 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
38 private:
39  friend class boost::serialization::access;
40 
41  template<class S>
42  void serialize(S &s, const unsigned /*version*/) {
43  s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(MemoryState);
44  s & BOOST_SERIALIZATION_NVP(protocell);
45  s & BOOST_SERIALIZATION_NVP(latestWrittenCell_);
46  }
47 #endif
48 
49 protected:
50  MemoryCellState() {} // for serialization
51 
52  explicit MemoryCellState(const MemoryCellPtr &protocell);
53 
54  MemoryCellState(const SValuePtr &addrProtoval, const SValuePtr &valProtoval);
55 
56  MemoryCellState(const MemoryCellState &other);
57 
58 public:
59  ~MemoryCellState();
60 
61 public:
64  static MemoryCellStatePtr promote(const BaseSemantics::MemoryStatePtr &m) {
65  MemoryCellStatePtr retval = boost::dynamic_pointer_cast<MemoryCellState>(m);
66  ASSERT_not_null(retval);
67  return retval;
68  }
69 
70 public:
71  virtual void clear() ROSE_OVERRIDE;
72 
73 public:
77  virtual MemoryCellPtr latestWrittenCell() const {
78  return latestWrittenCell_;
79  }
80  virtual void latestWrittenCell(const MemoryCellPtr &cell) {
81  latestWrittenCell_ = cell;
82  }
91  virtual AddressSet getWritersUnion(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps,
92  RiscOperators *valOps) = 0;
93 
100  virtual AddressSet getWritersIntersection(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps,
101  RiscOperators *valOps) = 0;
102 
106  virtual std::vector<MemoryCellPtr> matchingCells(const MemoryCell::Predicate&) const = 0;
107 
113  virtual std::vector<MemoryCellPtr> leadingCells(const MemoryCell::Predicate&) const = 0;
114 
118  virtual void eraseMatchingCells(const MemoryCell::Predicate&) = 0;
119 
124  virtual void eraseLeadingCells(const MemoryCell::Predicate&) = 0;
125 
129  virtual void traverse(MemoryCell::Visitor&) = 0;
130 
134  }
135 
137  std::vector<MemoryCellPtr> allCells() const {
139  }
140 };
141 
142 } // namespace
143 } // namespace
144 } // namespace
145 } // namespace
146 
147 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
149 #endif
150 
151 #endif
152 #endif
virtual std::vector< MemoryCellPtr > leadingCells(const MemoryCell::Predicate &) const =0
Find leading matching cells.
boost::shared_ptr< class MemoryCellState > MemoryCellStatePtr
Shared-ownership pointer to a cell-based memory state.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
Main namespace for the ROSE library.
virtual AddressSet getWritersUnion(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps)=0
Writers for an address.
virtual void eraseMatchingCells(const MemoryCell::Predicate &)=0
Remove all matching cells.
virtual void eraseLeadingCells(const MemoryCell::Predicate &)=0
Remove leading matching cells.
virtual std::vector< MemoryCellPtr > matchingCells(const MemoryCell::Predicate &) const =0
Find all matching cells.
Base class for most instruction semantics RISC operators.
Definition: RiscOperators.h:48
boost::shared_ptr< MemoryCell > MemoryCellPtr
Shared-ownership pointer to a memory cell.
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
virtual void latestWrittenCell(const MemoryCellPtr &cell)
Property: Cell most recently written.
virtual void traverse(MemoryCell::Visitor &)=0
Traverse and modify cells.
static MemoryCellStatePtr promote(const BaseSemantics::MemoryStatePtr &m)
Promote a base memory state pointer to a BaseSemantics::MemoryCellState pointer.
virtual AddressSet getWritersIntersection(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps)=0
Writers for an address.
virtual MemoryCellPtr latestWrittenCell() const
Property: Cell most recently written.