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
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 //----------------------------------------------------------------------
34 class SymbolVendor : public ModuleChild, public PluginInterface {
36 static SymbolVendor *FindPlugin(const lldb::ModuleSP &module_sp,
37 Stream *feedback_strm);
39 //------------------------------------------------------------------
40 // Constructors and Destructors
41 //------------------------------------------------------------------
42 SymbolVendor(const lldb::ModuleSP &module_sp);
44 ~SymbolVendor() override;
46 void AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp);
48 virtual void Dump(Stream *s);
50 virtual lldb::LanguageType ParseCompileUnitLanguage(const SymbolContext &sc);
52 virtual size_t ParseCompileUnitFunctions(const SymbolContext &sc);
54 virtual bool ParseCompileUnitLineTable(const SymbolContext &sc);
56 virtual bool ParseCompileUnitDebugMacros(const SymbolContext &sc);
58 virtual bool ParseCompileUnitSupportFiles(const SymbolContext &sc,
59 FileSpecList &support_files);
61 virtual bool ParseCompileUnitIsOptimized(const SymbolContext &sc);
63 virtual bool ParseImportedModules(const SymbolContext &sc,
64 std::vector<ConstString> &imported_modules);
66 virtual size_t ParseFunctionBlocks(const SymbolContext &sc);
68 virtual size_t ParseTypes(const SymbolContext &sc);
70 virtual size_t ParseVariablesForContext(const SymbolContext &sc);
72 virtual Type *ResolveTypeUID(lldb::user_id_t type_uid);
74 virtual uint32_t ResolveSymbolContext(const Address &so_addr,
75 uint32_t resolve_scope,
78 virtual uint32_t ResolveSymbolContext(const FileSpec &file_spec,
79 uint32_t line, bool check_inlines,
80 uint32_t resolve_scope,
81 SymbolContextList &sc_list);
83 virtual size_t FindGlobalVariables(const ConstString &name,
84 const CompilerDeclContext *parent_decl_ctx,
85 bool append, size_t max_matches,
86 VariableList &variables);
88 virtual size_t FindGlobalVariables(const RegularExpression ®ex,
89 bool append, size_t max_matches,
90 VariableList &variables);
92 virtual size_t FindFunctions(const ConstString &name,
93 const CompilerDeclContext *parent_decl_ctx,
94 uint32_t name_type_mask, bool include_inlines,
95 bool append, SymbolContextList &sc_list);
97 virtual size_t FindFunctions(const RegularExpression ®ex,
98 bool include_inlines, bool append,
99 SymbolContextList &sc_list);
102 FindTypes(const SymbolContext &sc, const ConstString &name,
103 const CompilerDeclContext *parent_decl_ctx, bool append,
105 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
108 virtual size_t FindTypes(const std::vector<CompilerContext> &context,
109 bool append, TypeMap &types);
111 virtual CompilerDeclContext
112 FindNamespace(const SymbolContext &sc, const ConstString &name,
113 const CompilerDeclContext *parent_decl_ctx);
115 virtual size_t GetNumCompileUnits();
117 virtual bool SetCompileUnitAtIndex(size_t cu_idx,
118 const lldb::CompUnitSP &cu_sp);
120 virtual lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx);
122 TypeList &GetTypeList() { return m_type_list; }
124 const TypeList &GetTypeList() const { return m_type_list; }
126 virtual size_t GetTypes(SymbolContextScope *sc_scope, uint32_t type_mask,
127 TypeList &type_list);
129 SymbolFile *GetSymbolFile() { return m_sym_file_ap.get(); }
131 FileSpec GetMainFileSpec() const;
133 // Get module unified section list symbol table.
134 virtual Symtab *GetSymtab();
136 // Clear module unified section list symbol table.
137 virtual void ClearSymtab();
139 //------------------------------------------------------------------
140 /// Notify the SymbolVendor that the file addresses in the Sections
141 /// for this module have been changed.
142 //------------------------------------------------------------------
143 virtual void SectionFileAddressesChanged();
145 //------------------------------------------------------------------
146 // PluginInterface protocol
147 //------------------------------------------------------------------
148 ConstString GetPluginName() override;
150 uint32_t GetPluginVersion() override;
153 //------------------------------------------------------------------
154 // Classes that inherit from SymbolVendor can see and modify these
155 //------------------------------------------------------------------
156 typedef std::vector<lldb::CompUnitSP> CompileUnits;
157 typedef CompileUnits::iterator CompileUnitIter;
158 typedef CompileUnits::const_iterator CompileUnitConstIter;
160 TypeList m_type_list; // Uniqued types for all parsers owned by this module
161 CompileUnits m_compile_units; // The current compile units
162 lldb::ObjectFileSP m_objfile_sp; // Keep a reference to the object file in
163 // case it isn't the same as the module
164 // object file (debug symbols in a separate
166 std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Subclasses
167 // can add more of these if needed.
170 //------------------------------------------------------------------
171 // For SymbolVendor only
172 //------------------------------------------------------------------
173 DISALLOW_COPY_AND_ASSIGN(SymbolVendor);
176 } // namespace lldb_private
178 #endif // liblldb_SymbolVendor_h_