ROSE 2.1.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
7#include <Rose/BinaryAnalysis/ByteOrder.h>
8
9#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
10#include <boost/serialization/access.hpp>
11#include <boost/serialization/export.hpp>
12#include <boost/serialization/shared_ptr.hpp>
13#endif
14
15namespace Rose {
16namespace BinaryAnalysis {
17namespace InstructionSemantics {
18namespace BaseSemantics {
19
21// Memory State
23
28public:
31
32private:
33 SValuePtr addrProtoval_;
34 SValuePtr valProtoval_;
35 ByteOrder::Endianness byteOrder_;
36 MergerPtr merger_;
37 bool byteRestricted_; // are cell values all exactly one byte wide?
38
40 // Serialization
41#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
42private:
43 friend class boost::serialization::access;
44
45 template<class S>
46 void serialize(S &s, const unsigned /*version*/) {
47 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(AddressSpace);
48 s & BOOST_SERIALIZATION_NVP(addrProtoval_);
49 s & BOOST_SERIALIZATION_NVP(valProtoval_);
50 s & BOOST_SERIALIZATION_NVP(byteOrder_);
51 //s & merger_ -- not saved
52 s & BOOST_SERIALIZATION_NVP(byteRestricted_);
53 }
54#endif
55
56
58 // Real constructors
59protected:
60 MemoryState(); // for serialization
61
62 MemoryState(Purpose, const std::string &name, const SValuePtr &valProtoval); // for deriving classes
63 MemoryState(const SValuePtr &addrProtoval, const SValuePtr &valProtoval);
64 MemoryState(const MemoryStatePtr &other);
65
66public:
67 virtual ~MemoryState();
68
70 // Static allocating constructors. None needed since this class is abstract
71
73 // Virtual constructors
74public:
81 virtual MemoryStatePtr create(const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const = 0;
82
84 // Dynamic pointer casts. No-op since this is the base class.
85public:
86 static MemoryStatePtr promote(const AddressSpacePtr&);
87
89 // Methods first declared at this level of the class hierarchy
90public:
100 void merger(const MergerPtr&);
106
110
112 virtual void clear() = 0;
113
121 bool byteRestricted() const;
122 void byteRestricted(bool);
150 virtual SValuePtr readMemory(const SValuePtr &address, const SValuePtr &dflt,
151 RiscOperators *addrOps, RiscOperators *valOps) = 0;
152
157 virtual SValuePtr peekMemory(const SValuePtr &address, const SValuePtr &dflt,
158 RiscOperators *addrOps, RiscOperators *valOps) = 0;
159
169 virtual void writeMemory(const SValuePtr &addr, const SValuePtr &value,
170 RiscOperators *addrOps, RiscOperators *valOps) = 0;
171
172 virtual SValuePtr readLocal(uint8_t index);
173 virtual void writeLocal(uint8_t index, const SValuePtr &value);
174
178 virtual void pushOperand(const SValuePtr &value);
179
184};
185
186} // namespace
187} // namespace
188} // namespace
189} // namespace
190
191#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
193#endif
194
195#endif
196#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 popOperand()
Pop an operand value from a frame.
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 to a frame.
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.