]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Symbol/SymbolVendor.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Symbol / SymbolVendor.h
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/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"
21
22 namespace lldb_private {
23
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 {
34 public:
35   static SymbolVendor *FindPlugin(const lldb::ModuleSP &module_sp,
36                                   Stream *feedback_strm);
37
38   //------------------------------------------------------------------
39   // Constructors and Destructors
40   //------------------------------------------------------------------
41   SymbolVendor(const lldb::ModuleSP &module_sp);
42
43   ~SymbolVendor() override;
44
45   void AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp);
46
47   virtual void Dump(Stream *s);
48
49   virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit);
50
51   virtual size_t ParseFunctions(CompileUnit &comp_unit);
52
53   virtual bool ParseLineTable(CompileUnit &comp_unit);
54
55   virtual bool ParseDebugMacros(CompileUnit &comp_unit);
56
57   virtual bool ParseSupportFiles(CompileUnit &comp_unit,
58                                  FileSpecList &support_files);
59
60   virtual bool ParseIsOptimized(CompileUnit &comp_unit);
61
62   virtual size_t ParseTypes(CompileUnit &comp_unit);
63
64   virtual bool ParseImportedModules(const SymbolContext &sc,
65                                     std::vector<ConstString> &imported_modules);
66
67   virtual size_t ParseBlocksRecursive(Function &func);
68
69   virtual size_t ParseVariablesForContext(const SymbolContext &sc);
70
71   virtual Type *ResolveTypeUID(lldb::user_id_t type_uid);
72
73   virtual uint32_t ResolveSymbolContext(const Address &so_addr,
74                                         lldb::SymbolContextItem resolve_scope,
75                                         SymbolContext &sc);
76
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);
81
82   virtual size_t FindGlobalVariables(const ConstString &name,
83                                      const CompilerDeclContext *parent_decl_ctx,
84                                      size_t max_matches,
85                                      VariableList &variables);
86
87   virtual size_t FindGlobalVariables(const RegularExpression &regex,
88                                      size_t max_matches,
89                                      VariableList &variables);
90
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);
96
97   virtual size_t FindFunctions(const RegularExpression &regex,
98                                bool include_inlines, bool append,
99                                SymbolContextList &sc_list);
100
101   virtual size_t
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,
105             TypeMap &types);
106
107   virtual size_t FindTypes(const std::vector<CompilerContext> &context,
108                            bool append, TypeMap &types);
109
110   virtual CompilerDeclContext
111   FindNamespace(const ConstString &name,
112                 const CompilerDeclContext *parent_decl_ctx);
113
114   virtual size_t GetNumCompileUnits();
115
116   virtual bool SetCompileUnitAtIndex(size_t cu_idx,
117                                      const lldb::CompUnitSP &cu_sp);
118
119   virtual lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx);
120
121   TypeList &GetTypeList() { return m_type_list; }
122
123   const TypeList &GetTypeList() const { return m_type_list; }
124
125   virtual size_t GetTypes(SymbolContextScope *sc_scope,
126                           lldb::TypeClass type_mask, TypeList &type_list);
127
128   SymbolFile *GetSymbolFile() { return m_sym_file_ap.get(); }
129
130   FileSpec GetMainFileSpec() const;
131
132   // Get module unified section list symbol table.
133   virtual Symtab *GetSymtab();
134
135   // Clear module unified section list symbol table.
136   virtual void ClearSymtab();
137
138   //------------------------------------------------------------------
139   /// Notify the SymbolVendor that the file addresses in the Sections
140   /// for this module have been changed.
141   //------------------------------------------------------------------
142   virtual void SectionFileAddressesChanged();
143
144   //------------------------------------------------------------------
145   // PluginInterface protocol
146   //------------------------------------------------------------------
147   ConstString GetPluginName() override;
148
149   uint32_t GetPluginVersion() override;
150
151 protected:
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;
158
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
164                                    // file)
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
169
170 private:
171   //------------------------------------------------------------------
172   // For SymbolVendor only
173   //------------------------------------------------------------------
174   DISALLOW_COPY_AND_ASSIGN(SymbolVendor);
175 };
176
177 } // namespace lldb_private
178
179 #endif // liblldb_SymbolVendor_h_