ROSE 2.9.0
Loading...
Searching...
No Matches
MemoryState.h
1#ifndef ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_MemoryState_H
2#define ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_MemoryState_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/AddressSpace.h>
6#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/SValue.h>
7
8#include <Rose/BinaryAnalysis/ByteOrder.h>
9
10#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
11#include <boost/serialization/access.hpp>
12#include <boost/serialization/export.hpp>
13#include <boost/serialization/shared_ptr.hpp>
14#endif
15
16namespace Rose {
17namespace BinaryAnalysis {
18namespace InstructionSemantics {
19namespace BaseSemantics {
20
22// Memory State
24
29public:
32
33private:
34 SValuePtr addrProtoval_;
35 SValuePtr valProtoval_;
36 ByteOrder::Endianness byteOrder_;
37 MergerPtr merger_;
38 bool byteRestricted_; // are cell values all exactly one byte wide?
39
41 // Serialization
42#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
43private:
44 friend class boost::serialization::access;
45
46 template<class S>
47 void serialize(S &s, const unsigned /*version*/) {
48 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(AddressSpace);
49 s & BOOST_SERIALIZATION_NVP(addrProtoval_);
50 s & BOOST_SERIALIZATION_NVP(valProtoval_);
51 s & BOOST_SERIALIZATION_NVP(byteOrder_);
52 //s & merger_ -- not saved
53 s & BOOST_SERIALIZATION_NVP(byteRestricted_);
54 }
55#endif
56
57
59 // Real constructors
60protected:
61 MemoryState(); // for serialization
62
63 MemoryState(Purpose, const std::string &name, const SValuePtr &valProtoval); // for deriving classes
64 MemoryState(const SValuePtr &addrProtoval, const SValuePtr &valProtoval);
65 MemoryState(const MemoryStatePtr &other);
66
67public:
68 virtual ~MemoryState();
69
71 // Static allocating constructors. None needed since this class is abstract
72
74 // Virtual constructors
75public:
82 virtual MemoryStatePtr create(const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const = 0;
83
85 // Dynamic pointer casts. No-op since this is the base class.
86public:
87 static MemoryStatePtr promote(const AddressSpacePtr&);
88
90 // Methods first declared at this level of the class hierarchy
91public:
101 void merger(const MergerPtr&);
107
111
113 virtual void clear() = 0;
114
122 bool byteRestricted() const;
123 void byteRestricted(bool);
151 virtual SValuePtr readMemory(const SValuePtr &address, const SValuePtr &dflt,
152 RiscOperators *addrOps, RiscOperators *valOps) = 0;
153
158 virtual SValuePtr peekMemory(const SValuePtr &address, const SValuePtr &dflt,
159 RiscOperators *addrOps, RiscOperators *valOps) = 0;
160
170 virtual void writeMemory(const SValuePtr &addr, const SValuePtr &value,
171 RiscOperators *addrOps, RiscOperators *valOps) = 0;
172
173 virtual SValuePtr readLocal(size_t index) const;
174 virtual void writeLocal(size_t index, const SValuePtr &value);
175
179 virtual SValuePtr peekOperand(size_t depth = 0);
180
185
189 virtual void pushOperand(const SValuePtr &value);
190};
191
192} // namespace
193} // namespace
194} // namespace
195} // namespace
196
197#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
199#endif
200
201#endif
202#endif
const std::string & name() const
Property: Name for this address space.
AddressSpacePurpose Purpose
Purpose for the address space.
void set_byteOrder(ByteOrder::Endianness)
Memory byte order.
virtual MemoryStatePtr create(const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const =0
Virtual allocating constructor.
virtual SValuePtr peekMemory(const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps)=0
Read a value from memory without side effects.
SValuePtr get_val_protoval() const
Return the value protoval.
virtual void writeMemory(const SValuePtr &addr, const SValuePtr &value, RiscOperators *addrOps, RiscOperators *valOps)=0
Write a value to memory.
ByteOrder::Endianness get_byteOrder() const
Memory byte order.
virtual void pushOperand(const SValuePtr &value)
Push an operand value.
virtual SValuePtr peekOperand(size_t depth=0)
Peek at an operand value.
SValuePtr get_addr_protoval() const
Return the address protoval.
bool byteRestricted() const
Indicates whether memory cell values are required to be eight bits wide.
virtual SValuePtr readMemory(const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps)=0
Read a value from memory.
void byteRestricted(bool)
Indicates whether memory cell values are required to be eight bits wide.
Base class for most instruction semantics RISC operators.
Base classes for instruction semantics.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
boost::shared_ptr< AddressSpace > AddressSpacePtr
Shared-ownership pointer for AddressSpace objects.
The ROSE library.