ROSE 0.11.145.237
AddressSpace.h
1#ifndef ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_AddressSpace_H
2#define ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_AddressSpace_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/BasicTypes.h>
6
7#include <Rose/BinaryAnalysis/Address.h>
8#include <Rose/BinaryAnalysis/RegisterDescriptor.h>
9#include <Combinatorics.h> // ROSE
10
11#include <boost/enable_shared_from_this.hpp>
12
13#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
14#include <boost/serialization/access.hpp>
15#include <boost/serialization/nvp.hpp>
16#include <boost/serialization/shared_ptr.hpp>
17#endif
18
19namespace Rose {
20namespace BinaryAnalysis {
21namespace InstructionSemantics {
22namespace BaseSemantics {
23
85
86
91class AddressSpace: public boost::enable_shared_from_this<AddressSpace> {
92public:
95
98
99private:
100 Purpose purpose_;
101 std::string name_;
102
103#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
104private:
105 friend class boost::serialization::access;
106
107 template<class S>
108 void serialize(S &s, const unsigned /*version*/) {
109 s & BOOST_SERIALIZATION_NVP(purpose_);
110 s & BOOST_SERIALIZATION_NVP(name_);
111 }
112#endif
113
114public:
115 virtual ~AddressSpace();
116protected:
117 AddressSpace(); // for de-serialization
118 AddressSpace(Purpose, const std::string &name);
120 AddressSpace& operator=(const AddressSpace&) = delete;
121
122public:
124 virtual Ptr clone() const = 0;
125
126public:
149 const std::string& name() const;
150 void name(const std::string&);
156 virtual void clear() = 0;
157
163 virtual SValuePtr read(const AddressSpaceAddress&, const SValuePtr &dflt, RiscOperators &addrOps, RiscOperators &valOps);
164
169 virtual SValuePtr peek(const AddressSpaceAddress&, const SValuePtr &dflt, RiscOperators &addrOps, RiscOperators &valOps);
170
172 virtual void write(const AddressSpaceAddress&, const SValuePtr &value, RiscOperators &addrOps, RiscOperators &valOps);
173
180 virtual void hash(Combinatorics::Hasher&, RiscOperators *addrOps, RiscOperators *valOps) const = 0;
181
185 virtual bool merge(const AddressSpacePtr &other, RiscOperators *addrOps, RiscOperators *valOps) = 0;
186
191 std::string printableName() const;
192
198 void print(std::ostream&, const std::string &prefix = "") const;
199 virtual void print(std::ostream&, Formatter&) const = 0;
204 AddressSpacePtr obj;
205 Formatter &fmt;
206 public:
208 WithFormatter() = delete;
210 void print(std::ostream&) const;
211 };
212
230 WithFormatter operator+(const std::string &linePrefix);
232};
233
234std::ostream& operator<<(std::ostream&, const AddressSpace&);
235std::ostream& operator<<(std::ostream&, const AddressSpace::WithFormatter&);
236
237} // namespace
238} // namespace
239} // namespace
240} // namespace
241
242#endif
243#endif
AddressSpaceAddress(RegisterDescriptor)
Construct an address that's a concrete register.
Sawyer::Optional< Address > toConcrete() const
Convert an address to a concrete value if possible.
SValuePtr toAbstract(RiscOperators &addrOps) const
Convert an address to an abstract value if possible.
AddressSpaceAddress(Address)
Construct an address that's a concrete value.
RegisterDescriptor registerDescriptor() const
Return the underlying address.
AddressSpaceAddress(const SValuePtr &)
Construct an address that's an abstract value.
const Sawyer::Optional< Address > & concrete() const
Return the underlying address.
const std::string & name() const
Property: Name for this address space.
void purpose(Purpose)
Property: Purpose of this address space.
virtual void write(const AddressSpaceAddress &, const SValuePtr &value, RiscOperators &addrOps, RiscOperators &valOps)
Write a value to an address space.
virtual SValuePtr peek(const AddressSpaceAddress &, const SValuePtr &dflt, RiscOperators &addrOps, RiscOperators &valOps)
Read without causing side effects.
virtual Ptr clone() const =0
Deep-copy of this address space.
WithFormatter with_format(Formatter &)
Used for printing address spaces with formatting.
virtual SValuePtr read(const AddressSpaceAddress &, const SValuePtr &dflt, RiscOperators &addrOps, RiscOperators &valOps)
Read a value from the address space.
void print(std::ostream &, const std::string &prefix="") const
Print an address space.
virtual void hash(Combinatorics::Hasher &, RiscOperators *addrOps, RiscOperators *valOps) const =0
Hash this address space.
WithFormatter operator+(Formatter &)
Used for printing address spaces with formatting.
AddressSpacePurpose Purpose
Purpose for the address space.
std::string printableName() const
Printable name for this address space.
void name(const std::string &)
Property: Name for this address space.
WithFormatter operator+(const std::string &linePrefix)
Used for printing address spaces with formatting.
virtual void print(std::ostream &, Formatter &) const =0
Print an address space.
Purpose purpose() const
Property: Purpose of this address space.
virtual bool merge(const AddressSpacePtr &other, RiscOperators *addrOps, RiscOperators *valOps)=0
Merge address spaces for data flow analysis.
Base class for most instruction semantics RISC operators.
Describes (part of) a physical CPU register.
Holds a value or nothing.
Definition Optional.h:56
Base classes for instruction semantics.
boost::shared_ptr< AddressSpace > AddressSpacePtr
Shared-ownership pointer for AddressSpace objects.
std::uint64_t Address
Address.
Definition Address.h:11
The ROSE library.