]> git.siccegge.de Git - frida/frida.git/commitdiff
Move Function/BasicBlock to core and clean up includes
authorChristoph Egger <Christoph.Egger@fau.de>
Fri, 20 Feb 2015 16:03:45 +0000 (17:03 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Fri, 20 Feb 2015 16:03:45 +0000 (17:03 +0100)
Function and BasicBlock are considered part od the Data Model and part
of the core. Move them there.

Also remove lots of #include from the headers and replace them by
forward declarations. This should make compilation units smaller and
remove the huge number of users for each header -- speeding up
compilation and making users explicitely include stuff they use.

15 files changed:
src/core/BasicBlock.hxx [new file with mode: 0644]
src/core/Function.hxx [new file with mode: 0644]
src/core/InformationManager.cxx
src/core/InformationManager.hxx
src/disassembler/BasicBlock.hxx [deleted file]
src/disassembler/Disassembler.hxx
src/disassembler/Function.hxx [deleted file]
src/disassembler/llvm/LLVMBasicBlock.hxx
src/disassembler/llvm/LLVMDisassembler.cxx
src/disassembler/llvm/LLVMDisassembler.hxx
src/disassembler/llvm/LLVMFunction.hxx
src/gui/Mainwindow.cxx
src/gui/Mainwindow.hxx
src/gui/widgets/BasicBlockWidget.cxx
src/gui/widgets/BasicBlockWidget.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
diff --git a/src/core/Function.hxx b/src/core/Function.hxx
new file mode 100644 (file)
index 0000000..3c8f799
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef INCLUDE__Function_hxx
+#define INCLUDE__Function_hxx
+
+#include <map>
+#include "BasicBlock.hxx"
+
+class Function {
+public:
+       Function(const std::string& name, uint64_t start_address)
+               : name(name)
+               , start_address(start_address) {
+       }
+
+       uint64_t getStartAddress() const {
+               return start_address;
+       }
+
+       std::string getName() const {
+               return name;
+       }
+
+       void addBasicBlock(BasicBlock* block) {
+               _blocks.insert(std::make_pair(block->getStartAddress(), block));
+       }
+
+       std::map<uint64_t, BasicBlock*>& blocks() {
+               return _blocks;
+       }
+private:
+       std::string name;
+       uint64_t start_address;
+       std::map<uint64_t, BasicBlock*> _blocks;
+};
+
+#endif
index 0907cf9d2d7f7eeb5a191781c4345e1fc3e5a72c..7c1c5dee207a4e9e1023a812858fec5e8ea67a9b 100644 (file)
@@ -1,8 +1,11 @@
 #include "InformationManager.hxx"
 #include "disassembler/llvm/LLVMDisassembler.hxx"
+#include "core/Function.hxx"
+#include "core/BasicBlock.hxx"
+
 #include "gui/qt.hxx"
-#include "quazip/quazip.h"
-#include "quazip/quazipfile.h"
+#include <quazip/quazip.h>
+#include <quazip/quazipfile.h>
 
 void InformationManager::reset(const std::string& filename) {
        disassembler.reset(createLLVMDisassembler(filename, this));
index 4e1b3187a52a081e5453aa9beb661af872170d55..f8e4f04011bc666c5aff24e14f4d157b2ff66130 100644 (file)
@@ -8,6 +8,7 @@
 
 class Disassembler;
 class Function;
+class BasicBlock;
 
 class QString;
 
diff --git a/src/disassembler/BasicBlock.hxx b/src/disassembler/BasicBlock.hxx
deleted file mode 100644 (file)
index b3e5a89..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#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
index dbc140ef021451daa37659697dda64bc73d2fe3b..4feeddf0e11e03ab97d5b84984daebcfde5af356 100644 (file)
@@ -4,9 +4,9 @@
 #include <string>
 #include <functional>
 
-#include "disassembler/BasicBlock.hxx"
-#include "disassembler/Function.hxx"
-#include "core/InformationManager.hxx"
+class Function;
+class BasicBlock;
+class InformationManager;
 
 class Disassembler {
 public:
diff --git a/src/disassembler/Function.hxx b/src/disassembler/Function.hxx
deleted file mode 100644 (file)
index 57833ba..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef INCLUDE__Function_hxx
-#define INCLUDE__Function_hxx
-
-#include "disassembler/BasicBlock.hxx"
-#include <map>
-
-class Function {
-public:
-       Function(const std::string& name, uint64_t start_address)
-               : name(name)
-               , start_address(start_address) {
-       }
-
-       uint64_t getStartAddress() const {
-               return start_address;
-       }
-
-       std::string getName() const {
-               return name;
-       }
-
-       void addBasicBlock(BasicBlock* block) {
-               _blocks.insert(std::make_pair(block->getStartAddress(), block));
-       }
-
-       std::map<uint64_t, BasicBlock*>& blocks() {
-               return _blocks;
-       }
-private:
-       std::string name;
-       uint64_t start_address;
-       std::map<uint64_t, BasicBlock*> _blocks;
-};
-
-#endif
index 0949f70a4d87c50fac5fb611d249fd4ec0a7f569..15826aa00e0f07180a09e384a598d747ded459e1 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef INCLUDE__LLVMBasicBlock_hxx
 #define INCLUDE__LLVMBasicBlock_hxx
 
-#include "disassembler/BasicBlock.hxx"
+#include "core/BasicBlock.hxx"
 
 class Disassembler;
 
index 5652cfb8bb2e62f6bb04813606aa82397861f65d..314779600481cb531e53f10096dd1b49d33b5df9 100644 (file)
@@ -1,6 +1,7 @@
 #include "disassembler/llvm/LLVMDisassembler.hxx"
 #include "disassembler/llvm/LLVMBasicBlock.hxx"
 #include "disassembler/llvm/LLVMFunction.hxx"
+#include "core/InformationManager.hxx"
 
 #include <stack>
 #include <algorithm>
index 95e961fb5656804ef745e4dc073ed496a41fe7ff..2291e205d4ccadede3acff7bb173579df9de9b91 100644 (file)
@@ -8,11 +8,11 @@
 #include "include_llvm.hxx"
 
 #include "disassembler/Disassembler.hxx"
-#include "disassembler/BasicBlock.hxx"
-#include "disassembler/Function.hxx"
-#include "disassembler/llvm/LLVMBasicBlock.hxx"
-#include "disassembler/llvm/LLVMFunction.hxx"
 
+class Function;
+class BasicBlock;
+class LLVMFunction;
+class LLVMBasicBlock;
 
 Disassembler * createLLVMDisassembler(const std::string& filename, InformationManager* manager);
 
index 0bdb1dc12aef4dcfce0ed0ff02ebb62e0e090918..e28b9588c44d3bb6ddeaf0ada93f30a904bccf5a 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef INCLUDE__LLVMFunction_hxx
 #define INCLUDE__LLVMFunction_hxx
 
-#include "disassembler/Function.hxx"
+#include "core/Function.hxx"
 
 class LLVMFunction : public Function {
 public:
index 03910a1be4801334ade968cbb237f6cd8cfe4d46..4d6e2c05c1b3b2dd5805131229cd6dd00b3847e1 100644 (file)
@@ -1,7 +1,10 @@
 #include "Mainwindow.hxx"
 #include "qt.hxx"
 #include "disassembler/llvm/LLVMDisassembler.hxx"
-
+#include "core/Function.hxx"
+#include "core/BasicBlock.hxx"
+#include "core/InformationManager.hxx"
+#include "widgets/ScriptingDock.hxx"
 #include "widgets/CFGScene.hxx"
 #include "dialogs/NewFunctionDialog.hxx"
 #include "dialogs/SimpleStringDialog.hxx"
index 0962efd7e1a554798efa6d2e30346a527113d50e..8cf1fadb25cfb0f707c4d207dd217269e56050a3 100644 (file)
 
 #include <log4cxx/logger.h>
 
-#include "disassembler/Disassembler.hxx"
-#include "widgets/BasicBlockWidget.hxx"
-#include "widgets/ScriptingDock.hxx"
-#include "core/InformationManager.hxx"
+class Disassembler;
+class Function;
+class InformationManager;
+class BasicBlockWidget;
+class ScriptingDock;
 
 class Mainwindow : public QMainWindow {
        Q_OBJECT
index fbf4370c9a212420ed7cf53e662cf5683d5461a6..b9a1b1411bfb97265d6993e9fa84196fb8d2f253 100644 (file)
@@ -1,6 +1,7 @@
 #include "BasicBlockWidget.hxx"
 #include "gui/Mainwindow.hxx"
 #include "gui/dialogs/SimpleStringDialog.hxx"
+#include "core/BasicBlock.hxx"
 
 class CustomQGraphicsTextItem : public QObject, public QGraphicsTextItem {
 public:
index 5d23d9b65f69995e7009398f769ad758be2044d2..2c9cec3331d142f01f338bbe4d1c34b270efb177 100644 (file)
@@ -2,7 +2,6 @@
 #define INCLUDE__BasicBlockWidget_hxx
 
 #include "gui/qt.hxx"
-#include "disassembler/BasicBlock.hxx"
 #include <vector>
 #include <cassert>
 #include <tuple>
@@ -10,6 +9,7 @@
 #include <memory>
 
 class Mainwindow;
+class BasicBlock;
 
 class BasicBlockWidget : public QObject, public QGraphicsItem
 {