]> git.siccegge.de Git - frida/frida.git/blob - src/disassembler/llvm/LLVMDisassembler.hxx
Remove deprecated printEachInstruction function
[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 ObjectType>
18 class LLVMDisassembler
19 : public Disassembler {
20 public:
21 LLVMDisassembler(const std::string& filename, InformationManager* manager,
22 llvm::object::ObjectFile* file = NULL);
23 virtual ~LLVMDisassembler();
24
25 void start();
26 void getSymbols() {}
27 uint64_t entryAddress();
28
29 Function * disassembleFunctionAt(uint64_t address, const std::string& name = "");
30 std::vector<Instruction> getInstructions(const BasicBlock* block);
31
32 private:
33 // http://llvm.org/docs/doxygen/html/MCObjectDisassembler_8cpp_source.html +197
34 void disassembleFunction(Function* function);
35 void splitBlocks(Function* fun);
36 void disassemble();
37 llvm::object::SectionRef getTextSection();
38
39 void readSymbols();
40 void readSections();
41 void readDynamicSymbols();
42
43 log4cxx::LoggerPtr logger;
44
45 llvm::Triple triple;
46 std::shared_ptr<llvm::object::Binary> binary;
47
48 const llvm::Target * target;
49 llvm::object::ObjectFile * o;
50
51 std::unique_ptr<const llvm::MCRegisterInfo> MRI;
52 std::unique_ptr<const llvm::MCAsmInfo> AsmInfo;
53 // std::unique_ptr<llvm::MCModule> Mod;
54 std::unique_ptr<llvm::MCInstPrinter> IP;
55 std::unique_ptr<llvm::MCDisassembler> DisAsm;
56 std::unique_ptr<const llvm::MCObjectFileInfo> MOFI;
57 std::unique_ptr<llvm::MCContext> Ctx;
58 std::unique_ptr<const llvm::MCInstrAnalysis> MIA;
59 std::unique_ptr<const llvm::MCSubtargetInfo> STI;
60 std::unique_ptr<const llvm::MCInstrInfo> MII;
61 std::unique_ptr<llvm::MCRelocationInfo> RelInfo;
62 std::unique_ptr<llvm::MCSymbolizer> Symzer;
63
64 std::map<std::string, llvm::object::SectionRef> sections;
65 std::map<std::string, llvm::object::SymbolRef> symbols;
66 InformationManager * manager;
67 uint64_t _entryAddress;
68 };
69
70 #endif