ROSE  0.11.101.0
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/InstructionSemantics/BaseSemantics/Types.h>
9 #include <Rose/BinaryAnalysis/SmtSolver.h>
10 
11 #include <ostream>
12 #include <string>
13 
14 namespace Rose {
15 namespace BinaryAnalysis {
16 
33 class AbstractLocation: public Location {
34 public:
37 private:
38  RegisterDescriptor reg_;
39  Address addr_;
40  size_t nBytes_ = 0; // size of memory location, or zero if unknown
41  RegisterDictionaryPtr regdict_;
42 
43 public:
49  virtual ~AbstractLocation();
50 
53 
56 
69  explicit AbstractLocation(const Address&, size_t nBytes = 0);
70 
72  static AbstractLocation parse(const std::string&);
73 
74  virtual bool isValid() const override;
75  virtual std::string toString() const override;
76  virtual void print(std::ostream&) const override;
77  virtual std::string printableName() const override;
78  virtual bool isEqual(const Location&) const override;
79  virtual bool operator<(const Location&) const override;
80  virtual bool operator<=(const Location&) const override;
81  virtual bool operator>(const Location&) const override;
82  virtual bool operator>=(const Location&) const override;
83 
88  int compare(const AbstractLocation &other) const;
89 
94  bool isRegister() const;
95 
100  bool isAddress() const;
101 
108 
113  const Address getAddress() const;
114 
119  size_t nBytes() const;
120 
130  bool mayAlias(const AbstractLocation &other, const SmtSolverPtr &solver = SmtSolverPtr()) const;
131 
141  bool mustAlias(const AbstractLocation &other, const SmtSolverPtr &solver = SmtSolverPtr()) const;
142 
149  void print(std::ostream &out, const RegisterDictionaryPtr &regdict) const;
150  void print(std::ostream &out, InstructionSemantics::BaseSemantics::Formatter &fmt) const;
151  void print(std::ostream &out, const RegisterDictionaryPtr &regdict, InstructionSemantics::BaseSemantics::Formatter &fmt) const;
153 };
154 
155 } // namespace
156 } // namespace
157 
158 #endif
159 #endif
virtual bool isEqual(const Location &) const override
Equality and inequality.
virtual std::string toString() const override
Convert location to string.
size_t nBytes() const
Returns size of memory location in bytes.
AbstractLocation()
Default constructor.
Main namespace for the ROSE library.
static AbstractLocation parse(const std::string &)
Parse an abstract location from a string.
RegisterDescriptor getRegister() const
Returns register.
const Address getAddress() const
Returns memory address.
Describes (part of) a physical CPU register.
Base class for location types.
Definition: Location.h:23
virtual bool isValid() const override
Test whether this object is valid.
int compare(const AbstractLocation &other) const
Compare two abstract locations.
bool isAddress() const
Checks memory reference.
Binary analysis.
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
bool mayAlias(const AbstractLocation &other, const SmtSolverPtr &solver=SmtSolverPtr()) const
True if two abstract locations could be aliases.
virtual std::string printableName() const override
Convert location to escaped, parsable string.
bool mustAlias(const AbstractLocation &other, const SmtSolverPtr &solver=SmtSolverPtr()) const
True if two abstract locations are certainly aliases.
virtual void print(std::ostream &) const override
Output location to a stream.
bool isRegister() const
Checks register reference.
AbstractLocation & operator=(const AbstractLocation &)
Assignment operator.