ROSE 2.15.0
Loading...
Searching...
No Matches
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 std::string label() const;
157
161 virtual void clear() = 0;
162
168 virtual SValuePtr read(const AddressSpaceAddress&, const SValuePtr &dflt, RiscOperators &addrOps, RiscOperators &valOps);
169
174 virtual SValuePtr peek(const AddressSpaceAddress&, const SValuePtr &dflt, RiscOperators &addrOps, RiscOperators &valOps);
175
177 virtual void write(const AddressSpaceAddress&, const SValuePtr &value, RiscOperators &addrOps, RiscOperators &valOps);
178
185 virtual void hash(Combinatorics::Hasher&, RiscOperators *addrOps, RiscOperators *valOps) const = 0;
186
190 virtual bool merge(const AddressSpacePtr &other, RiscOperators *addrOps, RiscOperators *valOps) = 0;
191
196 std::string printableName() const;
197
203 void print(std::ostream&, const std::string &prefix = "") const;
204 virtual void print(std::ostream&, Formatter&) const = 0;
209 AddressSpacePtr obj;
210 Formatter &fmt;
211 public:
213 WithFormatter() = delete;
215 void print(std::ostream&) const;
216 };
217
235 WithFormatter operator+(const std::string &linePrefix);
237};
238
239std::ostream& operator<<(std::ostream&, const AddressSpace&);
240std::ostream& operator<<(std::ostream&, const AddressSpace::WithFormatter&);
241
242} // namespace
243} // namespace
244} // namespace
245} // namespace
246
247#endif
248#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 std::string label() const
Label for this address space.
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:54
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.