]> git.siccegge.de Git - frida/frida.git/blobdiff - src/core/BasicBlock.hxx
Move Function/BasicBlock to core and clean up includes
[frida/frida.git] / src / core / BasicBlock.hxx
diff --git a/src/core/BasicBlock.hxx b/src/core/BasicBlock.hxx
new file mode 100644 (file)
index 0000000..b3e5a89
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef INCLUDE__BasicBlock_hxx
+#define INCLUDE__BasicBlock_hxx
+
+#include <cassert>
+#include <string>
+#include <sstream>
+
+class BasicBlock {
+public:
+       BasicBlock() {
+               next_blocks[0] = 0;
+               next_blocks[1] = 0;
+       }
+
+       uint64_t getStartAddress() const {
+               return start_address;
+       }
+
+       uint64_t getEndAddress() const {
+               return end_address;
+       }
+
+       uint64_t getNextBlock(size_t index) const {
+               assert(index < 2);
+               return next_blocks[index];
+       }
+
+       void setNextBlock(size_t index, uint64_t address) {
+               assert(index < 2);
+               next_blocks[index] = address;
+       }
+
+       void setStartAddress(uint64_t address) {
+               start_address = address;
+       }
+
+       void setEndAddress(uint64_t address) {
+               end_address = address;
+       }
+
+       std::string getName() {
+               std::stringstream s;
+               s << "BLOCK_" << std::hex << start_address << '_' << end_address;
+               return s.str();
+       }
+
+private:
+       uint64_t start_address;
+       uint64_t end_address;
+
+       uint64_t next_blocks[2];
+};
+
+#endif