ROSE  0.11.98.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/Jvm.h>
7 #include <Rose/BinaryAnalysis/Partitioner2/Partitioner.h>
8 
9 namespace Rose {
10 namespace BinaryAnalysis {
11 namespace ByteCode {
12 
13 using BasicBlockPtr = Partitioner2::BasicBlock::Ptr;
14 
15 class Code {
16 public:
17  virtual const uint8_t* bytes() const = 0;
18  virtual const size_t size() const = 0;
19 protected:
20  Code() {}
21 };
22 
23 class Field {
24 public:
25  virtual const std::string name() const = 0;
26 protected:
27  Field() {}
28 };
29 
30 class Method {
31 public:
32  virtual const std::string name() const = 0;
33  virtual const Code & code() const = 0;
34  virtual const void decode(const Disassembler::BasePtr&) const = 0;
35  virtual const SgAsmInstructionList* instructions() const = 0;
36 
37  /* Set of instruction branch targets */
38  std::set<rose_addr_t> targets() const;
39 
40  // Methods associated with basic blocks (Rose::BinaryAnalysis::Partitioner2)
41  //
42  const std::vector<BasicBlockPtr>& blocks() const {
43  return blocks_;
44  }
45  void append(BasicBlockPtr bb) {
46  blocks_.push_back(bb);
47  }
48 
49 protected:
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();
79  virtual void digraph();
80 protected:
81  Class() {}
82 };
83 
84 } // namespace
85 } // namespace
86 } // namespace
87 
88 #endif
89 #endif
Main namespace for the ROSE library.
Binary analysis.
Sawyer::SharedPointer< BasicBlock > Ptr
Shared pointer to a basic block.
Definition: BasicBlock.h:134
List of SgAsmInstruction nodes.