ROSE  0.11.137.0
Analysis.h
1 #ifndef ROSE_BinaryAnalysis_ByteCode_Analysis_H
2 #define ROSE_BinaryAnalysis_ByteCode_Analysis_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
5 
6 #include <Rose/BinaryAnalysis/Disassembler/BasicTypes.h>
7 #include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
8 
9 namespace Rose {
10 namespace BinaryAnalysis {
11 namespace ByteCode {
12 
13 using BasicBlockPtr = Partitioner2::BasicBlockPtr;
14 using PartitionerPtr = Partitioner2::PartitionerPtr;
15 
16 class Code {
17 public:
18  virtual const uint8_t* bytes() const = 0;
19  virtual const size_t size() const = 0;
20  virtual const rose_addr_t offset() const = 0;
21 
22 protected:
23  Code() {}
24 };
25 
26 class Field {
27 public:
28  virtual const std::string name() const = 0;
29 protected:
30  Field() {}
31 };
32 
33 class Method {
34 public:
35  virtual const std::string name() const = 0;
36  virtual const Code & code() const = 0;
37  virtual const void decode(const Disassembler::BasePtr&) const = 0;
38  virtual const SgAsmInstructionList* instructions() const = 0;
39 
40  /* Annotate the AST (.e.g., add comments to instructions) */
41  virtual void annotate() = 0;
42 
43  /* Set of instruction branch targets */
44  std::set<rose_addr_t> targets() const;
45 
46  // Methods associated with basic blocks (Rose::BinaryAnalysis::Partitioner2)
47  //
48  const std::vector<BasicBlockPtr>& blocks() const;
49  void append(BasicBlockPtr bb);
50 
51 protected:
52  Method();
53  ~Method();
54  Partitioner2::FunctionPtr function_;
55  std::vector<BasicBlockPtr> blocks_;
56 };
57 
58 class Interface {
59 public:
60  virtual const std::string name() const = 0;
61 protected:
62  Interface() {}
63 };
64 
65 class Attribute {
66 public:
67  virtual const std::string name() const = 0;
68 protected:
69  Attribute() {}
70 };
71 
72 class Class {
73 public:
74  virtual const std::string name() const = 0;
75  virtual const std::string super_name() const = 0;
76  virtual const std::vector<const Field*> &fields() const = 0;
77  virtual const std::vector<const Method*> &methods() const = 0;
78  virtual const std::vector<const Attribute*> &attributes() const = 0;
79  virtual const std::vector<const Interface*> &interfaces() const = 0;
80  virtual const std::vector<std::string> &strings() = 0;
81  virtual void partition(const PartitionerPtr &partitioner) const;
82  virtual void digraph();
83 protected:
84  Class() {}
85 };
86 
87 class Namespace {
88 public:
89  virtual const std::string name() const = 0;
90  virtual const std::vector<const Class*> &classes() const = 0;
91  virtual void partition(const PartitionerPtr &partitioner) const;
92 
93 protected:
94  Namespace() {}
95 };
96 
97 class Container {
98 public:
99  virtual const std::string name() const = 0;
100  virtual const std::vector<const Namespace*> &namespaces() const = 0;
101  virtual void partition(const PartitionerPtr &partitioner) const;
102 
103 protected:
104  Container() {}
105 };
106 
107 } // namespace
108 } // namespace
109 } // namespace
110 
111 #endif
112 #endif
Main namespace for the ROSE library.
Sawyer::SharedPointer< BasicBlock > BasicBlockPtr
Shared-ownersip pointer for BasicBlock.
Sawyer::SharedPointer< Partitioner > PartitionerPtr
Shared-ownership pointer for Partitioner.
List of SgAsmInstruction nodes.