1 //===-- SymbolVendor.h ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_SymbolVendor_h_
11 #define liblldb_SymbolVendor_h_
15 #include "lldb/Core/ModuleChild.h"
16 #include "lldb/Core/PluginInterface.h"
17 #include "lldb/Symbol/TypeList.h"
18 #include "lldb/Symbol/TypeMap.h"
19 #include "lldb/lldb-private.h"
20 #include "llvm/ADT/DenseSet.h"
22 namespace lldb_private {
24 //----------------------------------------------------------------------
25 // The symbol vendor class is designed to abstract the process of searching for
26 // debug information for a given module. Platforms can subclass this class and
27 // provide extra ways to find debug information. Examples would be a subclass
28 // that would allow for locating a stand alone debug file, parsing debug maps,
29 // or runtime data in the object files. A symbol vendor can use multiple
30 // sources (SymbolFile objects) to provide the information and only parse as
31 // deep as needed in order to provide the information that is requested.
32 //----------------------------------------------------------------------
33 class SymbolVendor : public ModuleChild, public PluginInterface {
35 static SymbolVendor *FindPlugin(const lldb::ModuleSP &module_sp,
36 Stream *feedback_strm);
38 //------------------------------------------------------------------
39 // Constructors and Destructors
40 //------------------------------------------------------------------
41 SymbolVendor(const lldb::ModuleSP &module_sp);
43 ~SymbolVendor() override;
45 void AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp);
47 virtual void Dump(Stream *s);
49 virtual lldb::LanguageType ParseCompileUnitLanguage(const SymbolContext &sc);
51 virtual size_t ParseCompileUnitFunctions(const SymbolContext &sc);
53 virtual bool ParseCompileUnitLineTable(const SymbolContext &sc);
55 virtual bool ParseCompileUnitDebugMacros(const SymbolContext &sc);
57 virtual bool ParseCompileUnitSupportFiles(const SymbolContext &sc,
58 FileSpecList &support_files);
60 virtual bool ParseCompileUnitIsOptimized(const SymbolContext &sc);
62 virtual bool ParseImportedModules(const SymbolContext &sc,
63 std::vector<ConstString> &imported_modules);
65 virtual size_t ParseFunctionBlocks(const SymbolContext &sc);
67 virtual size_t ParseTypes(const SymbolContext &sc);
69 virtual size_t ParseVariablesForContext(const SymbolContext &sc);
71 virtual Type *ResolveTypeUID(lldb::user_id_t type_uid);
73 virtual uint32_t ResolveSymbolContext(const Address &so_addr,
74 uint32_t resolve_scope,
77 virtual uint32_t ResolveSymbolContext(const FileSpec &file_spec,
78 uint32_t line, bool check_inlines,
79 uint32_t resolve_scope,
80 SymbolContextList &sc_list);
82 virtual size_t FindGlobalVariables(const ConstString &name,
83 const CompilerDeclContext *parent_decl_ctx,
85 VariableList &variables);
87 virtual size_t FindGlobalVariables(const RegularExpression ®ex,
89 VariableList &variables);
91 virtual size_t FindFunctions(const ConstString &name,
92 const CompilerDeclContext *parent_decl_ctx,
93 uint32_t name_type_mask, bool include_inlines,
94 bool append, SymbolContextList &sc_list);
96 virtual size_t FindFunctions(const RegularExpression ®ex,
97 bool include_inlines, bool append,
98 SymbolContextList &sc_list);
101 FindTypes(const SymbolContext &sc, const ConstString &name,
102 const CompilerDeclContext *parent_decl_ctx, bool append,
104 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
107 virtual size_t FindTypes(const std::vector<CompilerContext> &context,
108 bool append, TypeMap &types);
110 virtual CompilerDeclContext
111 FindNamespace(const SymbolContext &sc, const ConstString &name,
112 const CompilerDeclContext *parent_decl_ctx);
114 virtual size_t GetNumCompileUnits();
116 virtual bool SetCompileUnitAtIndex(size_t cu_idx,
117 const lldb::CompUnitSP &cu_sp);
119 virtual lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx);
121 TypeList &GetTypeList() { return m_type_list; }
123 const TypeList &GetTypeList() const { return m_type_list; }
125 virtual size_t GetTypes(SymbolContextScope *sc_scope, uint32_t type_mask,
126 TypeList &type_list);
128 SymbolFile *GetSymbolFile() { return m_sym_file_ap.get(); }
130 FileSpec GetMainFileSpec() const;
132 // Get module unified section list symbol table.
133 virtual Symtab *GetSymtab();
135 // Clear module unified section list symbol table.
136 virtual void ClearSymtab();
138 //------------------------------------------------------------------
139 /// Notify the SymbolVendor that the file addresses in the Sections
140 /// for this module have been changed.
141 //------------------------------------------------------------------
142 virtual void SectionFileAddressesChanged();
144 //------------------------------------------------------------------
145 // PluginInterface protocol
146 //------------------------------------------------------------------
147 ConstString GetPluginName() override;
149 uint32_t GetPluginVersion() override;
152 //------------------------------------------------------------------
153 // Classes that inherit from SymbolVendor can see and modify these
154 //------------------------------------------------------------------
155 typedef std::vector<lldb::CompUnitSP> CompileUnits;
156 typedef CompileUnits::iterator CompileUnitIter;
157 typedef CompileUnits::const_iterator CompileUnitConstIter;
159 TypeList m_type_list; // Uniqued types for all parsers owned by this module
160 CompileUnits m_compile_units; // The current compile units
161 lldb::ObjectFileSP m_objfile_sp; // Keep a reference to the object file in
162 // case it isn't the same as the module
163 // object file (debug symbols in a separate
165 std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Subclasses
166 // can add more of these if needed.
169 //------------------------------------------------------------------
170 // For SymbolVendor only
171 //------------------------------------------------------------------
172 DISALLOW_COPY_AND_ASSIGN(SymbolVendor);
175 } // namespace lldb_private
177 #endif // liblldb_SymbolVendor_h_