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