SymbolVendor.h revision 0be1edd34ff46e017b1b973c5a57e3de9f613baf
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/Symbol/ClangNamespaceDecl.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 (const lldb::ModuleSP &module_sp); 50 51 //------------------------------------------------------------------ 52 // Constructors and Destructors 53 //------------------------------------------------------------------ 54 SymbolVendor(const lldb::ModuleSP &module_sp); 55 56 virtual 57 ~SymbolVendor(); 58 59 void 60 AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp); 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 const ClangNamespaceDecl *namespace_decl, 102 bool append, 103 uint32_t max_matches, 104 VariableList& variables); 105 106 virtual uint32_t 107 FindGlobalVariables (const RegularExpression& regex, 108 bool append, 109 uint32_t max_matches, 110 VariableList& variables); 111 112 virtual uint32_t 113 FindFunctions (const ConstString &name, 114 const ClangNamespaceDecl *namespace_decl, 115 uint32_t name_type_mask, 116 bool include_inlines, 117 bool append, 118 SymbolContextList& sc_list); 119 120 virtual uint32_t 121 FindFunctions (const RegularExpression& regex, 122 bool include_inlines, 123 bool append, 124 SymbolContextList& sc_list); 125 126 virtual uint32_t 127 FindTypes (const SymbolContext& sc, 128 const ConstString &name, 129 const ClangNamespaceDecl *namespace_decl, 130 bool append, 131 uint32_t max_matches, 132 TypeList& types); 133 134 virtual lldb_private::ClangNamespaceDecl 135 FindNamespace (const SymbolContext& sc, 136 const ConstString &name, 137 const ClangNamespaceDecl *parent_namespace_decl); 138 139 virtual uint32_t 140 GetNumCompileUnits(); 141 142 virtual bool 143 SetCompileUnitAtIndex (uint32_t cu_idx, 144 const lldb::CompUnitSP &cu_sp); 145 146 virtual lldb::CompUnitSP 147 GetCompileUnitAtIndex(uint32_t idx); 148 149 TypeList& 150 GetTypeList() 151 { 152 return m_type_list; 153 } 154 155 const TypeList& 156 GetTypeList() const 157 { 158 return m_type_list; 159 } 160 161 SymbolFile * 162 GetSymbolFile() 163 { 164 return m_sym_file_ap.get(); 165 } 166 167 //------------------------------------------------------------------ 168 // PluginInterface protocol 169 //------------------------------------------------------------------ 170 virtual const char * 171 GetPluginName(); 172 173 virtual const char * 174 GetShortPluginName(); 175 176 virtual uint32_t 177 GetPluginVersion(); 178 179protected: 180 //------------------------------------------------------------------ 181 // Classes that inherit from SymbolVendor can see and modify these 182 //------------------------------------------------------------------ 183 typedef std::vector<lldb::CompUnitSP> CompileUnits; 184 typedef CompileUnits::iterator CompileUnitIter; 185 typedef CompileUnits::const_iterator CompileUnitConstIter; 186 187 TypeList m_type_list; // Uniqued types for all parsers owned by this module 188 CompileUnits m_compile_units; // The current compile units 189 lldb::ObjectFileSP m_objfile_sp; // Keep a reference to the object file in case it isn't the same as the module object file (debug symbols in a separate file) 190 std::auto_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Suclasses can add more of these if needed. 191 192private: 193 //------------------------------------------------------------------ 194 // For SymbolVendor only 195 //------------------------------------------------------------------ 196 DISALLOW_COPY_AND_ASSIGN (SymbolVendor); 197}; 198 199 200} // namespace lldb_private 201 202#endif // liblldb_SymbolVendor_h_ 203