SymbolVendor.h revision 102b2c2681c9a830afe25bfea35557421905e42c
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/ClangNamespaceDecl.h"
19#include "lldb/Symbol/TypeList.h"
20
21
22namespace 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//----------------------------------------------------------------------
34class SymbolVendor :
35    public ModuleChild,
36    public PluginInterface
37{
38public:
39    static bool
40    RegisterPlugin (const char *name,
41                    const char *description,
42                    SymbolVendorCreateInstance create_callback);
43
44    static bool
45    UnregisterPlugin (SymbolVendorCreateInstance create_callback);
46
47
48    static SymbolVendor*
49    FindPlugin (const lldb::ModuleSP &module_sp,
50                lldb_private::Stream *feedback_strm);
51
52    //------------------------------------------------------------------
53    // Constructors and Destructors
54    //------------------------------------------------------------------
55    SymbolVendor(const lldb::ModuleSP &module_sp);
56
57    virtual
58    ~SymbolVendor();
59
60    void
61    AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp);
62
63    virtual void
64    Dump(Stream *s);
65
66    virtual lldb::LanguageType
67    ParseCompileUnitLanguage (const SymbolContext& sc);
68
69    virtual size_t
70    ParseCompileUnitFunctions (const SymbolContext& sc);
71
72    virtual bool
73    ParseCompileUnitLineTable (const SymbolContext& sc);
74
75    virtual bool
76    ParseCompileUnitSupportFiles (const SymbolContext& sc,
77                                  FileSpecList& support_files);
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 ClangNamespaceDecl *namespace_decl,
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 ClangNamespaceDecl *namespace_decl,
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 ClangNamespaceDecl *namespace_decl,
134               bool append,
135               size_t max_matches,
136               TypeList& types);
137
138    virtual lldb_private::ClangNamespaceDecl
139    FindNamespace (const SymbolContext& sc,
140                   const ConstString &name,
141                   const ClangNamespaceDecl *parent_namespace_decl);
142
143    virtual size_t
144    GetNumCompileUnits();
145
146    virtual bool
147    SetCompileUnitAtIndex (size_t cu_idx,
148                           const lldb::CompUnitSP &cu_sp);
149
150    virtual lldb::CompUnitSP
151    GetCompileUnitAtIndex(size_t idx);
152
153    TypeList&
154    GetTypeList()
155    {
156        return m_type_list;
157    }
158
159    const TypeList&
160    GetTypeList() const
161    {
162        return m_type_list;
163    }
164
165    SymbolFile *
166    GetSymbolFile()
167    {
168        return m_sym_file_ap.get();
169    }
170
171    //------------------------------------------------------------------
172    // PluginInterface protocol
173    //------------------------------------------------------------------
174    virtual const char *
175    GetPluginName();
176
177    virtual const char *
178    GetShortPluginName();
179
180    virtual uint32_t
181    GetPluginVersion();
182
183protected:
184    //------------------------------------------------------------------
185    // Classes that inherit from SymbolVendor can see and modify these
186    //------------------------------------------------------------------
187    typedef std::vector<lldb::CompUnitSP> CompileUnits;
188    typedef CompileUnits::iterator CompileUnitIter;
189    typedef CompileUnits::const_iterator CompileUnitConstIter;
190
191    TypeList m_type_list; // Uniqued types for all parsers owned by this module
192    CompileUnits m_compile_units; // The current compile units
193    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)
194    std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Suclasses can add more of these if needed.
195
196private:
197    //------------------------------------------------------------------
198    // For SymbolVendor only
199    //------------------------------------------------------------------
200    DISALLOW_COPY_AND_ASSIGN (SymbolVendor);
201};
202
203
204} // namespace lldb_private
205
206#endif  // liblldb_SymbolVendor_h_
207