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