ROSE  0.11.132.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  /* Set of instruction branch targets */
41  std::set<rose_addr_t> targets() const;
42 
43  // Methods associated with basic blocks (Rose::BinaryAnalysis::Partitioner2)
44  //
45  const std::vector<BasicBlockPtr>& blocks() const;
46  void append(BasicBlockPtr bb);
47 
48 protected:
49  Method();
50  ~Method();
51  Partitioner2::FunctionPtr function_;
52  std::vector<BasicBlockPtr> blocks_;
53 };
54 
55 class Interface {
56 public:
57  virtual const std::string name() const = 0;
58 protected:
59  Interface() {}
60 };
61 
62 class Attribute {
63 public:
64  virtual const std::string name() const = 0;
65 protected:
66  Attribute() {}
67 };
68 
69 class Class {
70 public:
71  virtual const std::string name() const = 0;
72  virtual const std::string super_name() const = 0;
73  virtual const std::vector<const Field*> &fields() const = 0;
74  virtual const std::vector<const Method*> &methods() const = 0;
75  virtual const std::vector<const Attribute*> &attributes() const = 0;
76  virtual const std::vector<const Interface*> &interfaces() const = 0;
77  virtual const std::vector<std::string> &strings() = 0;
78  virtual void partition(const PartitionerPtr &partitioner) const;
79  virtual void digraph();
80 protected:
81  Class() {}
82 };
83 
84 class Namespace {
85 public:
86  virtual const std::string name() const = 0;
87  virtual const std::vector<const Class*> &classes() const = 0;
88  virtual void partition(const PartitionerPtr &partitioner) const;
89 
90 protected:
91  Namespace() {}
92 };
93 
94 class Container {
95 public:
96  virtual const std::string name() const = 0;
97  virtual const std::vector<const Namespace*> &namespaces() const = 0;
98  virtual void partition(const PartitionerPtr &partitioner) const;
99 
100 protected:
101  Container() {}
102 };
103 
104 } // namespace
105 } // namespace
106 } // namespace
107 
108 #endif
109 #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.