Pass the InformationManager inside the BasicBlock and Function classes
[frida/frida.git] / src / core / BasicBlock.hxx
1 #ifndef INCLUDE__BasicBlock_hxx
2 #define INCLUDE__BasicBlock_hxx
3
4 #include <cassert>
5 #include <string>
6 #include <sstream>
7
8 class Disassembler;
9 class InformationManager;
10
11 class BasicBlock {
12 public:
13 BasicBlock(uint64_t start_address, Disassembler * disassembler,
14 InformationManager* manager)
15 : start_address(start_address)
16 , disassembler(disassembler)
17 , manager(manager) {
18 next_blocks[0] = 0;
19 next_blocks[1] = 0;
20 }
21
22 uint64_t getStartAddress() const {
23 return start_address;
24 }
25
26 uint64_t getEndAddress() const {
27 return end_address;
28 }
29
30 uint64_t getNextBlock(size_t index) const {
31 assert(index < 2);
32 return next_blocks[index];
33 }
34
35 void setNextBlock(size_t index, uint64_t address) {
36 assert(index < 2);
37 next_blocks[index] = address;
38 }
39
40 void setStartAddress(uint64_t address) {
41 start_address = address;
42 }
43
44 void setEndAddress(uint64_t address) {
45 end_address = address;
46 }
47
48 std::string getName() {
49 std::stringstream s;
50 s << "BLOCK_" << std::hex << start_address << '_' << end_address;
51 return s.str();
52 }
53
54 Disassembler * getDisassembler() {
55 return disassembler;
56 }
57
58 InformationManager* getManager() const {
59 return manager;
60 }
61 private:
62 uint64_t start_address;
63 uint64_t end_address;
64 Disassembler* disassembler;
65 InformationManager* manager;
66 uint64_t next_blocks[2];
67 };
68
69 #endif