SymbolVendor.h revision 0e191607adcb0ea8ebd06c278be648a7f5c0097f
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 SymbolVendor* 40 FindPlugin (const lldb::ModuleSP &module_sp, 41 lldb_private::Stream *feedback_strm); 42 43 //------------------------------------------------------------------ 44 // Constructors and Destructors 45 //------------------------------------------------------------------ 46 SymbolVendor(const lldb::ModuleSP &module_sp); 47 48 virtual 49 ~SymbolVendor(); 50 51 void 52 AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp); 53 54 virtual void 55 Dump(Stream *s); 56 57 virtual lldb::LanguageType 58 ParseCompileUnitLanguage (const SymbolContext& sc); 59 60 virtual size_t 61 ParseCompileUnitFunctions (const SymbolContext& sc); 62 63 virtual bool 64 ParseCompileUnitLineTable (const SymbolContext& sc); 65 66 virtual bool 67 ParseCompileUnitSupportFiles (const SymbolContext& sc, 68 FileSpecList& support_files); 69 70 virtual size_t 71 ParseFunctionBlocks (const SymbolContext& sc); 72 73 virtual size_t 74 ParseTypes (const SymbolContext& sc); 75 76 virtual size_t 77 ParseVariablesForContext (const SymbolContext& sc); 78 79 virtual Type* 80 ResolveTypeUID(lldb::user_id_t type_uid); 81 82 virtual uint32_t 83 ResolveSymbolContext (const Address& so_addr, 84 uint32_t resolve_scope, 85 SymbolContext& sc); 86 87 virtual uint32_t 88 ResolveSymbolContext (const FileSpec& file_spec, 89 uint32_t line, 90 bool check_inlines, 91 uint32_t resolve_scope, 92 SymbolContextList& sc_list); 93 94 virtual size_t 95 FindGlobalVariables (const ConstString &name, 96 const ClangNamespaceDecl *namespace_decl, 97 bool append, 98 size_t max_matches, 99 VariableList& variables); 100 101 virtual size_t 102 FindGlobalVariables (const RegularExpression& regex, 103 bool append, 104 size_t max_matches, 105 VariableList& variables); 106 107 virtual size_t 108 FindFunctions (const ConstString &name, 109 const ClangNamespaceDecl *namespace_decl, 110 uint32_t name_type_mask, 111 bool include_inlines, 112 bool append, 113 SymbolContextList& sc_list); 114 115 virtual size_t 116 FindFunctions (const RegularExpression& regex, 117 bool include_inlines, 118 bool append, 119 SymbolContextList& sc_list); 120 121 virtual size_t 122 FindTypes (const SymbolContext& sc, 123 const ConstString &name, 124 const ClangNamespaceDecl *namespace_decl, 125 bool append, 126 size_t max_matches, 127 TypeList& types); 128 129 virtual lldb_private::ClangNamespaceDecl 130 FindNamespace (const SymbolContext& sc, 131 const ConstString &name, 132 const ClangNamespaceDecl *parent_namespace_decl); 133 134 virtual size_t 135 GetNumCompileUnits(); 136 137 virtual bool 138 SetCompileUnitAtIndex (size_t cu_idx, 139 const lldb::CompUnitSP &cu_sp); 140 141 virtual lldb::CompUnitSP 142 GetCompileUnitAtIndex(size_t idx); 143 144 TypeList& 145 GetTypeList() 146 { 147 return m_type_list; 148 } 149 150 const TypeList& 151 GetTypeList() const 152 { 153 return m_type_list; 154 } 155 156 SymbolFile * 157 GetSymbolFile() 158 { 159 return m_sym_file_ap.get(); 160 } 161 162 //------------------------------------------------------------------ 163 // PluginInterface protocol 164 //------------------------------------------------------------------ 165 virtual lldb_private::ConstString 166 GetPluginName(); 167 168 virtual uint32_t 169 GetPluginVersion(); 170 171protected: 172 //------------------------------------------------------------------ 173 // Classes that inherit from SymbolVendor can see and modify these 174 //------------------------------------------------------------------ 175 typedef std::vector<lldb::CompUnitSP> CompileUnits; 176 typedef CompileUnits::iterator CompileUnitIter; 177 typedef CompileUnits::const_iterator CompileUnitConstIter; 178 179 TypeList m_type_list; // Uniqued types for all parsers owned by this module 180 CompileUnits m_compile_units; // The current compile units 181 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) 182 std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Suclasses can add more of these if needed. 183 184private: 185 //------------------------------------------------------------------ 186 // For SymbolVendor only 187 //------------------------------------------------------------------ 188 DISALLOW_COPY_AND_ASSIGN (SymbolVendor); 189}; 190 191 192} // namespace lldb_private 193 194#endif // liblldb_SymbolVendor_h_ 195