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/TypeList.h" 19#include "lldb/Symbol/TypeMap.h" 20 21namespace lldb_private { 22 23//---------------------------------------------------------------------- 24// The symbol vendor class is designed to abstract the process of 25// searching for debug information for a given module. Platforms can 26// subclass this class and provide extra ways to find debug information. 27// Examples would be a subclass that would allow for locating a stand 28// alone debug file, parsing debug maps, or runtime data in the object 29// files. A symbol vendor can use multiple sources (SymbolFile 30// objects) to provide the information and only parse as deep as needed 31// in order to provide the information that is requested. 32//---------------------------------------------------------------------- 33class SymbolVendor : 34 public ModuleChild, 35 public PluginInterface 36{ 37public: 38 static SymbolVendor* 39 FindPlugin (const lldb::ModuleSP &module_sp, 40 Stream *feedback_strm); 41 42 //------------------------------------------------------------------ 43 // Constructors and Destructors 44 //------------------------------------------------------------------ 45 SymbolVendor(const lldb::ModuleSP &module_sp); 46 47 ~SymbolVendor() override; 48 49 void 50 AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp); 51 52 virtual void 53 Dump(Stream *s); 54 55 virtual lldb::LanguageType 56 ParseCompileUnitLanguage (const SymbolContext& sc); 57 58 virtual size_t 59 ParseCompileUnitFunctions (const SymbolContext& sc); 60 61 virtual bool 62 ParseCompileUnitLineTable (const SymbolContext& sc); 63 64 virtual bool 65 ParseCompileUnitDebugMacros (const SymbolContext& sc); 66 67 virtual bool 68 ParseCompileUnitSupportFiles (const SymbolContext& sc, 69 FileSpecList& support_files); 70 71 virtual bool 72 ParseImportedModules (const SymbolContext &sc, 73 std::vector<ConstString> &imported_modules); 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 size_t 100 FindGlobalVariables (const ConstString &name, 101 const CompilerDeclContext *parent_decl_ctx, 102 bool append, 103 size_t max_matches, 104 VariableList& variables); 105 106 virtual size_t 107 FindGlobalVariables (const RegularExpression& regex, 108 bool append, 109 size_t max_matches, 110 VariableList& variables); 111 112 virtual size_t 113 FindFunctions (const ConstString &name, 114 const CompilerDeclContext *parent_decl_ctx, 115 uint32_t name_type_mask, 116 bool include_inlines, 117 bool append, 118 SymbolContextList& sc_list); 119 120 virtual size_t 121 FindFunctions (const RegularExpression& regex, 122 bool include_inlines, 123 bool append, 124 SymbolContextList& sc_list); 125 126 virtual size_t 127 FindTypes (const SymbolContext& sc, 128 const ConstString &name, 129 const CompilerDeclContext *parent_decl_ctx, 130 bool append, 131 size_t max_matches, 132 TypeMap& types); 133 134 virtual size_t 135 FindTypes (const std::vector<CompilerContext> &context, bool append, TypeMap& types); 136 137 virtual CompilerDeclContext 138 FindNamespace (const SymbolContext& sc, 139 const ConstString &name, 140 const CompilerDeclContext *parent_decl_ctx); 141 142 virtual size_t 143 GetNumCompileUnits(); 144 145 virtual bool 146 SetCompileUnitAtIndex (size_t cu_idx, 147 const lldb::CompUnitSP &cu_sp); 148 149 virtual lldb::CompUnitSP 150 GetCompileUnitAtIndex(size_t idx); 151 152 TypeList& 153 GetTypeList() 154 { 155 return m_type_list; 156 } 157 158 const TypeList& 159 GetTypeList() const 160 { 161 return m_type_list; 162 } 163 164 virtual size_t 165 GetTypes (SymbolContextScope *sc_scope, 166 uint32_t type_mask, 167 TypeList &type_list); 168 169 SymbolFile * 170 GetSymbolFile() 171 { 172 return m_sym_file_ap.get(); 173 } 174 175 FileSpec 176 GetMainFileSpec() const; 177 178 // Get module unified section list symbol table. 179 virtual Symtab * 180 GetSymtab (); 181 182 // Clear module unified section list symbol table. 183 virtual void 184 ClearSymtab (); 185 186 //------------------------------------------------------------------ 187 /// Notify the SymbolVendor that the file addresses in the Sections 188 /// for this module have been changed. 189 //------------------------------------------------------------------ 190 virtual void 191 SectionFileAddressesChanged (); 192 193 //------------------------------------------------------------------ 194 // PluginInterface protocol 195 //------------------------------------------------------------------ 196 ConstString 197 GetPluginName() override; 198 199 uint32_t 200 GetPluginVersion() override; 201 202protected: 203 //------------------------------------------------------------------ 204 // Classes that inherit from SymbolVendor can see and modify these 205 //------------------------------------------------------------------ 206 typedef std::vector<lldb::CompUnitSP> CompileUnits; 207 typedef CompileUnits::iterator CompileUnitIter; 208 typedef CompileUnits::const_iterator CompileUnitConstIter; 209 210 TypeList m_type_list; // Uniqued types for all parsers owned by this module 211 CompileUnits m_compile_units; // The current compile units 212 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) 213 std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Subclasses can add more of these if needed. 214 215private: 216 //------------------------------------------------------------------ 217 // For SymbolVendor only 218 //------------------------------------------------------------------ 219 DISALLOW_COPY_AND_ASSIGN (SymbolVendor); 220}; 221 222} // namespace lldb_private 223 224#endif // liblldb_SymbolVendor_h_ 225