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