]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Symbol/SymbolVendor.h
Update compiler-rt to release_39 branch r288513. Since this contains a
[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/lldb-private.h"
16 #include "lldb/Core/ModuleChild.h"
17 #include "lldb/Core/PluginInterface.h"
18 #include "lldb/Symbol/TypeList.h"
19 #include "lldb/Symbol/TypeMap.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
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 :
35     public ModuleChild,
36     public PluginInterface
37 {
38 public:
39     static SymbolVendor*
40     FindPlugin (const lldb::ModuleSP &module_sp,
41                 Stream *feedback_strm);
42
43     //------------------------------------------------------------------
44     // Constructors and Destructors
45     //------------------------------------------------------------------
46     SymbolVendor(const lldb::ModuleSP &module_sp);
47
48     ~SymbolVendor() override;
49
50     void
51     AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp);
52
53     virtual void
54     Dump(Stream *s);
55
56     virtual lldb::LanguageType
57     ParseCompileUnitLanguage (const SymbolContext& sc);
58     
59     virtual size_t
60     ParseCompileUnitFunctions (const SymbolContext& sc);
61
62     virtual bool
63     ParseCompileUnitLineTable (const SymbolContext& sc);
64
65     virtual bool
66     ParseCompileUnitDebugMacros (const SymbolContext& sc);
67
68     virtual bool
69     ParseCompileUnitSupportFiles (const SymbolContext& sc,
70                                   FileSpecList& support_files);
71
72     virtual bool
73     ParseCompileUnitIsOptimized(const SymbolContext &sc);
74
75     virtual bool
76     ParseImportedModules (const SymbolContext &sc,
77                           std::vector<ConstString> &imported_modules);
78
79     virtual size_t
80     ParseFunctionBlocks (const SymbolContext& sc);
81
82     virtual size_t
83     ParseTypes (const SymbolContext& sc);
84
85     virtual size_t
86     ParseVariablesForContext (const SymbolContext& sc);
87
88     virtual Type*
89     ResolveTypeUID(lldb::user_id_t type_uid);
90
91     virtual uint32_t
92     ResolveSymbolContext (const Address& so_addr,
93                           uint32_t resolve_scope,
94                           SymbolContext& sc);
95
96     virtual uint32_t
97     ResolveSymbolContext (const FileSpec& file_spec,
98                           uint32_t line,
99                           bool check_inlines,
100                           uint32_t resolve_scope,
101                           SymbolContextList& sc_list);
102
103     virtual size_t
104     FindGlobalVariables (const ConstString &name,
105                          const CompilerDeclContext *parent_decl_ctx,
106                          bool append,
107                          size_t max_matches,
108                          VariableList& variables);
109
110     virtual size_t
111     FindGlobalVariables (const RegularExpression& regex,
112                          bool append,
113                          size_t max_matches,
114                          VariableList& variables);
115
116     virtual size_t
117     FindFunctions (const ConstString &name,
118                    const CompilerDeclContext *parent_decl_ctx,
119                    uint32_t name_type_mask,
120                    bool include_inlines,
121                    bool append,
122                    SymbolContextList& sc_list);
123
124     virtual size_t
125     FindFunctions (const RegularExpression& regex,
126                    bool include_inlines,
127                    bool append,
128                    SymbolContextList& sc_list);
129
130     virtual size_t
131     FindTypes (const SymbolContext& sc, 
132                const ConstString &name,
133                const CompilerDeclContext *parent_decl_ctx, 
134                bool append, 
135                size_t max_matches,
136                llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
137                TypeMap& types);
138
139     virtual size_t
140     FindTypes (const std::vector<CompilerContext> &context, bool append, TypeMap& types);
141
142     virtual CompilerDeclContext
143     FindNamespace (const SymbolContext& sc, 
144                    const ConstString &name,
145                    const CompilerDeclContext *parent_decl_ctx);
146     
147     virtual size_t
148     GetNumCompileUnits();
149
150     virtual bool
151     SetCompileUnitAtIndex (size_t cu_idx,
152                            const lldb::CompUnitSP &cu_sp);
153
154     virtual lldb::CompUnitSP
155     GetCompileUnitAtIndex(size_t idx);
156
157     TypeList&
158     GetTypeList()
159     {
160         return m_type_list;
161     }
162
163     const TypeList&
164     GetTypeList() const
165     {
166         return m_type_list;
167     }
168
169     virtual size_t
170     GetTypes (SymbolContextScope *sc_scope,
171               uint32_t type_mask,
172               TypeList &type_list);
173
174     SymbolFile *
175     GetSymbolFile()
176     {
177         return m_sym_file_ap.get();
178     }
179
180     FileSpec
181     GetMainFileSpec() const;
182
183     // Get module unified section list symbol table.
184     virtual Symtab *
185     GetSymtab ();
186
187     // Clear module unified section list symbol table.
188     virtual void
189     ClearSymtab ();
190
191     //------------------------------------------------------------------
192     /// Notify the SymbolVendor that the file addresses in the Sections
193     /// for this module have been changed.
194     //------------------------------------------------------------------
195     virtual void
196     SectionFileAddressesChanged ();
197
198     //------------------------------------------------------------------
199     // PluginInterface protocol
200     //------------------------------------------------------------------
201     ConstString
202     GetPluginName() override;
203
204     uint32_t
205     GetPluginVersion() override;
206
207 protected:
208     //------------------------------------------------------------------
209     // Classes that inherit from SymbolVendor can see and modify these
210     //------------------------------------------------------------------
211     typedef std::vector<lldb::CompUnitSP> CompileUnits;
212     typedef CompileUnits::iterator CompileUnitIter;
213     typedef CompileUnits::const_iterator CompileUnitConstIter;
214
215     TypeList m_type_list; // Uniqued types for all parsers owned by this module
216     CompileUnits m_compile_units; // The current compile units
217     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)
218     std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Subclasses can add more of these if needed.
219
220 private:
221     //------------------------------------------------------------------
222     // For SymbolVendor only
223     //------------------------------------------------------------------
224     DISALLOW_COPY_AND_ASSIGN (SymbolVendor);
225 };
226
227 } // namespace lldb_private
228
229 #endif // liblldb_SymbolVendor_h_