1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics2_BaseSemantics_MemoryCellList_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics2_BaseSemantics_MemoryCellList_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
6 #include <Rose/BinaryAnalysis/InstructionSemantics2/BaseSemantics/MemoryCellState.h>
7 #include <Rose/BinaryAnalysis/InstructionSemantics2/BaseSemantics/RiscOperators.h>
9 #include <boost/serialization/access.hpp>
10 #include <boost/serialization/base_object.hpp>
11 #include <boost/serialization/export.hpp>
14 namespace BinaryAnalysis {
15 namespace InstructionSemantics2 {
50 bool occlusionsErased_;
54 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
56 friend class boost::serialization::access;
59 void serialize(S &s,
const unsigned ) {
61 s & BOOST_SERIALIZATION_NVP(cells);
62 s & BOOST_SERIALIZATION_NVP(occlusionsErased_);
70 : occlusionsErased_(false) {}
73 : MemoryCellState(protocell), occlusionsErased_(false) {}
76 : MemoryCellState(addrProtoval, valProtoval), occlusionsErased_(false) {}
79 MemoryCellList(
const MemoryCellList &other)
80 : MemoryCellState(other), occlusionsErased_(other.occlusionsErased_) {
81 for (CellList::const_iterator ci=other.cells.begin(); ci!=other.cells.end(); ++ci)
82 cells.push_back((*ci)->clone());
101 static MemoryCellListPtr
instance(
const MemoryCellListPtr &other) {
110 return instance(addrProtoval, valProtoval);
128 MemoryCellListPtr retval = boost::dynamic_pointer_cast<
MemoryCellList>(m);
129 ASSERT_not_null(retval);
136 virtual void clear()
override;
218 template<
class Iterator>
221 ASSERT_not_null(addr);
224 for (; cursor!=cells.end(); ++cursor) {
225 if (tempCell->mayAlias(*cursor, addrOps)) {
226 retval.push_back(*cursor);
227 if (tempCell->mustAlias(*cursor, addrOps))
236 virtual const CellList&
get_cells()
const {
return cells; }
252 virtual AddressSet mergeCellWriters(
const CellList &cells);
259 virtual void updateReadProperties(CellList &cells);
275 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
virtual void print(std::ostream &, Formatter &) const override
Print a memory state to more than one line of output.
virtual SValuePtr undefined_(size_t nbits)
Returns a new undefined value.
virtual MemoryStatePtr clone() const override
Virtual allocating copy constructor.
boost::shared_ptr< class MemoryCellState > MemoryCellStatePtr
Shared-ownership pointer to a cell-based memory state.
virtual const CellList & get_cells() const
Returns the list of all memory cells.
virtual void writeMemory(const SValuePtr &addr, const SValuePtr &value, RiscOperators *addrOps, RiscOperators *valOps) override
Write a value to memory.
bool mergeWithAliasing(const MemoryStatePtr &other, RiscOperators *addrOps, RiscOperators *valOps)
Merge two states with aliasing.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
virtual void clear() override
Clear memory.
virtual std::vector< MemoryCellPtr > leadingCells(MemoryCell::Predicate &) const override
Find leading matching cells.
Main namespace for the ROSE library.
static MemoryCellListPtr instance(const MemoryCellPtr &protocell)
Instantiate a new memory state with prototypical memory cell.
virtual bool merge(const MemoryStatePtr &other, RiscOperators *addrOps, RiscOperators *valOps) override
Merge memory states for data flow analysis.
virtual MemoryStatePtr create(const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const override
Virtual allocating constructor.
Predicate for matching cells.
virtual AddressSet getWritersIntersection(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps) override
Writers for an address.
MemoryCellStatePtr Ptr
Shared-ownership pointer.
virtual MemoryStatePtr create(const MemoryCellPtr &protocell) const
Virtual allocating constructor.
boost::shared_ptr< class MemoryCellList > MemoryCellListPtr
Shared-ownership pointer to a list-based memory state.
Base classes for instruction semantics.
static MemoryCellListPtr instance(const SValuePtr &addrProtoval, const SValuePtr &valProtoval)
Instantiate a new prototypical memory state.
virtual void eraseMatchingCells(MemoryCell::Predicate &) override
Remove all matching cells.
virtual std::vector< MemoryCellPtr > matchingCells(MemoryCell::Predicate &) const override
Find all matching cells.
bool occlusionsErased() const
Property: erase occluded cells.
virtual AddressSet getWritersUnion(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps) override
Writers for an address.
Base class for most instruction semantics RISC operators.
boost::shared_ptr< MemoryCell > MemoryCellPtr
Shared-ownership pointer to a memory cell.
CellList scan(Iterator &cursor, const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps) const
Scan cell list to find matching cells.
virtual void eraseLeadingCells(MemoryCell::Predicate &) override
Remove leading matching cells.
std::list< MemoryCellPtr > CellList
List of memory cells.
virtual CellList & get_cells()
Returns the list of all memory cells.
virtual SValuePtr readMemory(const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps) override
Read a value from memory.
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
bool mergeNoAliasing(const MemoryStatePtr &other, RiscOperators *addrOps, RiscOperators *valOps)
Merge two states without aliasing.
virtual void hash(Combinatorics::Hasher &, RiscOperators *addrOps, RiscOperators *valOps) const override
Calculate a hash for this memory state.
virtual SValuePtr peekMemory(const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps) override
Read a value from memory without side effects.
static MemoryCellListPtr promote(const BaseSemantics::MemoryStatePtr &m)
Promote a base memory state pointer to a BaseSemantics::MemoryCellList pointer.
Visitor for traversing a cells.
virtual void traverse(MemoryCell::Visitor &) override
Traverse and modify cells.
static MemoryCellListPtr instance(const MemoryCellListPtr &other)
Instantiate a new copy of an existing memory state.
Simple list-based memory state.
void occlusionsErased(bool b)
Property: erase occluded cells.
virtual bool isAllPresent(const SValuePtr &address, size_t nBytes, RiscOperators *addrOps, RiscOperators *valOps) const
Predicate to determine whether all bytes are present.