ROSE 0.11.145.281
AbstractLocation.h
1#ifndef ROSE_BinaryAnalysis_AbstractLocation_H
2#define ROSE_BinaryAnalysis_AbstractLocation_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <Rose/Location.h>
7#include <Rose/BinaryAnalysis/BasicTypes.h>
8#include <Rose/BinaryAnalysis/SmtSolver.h>
9
10#include <ostream>
11#include <string>
12
13namespace Rose {
14namespace BinaryAnalysis {
15
35public:
38private:
39 RegisterDescriptor reg_; // empty for absolute addresses
40 Address addr_; // null for register locations
41 size_t nBytes_ = 0; // size of memory location, or zero if unknown
42 RegisterDictionaryPtr regdict_; // not hashed or compared; only used to generate string output
43
44public:
50 virtual ~AbstractLocation();
51
54
57
72 explicit AbstractLocation(const Address&, size_t nBytes = 0);
73
81 AbstractLocation(RegisterDescriptor base, const Address &offset, size_t nBytes = 0);
86 static AbstractLocation parse(const std::string&);
87
88 // Overrides are documented in the base class.
89 virtual bool isValid() const override;
90 virtual uint64_t hash() const override;
91 virtual std::string toString() const override;
92 virtual void print(std::ostream&) const override;
93 virtual std::string printableName() const override;
94 virtual bool isEqual(const Location&) const override;
95 virtual bool operator<(const Location&) const override;
96 virtual bool operator<=(const Location&) const override;
97 virtual bool operator>(const Location&) const override;
98 virtual bool operator>=(const Location&) const override;
99
104 int compare(const AbstractLocation &other) const;
105
110 bool isRegister() const;
111
116 bool isAddress() const;
117
121 bool isAbsoluteAddress() const;
122
128 bool isRelativeAddress() const;
129
134
140
145 const Address getAddress() const;
146
151 const Address getOffset() const;
152
157 size_t nBytes() const;
158
168 bool mayAlias(const AbstractLocation &other, const SmtSolverPtr &solver = SmtSolverPtr()) const;
169
179 bool mustAlias(const AbstractLocation &other, const SmtSolverPtr &solver = SmtSolverPtr()) const;
180
187 void print(std::ostream &out, const RegisterDictionaryPtr &regdict) const;
188 void print(std::ostream &out, InstructionSemantics::BaseSemantics::Formatter &fmt) const;
189 void print(std::ostream &out, const RegisterDictionaryPtr &regdict, InstructionSemantics::BaseSemantics::Formatter &fmt) const;
191};
192
193} // namespace
194} // namespace
195
196#endif
197#endif
void print(std::ostream &out, InstructionSemantics::BaseSemantics::Formatter &fmt) const
Print an abstract location.
AbstractLocation(const AbstractLocation &)
Copy constructor.
bool isRegister() const
Checks register reference.
void print(std::ostream &out, const RegisterDictionaryPtr &regdict, InstructionSemantics::BaseSemantics::Formatter &fmt) const
Print an abstract location.
AbstractLocation(const Address &, size_t nBytes=0)
Absolute memory referent.
AbstractLocation()
Default constructor.
virtual std::string printableName() const override
Convert location to escaped, parsable string.
bool isAbsoluteAddress() const
True if this is an absolute memory location.
static AbstractLocation parse(const std::string &)
Parse an abstract location from a string.
int compare(const AbstractLocation &other) const
Compare two abstract locations.
bool mayAlias(const AbstractLocation &other, const SmtSolverPtr &solver=SmtSolverPtr()) const
True if two abstract locations could be aliases.
bool mustAlias(const AbstractLocation &other, const SmtSolverPtr &solver=SmtSolverPtr()) const
True if two abstract locations are certainly aliases.
AbstractLocation & operator=(const AbstractLocation &)
Assignment operator.
virtual void print(std::ostream &) const override
Output location to a stream.
bool isRelativeAddress() const
True if this is a register-relative memory location.
AbstractLocation(RegisterDescriptor base, const Address &offset, size_t nBytes=0)
Relative memory referent.
void print(std::ostream &out, const RegisterDictionaryPtr &regdict) const
Print an abstract location.
bool isAddress() const
Checks memory reference.
const Address getAddress() const
Returns memory absolute address.
size_t nBytes() const
Returns size of memory location in bytes.
virtual std::string toString() const override
Convert location to string.
RegisterDictionaryPtr registerDictionary() const
Property: Register dictionary.
RegisterDescriptor getRegister() const
Returns register.
const Address getOffset() const
Returns the memory offset.
AbstractLocation(RegisterDescriptor, const RegisterDictionaryPtr &regdict)
Register referent.
AbstractLocation(RegisterDescriptor base, const RegisterDictionaryPtr &, const Address &offset, size_t nBytes=0)
Relative memory referent.
virtual bool isValid() const override
Test whether this object is valid.
virtual bool isEqual(const Location &) const override
Equality and inequality.
AbstractLocation(RegisterDescriptor)
Register referent.
virtual uint64_t hash() const override
Compute a 64-bit hash of this object.
Describes (part of) a physical CPU register.
Base class for location types.
Definition Location.h:24
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
std::shared_ptr< SmtSolver > SmtSolverPtr
Reference counting pointer.
The ROSE library.