1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_MemoryCellList_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_MemoryCellList_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
6 #include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/MemoryCellState.h>
7 #include <Rose/BinaryAnalysis/InstructionSemantics/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 InstructionSemantics {
49 bool occlusionsErased_;
53 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
55 friend class boost::serialization::access;
58 void serialize(S &s,
const unsigned ) {
60 s & BOOST_SERIALIZATION_NVP(cells);
61 s & BOOST_SERIALIZATION_NVP(occlusionsErased_);
69 : occlusionsErased_(false) {}
72 : MemoryCellState(protocell), occlusionsErased_(false) {}
75 : MemoryCellState(addrProtoval, valProtoval), occlusionsErased_(false) {}
78 MemoryCellList(
const MemoryCellList &other)
79 : MemoryCellState(other), occlusionsErased_(other.occlusionsErased_) {
80 for (CellList::const_iterator ci=other.cells.begin(); ci!=other.cells.end(); ++ci)
81 cells.push_back((*ci)->clone());
100 static MemoryCellListPtr
instance(
const MemoryCellListPtr &other) {
109 return instance(addrProtoval, valProtoval);
127 MemoryCellListPtr retval = boost::dynamic_pointer_cast<
MemoryCellList>(m);
128 ASSERT_not_null(retval);
135 virtual void clear()
override;
217 template<
class Iterator>
220 ASSERT_not_null(addr);
223 for (; cursor!=cells.end(); ++cursor) {
224 if (tempCell->mayAlias(*cursor, addrOps)) {
225 retval.push_back(*cursor);
226 if (tempCell->mustAlias(*cursor, addrOps))
270 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
Base classes for instruction semantics.
virtual void writeMemory(const SValuePtr &addr, const SValuePtr &value, RiscOperators *addrOps, RiscOperators *valOps) override
Write a value to memory.
Simple list-based memory state.
boost::shared_ptr< class MemoryCellList > MemoryCellListPtr
Shared-ownership pointer to a list-based 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.
static MemoryCellListPtr instance(const MemoryCellListPtr &other)
Instantiate a new copy of an existing memory state.
virtual SValuePtr undefined_(size_t nbits)
Returns a new undefined value.
void occlusionsErased(bool b)
Property: erase occluded cells.
Main namespace for the ROSE library.
CellList scan(Iterator &cursor, const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps) const
Scan cell list to find matching cells.
virtual void hash(Combinatorics::Hasher &, RiscOperators *addrOps, RiscOperators *valOps) const override
Calculate a hash for this memory state.
boost::shared_ptr< MemoryCell > MemoryCellPtr
Shared-ownership pointer to a memory cell.
virtual MemoryStatePtr clone() const override
Virtual allocating copy constructor.
virtual void print(std::ostream &, Formatter &) const override
Print a memory state to more than one line of output.
bool occlusionsErased() const
Property: erase occluded cells.
virtual void eraseMatchingCells(MemoryCell::Predicate &) override
Remove all matching cells.
static MemoryCellListPtr instance(const SValuePtr &addrProtoval, const SValuePtr &valProtoval)
Instantiate a new prototypical memory state.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
virtual CellList & get_cells()
Returns the list of all memory cells.
virtual std::vector< MemoryCellPtr > matchingCells(MemoryCell::Predicate &) const override
Find all matching cells.
virtual void traverse(MemoryCell::Visitor &) override
Traverse and modify cells.
bool mergeWithAliasing(const MemoryStatePtr &other, RiscOperators *addrOps, RiscOperators *valOps)
Merge two states with aliasing.
virtual MemoryStatePtr create(const MemoryCellPtr &protocell) const
Virtual allocating constructor.
virtual MemoryStatePtr create(const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const override
Virtual allocating constructor.
std::list< MemoryCellPtr > CellList
List of memory cells.
virtual SValuePtr readMemory(const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps) override
Read a value from memory.
virtual bool merge(const MemoryStatePtr &other, RiscOperators *addrOps, RiscOperators *valOps) override
Merge memory states for data flow analysis.
virtual AddressSet getWritersUnion(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps) override
Writers for an address.
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
MemoryCellListPtr Ptr
Shared-ownership pointer.
virtual void clear() override
Clear memory.
bool mergeNoAliasing(const MemoryStatePtr &other, RiscOperators *addrOps, RiscOperators *valOps)
Merge two states without aliasing.
static MemoryCellListPtr instance(const MemoryCellPtr &protocell)
Instantiate a new memory state with prototypical memory cell.
virtual std::vector< MemoryCellPtr > leadingCells(MemoryCell::Predicate &) const override
Find leading matching cells.
virtual bool isAllPresent(const SValuePtr &address, size_t nBytes, RiscOperators *addrOps, RiscOperators *valOps) const
Predicate to determine whether all bytes are present.
Predicate for matching cells.
virtual void eraseLeadingCells(MemoryCell::Predicate &) override
Remove leading matching cells.
Base class for most instruction semantics RISC operators.
Visitor for traversing a cells.
virtual const CellList & get_cells() const
Returns the list of all memory cells.
virtual AddressSet getWritersIntersection(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps) override
Writers for an address.