Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame^] | 1 | //===-- SymbolVendor.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_SymbolVendor_h_ |
| 11 | #define liblldb_SymbolVendor_h_ |
| 12 | |
| 13 | #include <vector> |
| 14 | |
| 15 | #include "lldb/lldb-private.h" |
| 16 | #include "lldb/Core/ModuleChild.h" |
| 17 | #include "lldb/Core/PluginInterface.h" |
| 18 | #include "lldb/Host/Mutex.h" |
| 19 | #include "lldb/Symbol/TypeList.h" |
| 20 | |
| 21 | |
| 22 | namespace lldb_private { |
| 23 | |
| 24 | //---------------------------------------------------------------------- |
| 25 | // The symbol vendor class is designed to abstract the process of |
| 26 | // searching for debug information for a given module. Platforms can |
| 27 | // subclass this class and provide extra ways to find debug information. |
| 28 | // Examples would be a subclass that would allow for locating a stand |
| 29 | // alone debug file, parsing debug maps, or runtime data in the object |
| 30 | // files. A symbol vendor can use multiple sources (SymbolFile |
| 31 | // objects) to provide the information and only parse as deep as needed |
| 32 | // in order to provide the information that is requested. |
| 33 | //---------------------------------------------------------------------- |
| 34 | class SymbolVendor : |
| 35 | public ModuleChild, |
| 36 | public PluginInterface |
| 37 | { |
| 38 | public: |
| 39 | static bool |
| 40 | RegisterPlugin (const char *name, |
| 41 | const char *description, |
| 42 | SymbolVendorCreateInstance create_callback); |
| 43 | |
| 44 | static bool |
| 45 | UnregisterPlugin (SymbolVendorCreateInstance create_callback); |
| 46 | |
| 47 | |
| 48 | static SymbolVendor* |
| 49 | FindPlugin (Module* module); |
| 50 | |
| 51 | //------------------------------------------------------------------ |
| 52 | // Constructors and Destructors |
| 53 | //------------------------------------------------------------------ |
| 54 | SymbolVendor(Module *module); |
| 55 | |
| 56 | virtual |
| 57 | ~SymbolVendor(); |
| 58 | |
| 59 | void |
| 60 | AddSymbolFileRepresendation(ObjectFile *obj_file); |
| 61 | |
| 62 | virtual void |
| 63 | Dump(Stream *s); |
| 64 | |
| 65 | virtual size_t |
| 66 | ParseCompileUnitFunctions (const SymbolContext& sc); |
| 67 | |
| 68 | virtual bool |
| 69 | ParseCompileUnitLineTable (const SymbolContext& sc); |
| 70 | |
| 71 | virtual bool |
| 72 | ParseCompileUnitSupportFiles (const SymbolContext& sc, |
| 73 | FileSpecList& support_files); |
| 74 | |
| 75 | virtual size_t |
| 76 | ParseFunctionBlocks (const SymbolContext& sc); |
| 77 | |
| 78 | virtual size_t |
| 79 | ParseTypes (const SymbolContext& sc); |
| 80 | |
| 81 | virtual size_t |
| 82 | ParseVariablesForContext (const SymbolContext& sc); |
| 83 | |
| 84 | virtual Type* |
| 85 | ResolveTypeUID(lldb::user_id_t type_uid); |
| 86 | |
| 87 | virtual uint32_t |
| 88 | ResolveSymbolContext (const Address& so_addr, |
| 89 | uint32_t resolve_scope, |
| 90 | SymbolContext& sc); |
| 91 | |
| 92 | virtual uint32_t |
| 93 | ResolveSymbolContext (const FileSpec& file_spec, |
| 94 | uint32_t line, |
| 95 | bool check_inlines, |
| 96 | uint32_t resolve_scope, |
| 97 | SymbolContextList& sc_list); |
| 98 | |
| 99 | virtual uint32_t |
| 100 | FindGlobalVariables(const ConstString &name, |
| 101 | bool append, |
| 102 | uint32_t max_matches, |
| 103 | VariableList& variables); |
| 104 | |
| 105 | virtual uint32_t |
| 106 | FindGlobalVariables(const RegularExpression& regex, |
| 107 | bool append, |
| 108 | uint32_t max_matches, |
| 109 | VariableList& variables); |
| 110 | |
| 111 | virtual uint32_t |
| 112 | FindFunctions(const ConstString &name, |
| 113 | bool append, |
| 114 | SymbolContextList& sc_list); |
| 115 | |
| 116 | virtual uint32_t |
| 117 | FindFunctions(const RegularExpression& regex, |
| 118 | bool append, |
| 119 | SymbolContextList& sc_list); |
| 120 | |
| 121 | virtual uint32_t |
| 122 | GetNumCompileUnits(); |
| 123 | |
| 124 | virtual bool |
| 125 | SetCompileUnitAtIndex (lldb::CompUnitSP& cu, |
| 126 | uint32_t index); |
| 127 | |
| 128 | virtual lldb::CompUnitSP |
| 129 | GetCompileUnitAtIndex(uint32_t idx); |
| 130 | |
| 131 | TypeList& |
| 132 | GetTypeList() |
| 133 | { |
| 134 | return m_type_list; |
| 135 | } |
| 136 | |
| 137 | const TypeList& |
| 138 | GetTypeList() const |
| 139 | { |
| 140 | return m_type_list; |
| 141 | } |
| 142 | |
| 143 | SymbolFile * |
| 144 | GetSymbolFile() |
| 145 | { |
| 146 | return m_sym_file_ap.get(); |
| 147 | } |
| 148 | |
| 149 | //------------------------------------------------------------------ |
| 150 | // PluginInterface protocol |
| 151 | //------------------------------------------------------------------ |
| 152 | virtual const char * |
| 153 | GetPluginName(); |
| 154 | |
| 155 | virtual const char * |
| 156 | GetShortPluginName(); |
| 157 | |
| 158 | virtual uint32_t |
| 159 | GetPluginVersion(); |
| 160 | |
| 161 | virtual void |
| 162 | GetPluginCommandHelp (const char *command, Stream *strm); |
| 163 | |
| 164 | virtual Error |
| 165 | ExecutePluginCommand (Args &command, Stream *strm); |
| 166 | |
| 167 | virtual Log * |
| 168 | EnablePluginLogging (Stream *strm, Args &command); |
| 169 | |
| 170 | protected: |
| 171 | //------------------------------------------------------------------ |
| 172 | // Classes that inherit from SymbolVendor can see and modify these |
| 173 | //------------------------------------------------------------------ |
| 174 | typedef std::vector<lldb::CompUnitSP> CompileUnits; |
| 175 | typedef CompileUnits::iterator CompileUnitIter; |
| 176 | typedef CompileUnits::const_iterator CompileUnitConstIter; |
| 177 | |
| 178 | mutable Mutex m_mutex; |
| 179 | TypeList m_type_list; // Uniqued types for all parsers owned by this module |
| 180 | CompileUnits m_compile_units; // The current compile units |
| 181 | std::auto_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Suclasses can add more of these if needed. |
| 182 | |
| 183 | private: |
| 184 | //------------------------------------------------------------------ |
| 185 | // For SymbolVendor only |
| 186 | //------------------------------------------------------------------ |
| 187 | DISALLOW_COPY_AND_ASSIGN (SymbolVendor); |
| 188 | }; |
| 189 | |
| 190 | |
| 191 | } // namespace lldb_private |
| 192 | |
| 193 | #endif // liblldb_SymbolVendor_h_ |