ROSE  0.9.9.109
MemoryCellState.h
1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics2_MemoryCellState_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics2_MemoryCellState_H
3 
4 #include <BaseSemantics2.h>
5 #include <MemoryCell.h>
6 
7 #include <boost/serialization/access.hpp>
8 #include <boost/serialization/base_object.hpp>
9 #include <boost/serialization/export.hpp>
10 
11 namespace Rose {
12 namespace BinaryAnalysis {
13 namespace InstructionSemantics2 {
14 namespace BaseSemantics {
15 
17 typedef boost::shared_ptr<class MemoryCellState> MemoryCellStatePtr;
18 
23 protected:
24  MemoryCellPtr protocell; // prototypical memory cell used for its virtual constructors
25  MemoryCellPtr latestWrittenCell_; // the cell whose value was most recently written to, if any
26 
27 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
28 private:
29  friend class boost::serialization::access;
30 
31  template<class S>
32  void serialize(S &s, const unsigned version) {
33  s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(MemoryState);
34  s & BOOST_SERIALIZATION_NVP(protocell);
35  s & BOOST_SERIALIZATION_NVP(latestWrittenCell_);
36  }
37 #endif
38 
39 protected:
40  MemoryCellState() {} // for serialization
41 
42  explicit MemoryCellState(const MemoryCellPtr &protocell)
43  : MemoryState(protocell->get_address(), protocell->get_value()), protocell(protocell) {}
44 
45  MemoryCellState(const SValuePtr &addrProtoval, const SValuePtr &valProtoval)
46  : MemoryState(addrProtoval, valProtoval), protocell(MemoryCell::instance(addrProtoval, valProtoval)) {}
47 
48  MemoryCellState(const MemoryCellState &other)
49  : MemoryState(other), protocell(other.protocell) {} // latestWrittenCell_ is cleared
50 
51 public:
54  static MemoryCellStatePtr promote(const BaseSemantics::MemoryStatePtr &m) {
55  MemoryCellStatePtr retval = boost::dynamic_pointer_cast<MemoryCellState>(m);
56  ASSERT_not_null(retval);
57  return retval;
58  }
59 
60 public:
61  virtual void clear() ROSE_OVERRIDE;
62 
63 public:
67  virtual MemoryCellPtr latestWrittenCell() const {
68  return latestWrittenCell_;
69  }
70  virtual void latestWrittenCell(const MemoryCellPtr &cell) {
71  latestWrittenCell_ = cell;
72  }
81  virtual MemoryCell::AddressSet getWritersUnion(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps,
82  RiscOperators *valOps) = 0;
83 
90  virtual MemoryCell::AddressSet getWritersIntersection(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps,
91  RiscOperators *valOps) = 0;
92 
96  virtual std::vector<MemoryCellPtr> matchingCells(const MemoryCell::Predicate&) const = 0;
97 
103  virtual std::vector<MemoryCellPtr> leadingCells(const MemoryCell::Predicate&) const = 0;
104 
108  virtual void eraseMatchingCells(const MemoryCell::Predicate&) = 0;
109 
114  virtual void eraseLeadingCells(const MemoryCell::Predicate&) = 0;
115 
119  virtual void traverse(MemoryCell::Visitor&) = 0;
120 
124  }
125 
127  std::vector<MemoryCellPtr> allCells() const {
129  }
130 };
131 
132 } // namespace
133 } // namespace
134 } // namespace
135 } // namespace
136 
137 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
139 #endif
140 
141 #endif
boost::shared_ptr< class MemoryCell > MemoryCellPtr
Shared-ownership pointer to a semantic memory cell.
Definition: MemoryCell.h:15
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.
Main namespace for the ROSE library.
Base classes for instruction semantics.
virtual MemoryCell::AddressSet getWritersIntersection(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.
static MemoryCellPtr instance(const SValuePtr &address, const SValuePtr &value)
Instantiates a new memory cell object with the specified address and value.
Definition: MemoryCell.h:107
boost::shared_ptr< class MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
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 MemoryCell::AddressSet getWritersUnion(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps)=0
Writers for an address.
virtual MemoryCellPtr latestWrittenCell() const
Property: Cell most recently written.