]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Symbol/SymbolVendor.h
MFV: r323381
[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
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 {
35 public:
36   static SymbolVendor *FindPlugin(const lldb::ModuleSP &module_sp,
37                                   Stream *feedback_strm);
38
39   //------------------------------------------------------------------
40   // Constructors and Destructors
41   //------------------------------------------------------------------
42   SymbolVendor(const lldb::ModuleSP &module_sp);
43
44   ~SymbolVendor() override;
45
46   void AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp);
47
48   virtual void Dump(Stream *s);
49
50   virtual lldb::LanguageType ParseCompileUnitLanguage(const SymbolContext &sc);
51
52   virtual size_t ParseCompileUnitFunctions(const SymbolContext &sc);
53
54   virtual bool ParseCompileUnitLineTable(const SymbolContext &sc);
55
56   virtual bool ParseCompileUnitDebugMacros(const SymbolContext &sc);
57
58   virtual bool ParseCompileUnitSupportFiles(const SymbolContext &sc,
59                                             FileSpecList &support_files);
60
61   virtual bool ParseCompileUnitIsOptimized(const SymbolContext &sc);
62
63   virtual bool ParseImportedModules(const SymbolContext &sc,
64                                     std::vector<ConstString> &imported_modules);
65
66   virtual size_t ParseFunctionBlocks(const SymbolContext &sc);
67
68   virtual size_t ParseTypes(const SymbolContext &sc);
69
70   virtual size_t ParseVariablesForContext(const SymbolContext &sc);
71
72   virtual Type *ResolveTypeUID(lldb::user_id_t type_uid);
73
74   virtual uint32_t ResolveSymbolContext(const Address &so_addr,
75                                         uint32_t resolve_scope,
76                                         SymbolContext &sc);
77
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);
82
83   virtual size_t FindGlobalVariables(const ConstString &name,
84                                      const CompilerDeclContext *parent_decl_ctx,
85                                      bool append, size_t max_matches,
86                                      VariableList &variables);
87
88   virtual size_t FindGlobalVariables(const RegularExpression &regex,
89                                      bool append, size_t max_matches,
90                                      VariableList &variables);
91
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);
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 SymbolContext &sc, const ConstString &name,
103             const CompilerDeclContext *parent_decl_ctx, bool append,
104             size_t max_matches,
105             llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
106             TypeMap &types);
107
108   virtual size_t FindTypes(const std::vector<CompilerContext> &context,
109                            bool append, TypeMap &types);
110
111   virtual CompilerDeclContext
112   FindNamespace(const SymbolContext &sc, const ConstString &name,
113                 const CompilerDeclContext *parent_decl_ctx);
114
115   virtual size_t GetNumCompileUnits();
116
117   virtual bool SetCompileUnitAtIndex(size_t cu_idx,
118                                      const lldb::CompUnitSP &cu_sp);
119
120   virtual lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx);
121
122   TypeList &GetTypeList() { return m_type_list; }
123
124   const TypeList &GetTypeList() const { return m_type_list; }
125
126   virtual size_t GetTypes(SymbolContextScope *sc_scope, uint32_t type_mask,
127                           TypeList &type_list);
128
129   SymbolFile *GetSymbolFile() { return m_sym_file_ap.get(); }
130
131   FileSpec GetMainFileSpec() const;
132
133   // Get module unified section list symbol table.
134   virtual Symtab *GetSymtab();
135
136   // Clear module unified section list symbol table.
137   virtual void ClearSymtab();
138
139   //------------------------------------------------------------------
140   /// Notify the SymbolVendor that the file addresses in the Sections
141   /// for this module have been changed.
142   //------------------------------------------------------------------
143   virtual void SectionFileAddressesChanged();
144
145   //------------------------------------------------------------------
146   // PluginInterface protocol
147   //------------------------------------------------------------------
148   ConstString GetPluginName() override;
149
150   uint32_t GetPluginVersion() override;
151
152 protected:
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;
159
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
165                                    // file)
166   std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Subclasses
167                                              // can add more of these if needed.
168
169 private:
170   //------------------------------------------------------------------
171   // For SymbolVendor only
172   //------------------------------------------------------------------
173   DISALLOW_COPY_AND_ASSIGN(SymbolVendor);
174 };
175
176 } // namespace lldb_private
177
178 #endif // liblldb_SymbolVendor_h_