ROSE  0.10.7.0
MemoryCellState.h
1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics2_MemoryCellState_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics2_MemoryCellState_H
3 #include <rosePublicConfig.h>
4 #ifdef ROSE_BUILD_BINARY_ANALYSIS_SUPPORT
5 
6 #include <BaseSemantics2.h>
7 #include <MemoryCell.h>
8 
9 #include <boost/serialization/access.hpp>
10 #include <boost/serialization/base_object.hpp>
11 #include <boost/serialization/export.hpp>
12 
13 namespace Rose {
14 namespace BinaryAnalysis {
15 namespace InstructionSemantics2 {
16 namespace BaseSemantics {
17 
19 typedef boost::shared_ptr<class MemoryCellState> MemoryCellStatePtr;
20 
24 class MemoryCellState: public MemoryState {
25 protected:
26  MemoryCellPtr protocell; // prototypical memory cell used for its virtual constructors
27  MemoryCellPtr latestWrittenCell_; // the cell whose value was most recently written to, if any
28 
29 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
30 private:
31  friend class boost::serialization::access;
32 
33  template<class S>
34  void serialize(S &s, const unsigned /*version*/) {
35  s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(MemoryState);
36  s & BOOST_SERIALIZATION_NVP(protocell);
37  s & BOOST_SERIALIZATION_NVP(latestWrittenCell_);
38  }
39 #endif
40 
41 protected:
42  MemoryCellState() {} // for serialization
43 
44  explicit MemoryCellState(const MemoryCellPtr &protocell)
45  : MemoryState(protocell->get_address(), protocell->get_value()), protocell(protocell) {}
46 
47  MemoryCellState(const SValuePtr &addrProtoval, const SValuePtr &valProtoval)
48  : MemoryState(addrProtoval, valProtoval), protocell(MemoryCell::instance(addrProtoval, valProtoval)) {}
49 
50  MemoryCellState(const MemoryCellState &other)
51  : MemoryState(other), protocell(other.protocell) {} // latestWrittenCell_ is cleared
52 
53 public:
56  static MemoryCellStatePtr promote(const BaseSemantics::MemoryStatePtr &m) {
57  MemoryCellStatePtr retval = boost::dynamic_pointer_cast<MemoryCellState>(m);
58  ASSERT_not_null(retval);
59  return retval;
60  }
61 
62 public:
63  virtual void clear() ROSE_OVERRIDE;
64 
65 public:
69  virtual MemoryCellPtr latestWrittenCell() const {
70  return latestWrittenCell_;
71  }
72  virtual void latestWrittenCell(const MemoryCellPtr &cell) {
73  latestWrittenCell_ = cell;
74  }
83  virtual MemoryCell::AddressSet getWritersUnion(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps,
84  RiscOperators *valOps) = 0;
85 
92  virtual MemoryCell::AddressSet getWritersIntersection(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps,
93  RiscOperators *valOps) = 0;
94 
98  virtual std::vector<MemoryCellPtr> matchingCells(const MemoryCell::Predicate&) const = 0;
99 
105  virtual std::vector<MemoryCellPtr> leadingCells(const MemoryCell::Predicate&) const = 0;
106 
110  virtual void eraseMatchingCells(const MemoryCell::Predicate&) = 0;
111 
116  virtual void eraseLeadingCells(const MemoryCell::Predicate&) = 0;
117 
121  virtual void traverse(MemoryCell::Visitor&) = 0;
122 
126  }
127 
129  std::vector<MemoryCellPtr> allCells() const {
131  }
132 };
133 
134 } // namespace
135 } // namespace
136 } // namespace
137 } // namespace
138 
139 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
141 #endif
142 
143 #endif
144 #endif
boost::shared_ptr< class MemoryCell > MemoryCellPtr
Shared-ownership pointer to a semantic memory cell.
Definition: MemoryCell.h:17
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 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:110
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.