]> git.siccegge.de Git - frida/frida.git/blobdiff - src/disassembler/llvm/LLVMDisassembler.hxx
Avoid memory leak
[frida/frida.git] / src / disassembler / llvm / LLVMDisassembler.hxx
index ff81be55385890a7ca642d9fa7d50a469ea001ac..42024ee7c4998839f796c7d55ea43ea45ccd8a2b 100644 (file)
@@ -2,23 +2,28 @@
 #define INCLUDE__LLVMDisassembler_hxx
 
 #include <memory>
 #define INCLUDE__LLVMDisassembler_hxx
 
 #include <memory>
+#include <map>
 #include <log4cxx/logger.h>
 
 #include "include_llvm.hxx"
 
 #include "disassembler/Disassembler.hxx"
 #include <log4cxx/logger.h>
 
 #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 LLVMDisassembler
     : public Disassembler {
 public:
     LLVMDisassembler(const std::string& filename);
 
 
 class LLVMDisassembler
     : public Disassembler {
 public:
     LLVMDisassembler(const std::string& filename);
-    virtual ~LLVMDisassembler() {};
+    virtual ~LLVMDisassembler();
 
        void getSymbols();
        uint64_t entryAddress();
 
 
        void getSymbols();
        uint64_t entryAddress();
 
-    void forEachInstruction(const std::string& name, std::function<void (long, std::string, std::string)> callback) {}
+       void forEachFunction(std::function<void (uint64_t, Function*)> callback);
 
        BasicBlock * generateControlFlowGraph(const std::string& name);
        BasicBlock * generateControlFlowGraph(uint64_t address);
 
        BasicBlock * generateControlFlowGraph(const std::string& name);
        BasicBlock * generateControlFlowGraph(uint64_t address);
@@ -28,7 +33,14 @@ protected:
     bool isJump(uint64_t address) {return false;}
 
 private:
     bool isJump(uint64_t address) {return false;}
 
 private:
+       void disassemble();
+
+       void readSymbols();
+       void readSections();
+
     log4cxx::LoggerPtr logger;
     log4cxx::LoggerPtr logger;
+       std::map<uint64_t, LLVMBasicBlock*> blocks;
+       std::map<uint64_t, LLVMFunction*> functions;
 
     llvm::Triple triple;
     std::shared_ptr<llvm::object::Binary> binary;
 
     llvm::Triple triple;
     std::shared_ptr<llvm::object::Binary> binary;