69d4f37d9c85cb8643bccdd713bb40f9c9adf102
[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 uint64_t getStartAddress() const {
14 return start_address;
15 }
16
17 uint64_t getEndAddress() const {
18 return end_address;
19 }
20
21 uint64_t getNextBlock(size_t index) const {
22 assert(index < 2);
23 return next_blocks[index];
24 }
25
26 void setNextBlock(size_t index, uint64_t address) {
27 assert(index < 2);
28 next_blocks[index] = address;
29 }
30
31 void setStartAddress(uint64_t address) {
32 start_address = address;
33 }
34
35 void setEndAddress(uint64_t address) {
36 end_address = address;
37 }
38
39 std::string getName() const {
40 std::stringstream s;
41 s << "BLOCK_" << std::hex << start_address << '_' << end_address;
42 return s.str();
43 }
44
45 InformationManager* getManager() const {
46 return manager;
47 }
48 private:
49 BasicBlock(uint64_t start_address, InformationManager* manager)
50 : start_address(start_address)
51 , manager(manager) {
52 next_blocks[0] = 0;
53 next_blocks[1] = 0;
54 }
55
56 uint64_t start_address;
57 uint64_t end_address;
58 Disassembler* disassembler;
59 InformationManager* manager;
60 uint64_t next_blocks[2];
61
62 friend class InformationManager;
63 };
64
65 #endif