SymbolVendor.h revision 960d6a40711f05effe6fcc5b66f0952450f79ea2
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 22namespace 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//---------------------------------------------------------------------- 34class SymbolVendor : 35 public ModuleChild, 36 public PluginInterface 37{ 38public: 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 uint32_t name_type_mask, 114 bool append, 115 SymbolContextList& sc_list); 116 117 virtual uint32_t 118 FindFunctions (const RegularExpression& regex, 119 bool append, 120 SymbolContextList& sc_list); 121 122 virtual uint32_t 123 FindTypes (const SymbolContext& sc, 124 const ConstString &name, 125 bool append, 126 uint32_t max_matches, 127 TypeList& types); 128 129// virtual uint32_t 130// FindTypes (const SymbolContext& sc, 131// const RegularExpression& regex, 132// bool append, 133// uint32_t max_matches, 134// TypeList& types); 135 136 virtual uint32_t 137 GetNumCompileUnits(); 138 139 virtual bool 140 SetCompileUnitAtIndex (lldb::CompUnitSP& cu, 141 uint32_t index); 142 143 virtual lldb::CompUnitSP 144 GetCompileUnitAtIndex(uint32_t idx); 145 146 TypeList& 147 GetTypeList() 148 { 149 return m_type_list; 150 } 151 152 const TypeList& 153 GetTypeList() const 154 { 155 return m_type_list; 156 } 157 158 SymbolFile * 159 GetSymbolFile() 160 { 161 return m_sym_file_ap.get(); 162 } 163 164 //------------------------------------------------------------------ 165 // PluginInterface protocol 166 //------------------------------------------------------------------ 167 virtual const char * 168 GetPluginName(); 169 170 virtual const char * 171 GetShortPluginName(); 172 173 virtual uint32_t 174 GetPluginVersion(); 175 176 virtual void 177 GetPluginCommandHelp (const char *command, Stream *strm); 178 179 virtual Error 180 ExecutePluginCommand (Args &command, Stream *strm); 181 182 virtual Log * 183 EnablePluginLogging (Stream *strm, Args &command); 184 185protected: 186 //------------------------------------------------------------------ 187 // Classes that inherit from SymbolVendor can see and modify these 188 //------------------------------------------------------------------ 189 typedef std::vector<lldb::CompUnitSP> CompileUnits; 190 typedef CompileUnits::iterator CompileUnitIter; 191 typedef CompileUnits::const_iterator CompileUnitConstIter; 192 193 mutable Mutex m_mutex; 194 TypeList m_type_list; // Uniqued types for all parsers owned by this module 195 CompileUnits m_compile_units; // The current compile units 196 std::auto_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Suclasses can add more of these if needed. 197 198private: 199 //------------------------------------------------------------------ 200 // For SymbolVendor only 201 //------------------------------------------------------------------ 202 DISALLOW_COPY_AND_ASSIGN (SymbolVendor); 203}; 204 205 206} // namespace lldb_private 207 208#endif // liblldb_SymbolVendor_h_ 209