ROSE 0.11.145.192
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#include <boost/serialization/access.hpp>
13#include <boost/serialization/nvp.hpp>
14#include <boost/serialization/shared_ptr.hpp>
15
16namespace Rose {
17namespace BinaryAnalysis {
18namespace InstructionSemantics {
19namespace BaseSemantics {
20
82
83
88class AddressSpace: public boost::enable_shared_from_this<AddressSpace> {
89public:
92
95
96private:
97 Purpose purpose_;
98 std::string name_;
99
100#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
101private:
102 friend class boost::serialization::access;
103
104 template<class S>
105 void serialize(S &s, const unsigned /*version*/) {
106 s & BOOST_SERIALIZATION_NVP(purpose_);
107 s & BOOST_SERIALIZATION_NVP(name_);
108 }
109#endif
110
111public:
112 virtual ~AddressSpace();
113protected:
114 AddressSpace(); // for de-serialization
115 AddressSpace(Purpose, const std::string &name);
117 AddressSpace& operator=(const AddressSpace&) = delete;
118
119public:
121 virtual Ptr clone() const = 0;
122
123public:
146 const std::string& name() const;
147 void name(const std::string&);
153 virtual void clear() = 0;
154
160 virtual SValuePtr read(const AddressSpaceAddress&, const SValuePtr &dflt, RiscOperators &addrOps, RiscOperators &valOps);
161
166 virtual SValuePtr peek(const AddressSpaceAddress&, const SValuePtr &dflt, RiscOperators &addrOps, RiscOperators &valOps);
167
169 virtual void write(const AddressSpaceAddress&, const SValuePtr &value, RiscOperators &addrOps, RiscOperators &valOps);
170
177 virtual void hash(Combinatorics::Hasher&, RiscOperators *addrOps, RiscOperators *valOps) const = 0;
178
182 virtual bool merge(const AddressSpacePtr &other, RiscOperators *addrOps, RiscOperators *valOps) = 0;
183
188 std::string printableName() const;
189
195 void print(std::ostream&, const std::string &prefix = "") const;
196 virtual void print(std::ostream&, Formatter&) const = 0;
201 AddressSpacePtr obj;
202 Formatter &fmt;
203 public:
205 WithFormatter() = delete;
207 void print(std::ostream&) const;
208 };
209
227 WithFormatter operator+(const std::string &linePrefix);
229};
230
231std::ostream& operator<<(std::ostream&, const AddressSpace&);
232std::ostream& operator<<(std::ostream&, const AddressSpace::WithFormatter&);
233
234} // namespace
235} // namespace
236} // namespace
237} // namespace
238
239#endif
240#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.