Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- DisassemblerLLVM.h --------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef liblldb_DisassemblerLLVM_h_ |
| 11 | #define liblldb_DisassemblerLLVM_h_ |
| 12 | |
| 13 | #include "lldb/Core/Disassembler.h" |
| 14 | #include "lldb/Host/Mutex.h" |
| 15 | |
| 16 | struct EDDisassembler; |
| 17 | typedef EDDisassembler *EDDisassemblerRef; |
| 18 | |
| 19 | struct EDInst; |
| 20 | typedef EDInst *EDInstRef; |
| 21 | |
| 22 | class DisassemblerLLVM : public lldb_private::Disassembler |
| 23 | { |
| 24 | public: |
| 25 | class Instruction : public lldb_private::Disassembler::Instruction |
| 26 | { |
| 27 | public: |
| 28 | Instruction(EDDisassemblerRef disassembler); |
| 29 | |
| 30 | virtual |
| 31 | ~Instruction(); |
| 32 | |
| 33 | void |
| 34 | Dump (lldb_private::Stream *s, |
| 35 | lldb::addr_t base_address, |
| 36 | lldb_private::DataExtractor *bytes, |
| 37 | uint32_t bytes_offset, |
| 38 | const lldb_private::ExecutionContext exe_ctx, |
| 39 | bool raw); |
| 40 | |
| 41 | bool |
| 42 | DoesBranch () const; |
| 43 | |
| 44 | size_t |
| 45 | GetByteSize() const; |
| 46 | |
| 47 | size_t |
| 48 | Extract (const lldb_private::DataExtractor &data, |
| 49 | uint32_t data_offset); |
| 50 | |
| 51 | protected: |
| 52 | EDDisassemblerRef m_disassembler; |
| 53 | EDInstRef m_inst; |
| 54 | }; |
| 55 | |
| 56 | //------------------------------------------------------------------ |
| 57 | // Static Functions |
| 58 | //------------------------------------------------------------------ |
| 59 | static void |
| 60 | Initialize(); |
| 61 | |
| 62 | static void |
| 63 | Terminate(); |
| 64 | |
| 65 | static const char * |
| 66 | GetPluginNameStatic(); |
| 67 | |
| 68 | static const char * |
| 69 | GetPluginDescriptionStatic(); |
| 70 | |
| 71 | static lldb_private::Disassembler * |
| 72 | CreateInstance(const lldb_private::ArchSpec &arch); |
| 73 | |
| 74 | |
| 75 | DisassemblerLLVM(const lldb_private::ArchSpec &arch); |
| 76 | |
| 77 | virtual |
| 78 | ~DisassemblerLLVM(); |
| 79 | |
| 80 | size_t |
| 81 | ParseInstructions (const lldb_private::DataExtractor& data, |
| 82 | uint32_t data_offset, |
| 83 | uint32_t num_instructions, |
| 84 | lldb::addr_t base_addr); |
| 85 | |
| 86 | //------------------------------------------------------------------ |
| 87 | // PluginInterface protocol |
| 88 | //------------------------------------------------------------------ |
| 89 | virtual const char * |
| 90 | GetPluginName(); |
| 91 | |
| 92 | virtual const char * |
| 93 | GetShortPluginName(); |
| 94 | |
| 95 | virtual uint32_t |
| 96 | GetPluginVersion(); |
| 97 | |
| 98 | virtual void |
| 99 | GetPluginCommandHelp (const char *command, lldb_private::Stream *strm); |
| 100 | |
| 101 | virtual lldb_private::Error |
| 102 | ExecutePluginCommand (lldb_private::Args &command, lldb_private::Stream *strm); |
| 103 | |
| 104 | virtual lldb_private::Log * |
| 105 | EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command); |
| 106 | |
| 107 | protected: |
| 108 | EDDisassemblerRef m_disassembler; |
| 109 | }; |
| 110 | |
| 111 | #endif // liblldb_DisassemblerLLVM_h_ |