]> git.siccegge.de Git - frida/frida.git/blob - src/disassembler/llvm/LLVMDisassembler.hxx
Remove unused LLVMBasicBlock class
[frida/frida.git] / src / disassembler / llvm / LLVMDisassembler.hxx
1 #ifndef INCLUDE__LLVMDisassembler_hxx
2 #define INCLUDE__LLVMDisassembler_hxx
3
4 #include <memory>
5 #include <map>
6 #include <log4cxx/logger.h>
7
8 #include "include_llvm.hxx"
9
10 #include "disassembler/Disassembler.hxx"
11
12 class Function;
13 class BasicBlock;
14
15 Disassembler * createLLVMDisassembler(const std::string& filename, InformationManager* manager);
16
17 template <typename ELFT>
18 class LLVMDisassembler
19 : public Disassembler {
20 public:
21 LLVMDisassembler(const std::string& filename, InformationManager* manager,
22 llvm::object::ELFObjectFile<ELFT>* file = NULL);
23 virtual ~LLVMDisassembler();
24
25 void start();
26 void getSymbols() {}
27 uint64_t entryAddress() {return _entryAddress;}
28
29 void forEachFunction(std::function<void (uint64_t, Function*)> callback);
30 void printEachInstruction(uint64_t start, uint64_t end,
31 std::function<void (uint8_t*, size_t, const std::string&,
32 const std::string&)> fun);
33
34 BasicBlock * getBasicBlock(uint64_t address) {
35 return blocks[address];
36 }
37
38 Function * disassembleFunctionAt(uint64_t address, const std::string& name = "");
39
40 protected:
41 bool isFunctionCall(uint64_t address) {return false;}
42 bool isJump(uint64_t address) {return false;}
43
44 private:
45 typedef llvm::object::ELFFile<ELFT> ELFO;
46
47 // http://llvm.org/docs/doxygen/html/MCObjectDisassembler_8cpp_source.html +197
48 void disassembleFunction(Function* function);
49 void splitBlocks(Function* fun);
50 void disassemble();
51
52 void readSymbols();
53 void readSections();
54 void readDynamicSymbols();
55
56 log4cxx::LoggerPtr logger;
57 std::map<uint64_t, BasicBlock*> blocks;
58 std::map<uint64_t, Function*> functions;
59
60 llvm::Triple triple;
61 std::shared_ptr<llvm::object::Binary> binary;
62
63 const llvm::Target * target;
64 llvm::object::ELFObjectFile<ELFT> * o;
65
66 std::unique_ptr<const llvm::MCRegisterInfo> MRI;
67 std::unique_ptr<const llvm::MCAsmInfo> AsmInfo;
68 std::unique_ptr<llvm::MCModule> Mod;
69 std::unique_ptr<llvm::MCInstPrinter> IP;
70 std::unique_ptr<llvm::MCDisassembler> DisAsm;
71 std::unique_ptr<const llvm::MCObjectFileInfo> MOFI;
72 std::unique_ptr<llvm::MCContext> Ctx;
73 std::unique_ptr<const llvm::MCInstrAnalysis> MIA;
74 std::unique_ptr<const llvm::MCSubtargetInfo> STI;
75 std::unique_ptr<const llvm::MCInstrInfo> MII;
76 std::unique_ptr<llvm::MCRelocationInfo> RelInfo;
77 std::unique_ptr<llvm::MCSymbolizer> Symzer;
78
79 std::map<std::string, llvm::object::SectionRef> sections;
80 std::map<std::string, llvm::object::SymbolRef> symbols;
81 InformationManager * manager;
82 uint64_t _entryAddress;
83 };
84
85 #endif