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 ParseLanguage(CompileUnit &comp_unit);
51 virtual size_t ParseFunctions(CompileUnit &comp_unit);
53 virtual bool ParseLineTable(CompileUnit &comp_unit);
55 virtual bool ParseDebugMacros(CompileUnit &comp_unit);
57 virtual bool ParseSupportFiles(CompileUnit &comp_unit,
58 FileSpecList &support_files);
60 virtual bool ParseIsOptimized(CompileUnit &comp_unit);
62 virtual size_t ParseTypes(CompileUnit &comp_unit);
64 virtual bool ParseImportedModules(const SymbolContext &sc,
65 std::vector<ConstString> &imported_modules);
67 virtual size_t ParseBlocksRecursive(Function &func);
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 lldb::SymbolContextItem resolve_scope,
77 virtual uint32_t ResolveSymbolContext(const FileSpec &file_spec,
78 uint32_t line, bool check_inlines,
79 lldb::SymbolContextItem 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 lldb::FunctionNameType name_type_mask,
94 bool include_inlines, bool append,
95 SymbolContextList &sc_list);
97 virtual size_t FindFunctions(const RegularExpression ®ex,
98 bool include_inlines, bool append,
99 SymbolContextList &sc_list);
102 FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
103 bool append, size_t max_matches,
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 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,
126 lldb::TypeClass type_mask, 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.
167 Symtab *m_symtab; // Save a symtab once to not pass it through `AddSymbols` of
168 // the symbol file each time when it is needed
171 //------------------------------------------------------------------
172 // For SymbolVendor only
173 //------------------------------------------------------------------
174 DISALLOW_COPY_AND_ASSIGN(SymbolVendor);
177 } // namespace lldb_private
179 #endif // liblldb_SymbolVendor_h_