SymbolVendor.h revision 31ad9cc8eab4d183ebfc5a0ef0bb952cacb1bc50
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/Host/Mutex.h"
19#include "lldb/Symbol/ClangNamespaceDecl.h"
20#include "lldb/Symbol/TypeList.h"
21
22
23namespace lldb_private {
24
25//----------------------------------------------------------------------
26// The symbol vendor class is designed to abstract the process of
27// searching for debug information for a given module. Platforms can
28// subclass this class and provide extra ways to find debug information.
29// Examples would be a subclass that would allow for locating a stand
30// alone debug file, parsing debug maps, or runtime data in the object
31// files. A symbol vendor can use multiple sources (SymbolFile
32// objects) to provide the information and only parse as deep as needed
33// in order to provide the information that is requested.
34//----------------------------------------------------------------------
35class SymbolVendor :
36    public ModuleChild,
37    public PluginInterface
38{
39public:
40    static bool
41    RegisterPlugin (const char *name,
42                    const char *description,
43                    SymbolVendorCreateInstance create_callback);
44
45    static bool
46    UnregisterPlugin (SymbolVendorCreateInstance create_callback);
47
48
49    static SymbolVendor*
50    FindPlugin (Module* module);
51
52    //------------------------------------------------------------------
53    // Constructors and Destructors
54    //------------------------------------------------------------------
55    SymbolVendor(Module *module);
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 size_t
67    ParseCompileUnitFunctions (const SymbolContext& sc);
68
69    virtual bool
70    ParseCompileUnitLineTable (const SymbolContext& sc);
71
72    virtual bool
73    ParseCompileUnitSupportFiles (const SymbolContext& sc,
74                                  FileSpecList& support_files);
75
76    virtual size_t
77    ParseFunctionBlocks (const SymbolContext& sc);
78
79    virtual size_t
80    ParseTypes (const SymbolContext& sc);
81
82    virtual size_t
83    ParseVariablesForContext (const SymbolContext& sc);
84
85    virtual Type*
86    ResolveTypeUID(lldb::user_id_t type_uid);
87
88    virtual uint32_t
89    ResolveSymbolContext (const Address& so_addr,
90                          uint32_t resolve_scope,
91                          SymbolContext& sc);
92
93    virtual uint32_t
94    ResolveSymbolContext (const FileSpec& file_spec,
95                          uint32_t line,
96                          bool check_inlines,
97                          uint32_t resolve_scope,
98                          SymbolContextList& sc_list);
99
100    virtual uint32_t
101    FindGlobalVariables (const ConstString &name,
102                         const ClangNamespaceDecl *namespace_decl,
103                         bool append,
104                         uint32_t max_matches,
105                         VariableList& variables);
106
107    virtual uint32_t
108    FindGlobalVariables (const RegularExpression& regex,
109                         bool append,
110                         uint32_t max_matches,
111                         VariableList& variables);
112
113    virtual uint32_t
114    FindFunctions (const ConstString &name,
115                   const ClangNamespaceDecl *namespace_decl,
116                   uint32_t name_type_mask,
117                   bool append,
118                   SymbolContextList& sc_list);
119
120    virtual uint32_t
121    FindFunctions (const RegularExpression& regex,
122                   bool append,
123                   SymbolContextList& sc_list);
124
125    virtual uint32_t
126    FindTypes (const SymbolContext& sc,
127               const ConstString &name,
128               const ClangNamespaceDecl *namespace_decl,
129               bool append,
130               uint32_t max_matches,
131               TypeList& types);
132
133    virtual lldb_private::ClangNamespaceDecl
134    FindNamespace (const SymbolContext& sc,
135                   const ConstString &name,
136                   const ClangNamespaceDecl *parent_namespace_decl);
137
138    virtual uint32_t
139    GetNumCompileUnits();
140
141    virtual bool
142    SetCompileUnitAtIndex (lldb::CompUnitSP& cu,
143                           uint32_t index);
144
145    virtual lldb::CompUnitSP
146    GetCompileUnitAtIndex(uint32_t idx);
147
148    TypeList&
149    GetTypeList()
150    {
151        return m_type_list;
152    }
153
154    const TypeList&
155    GetTypeList() const
156    {
157        return m_type_list;
158    }
159
160    SymbolFile *
161    GetSymbolFile()
162    {
163        return m_sym_file_ap.get();
164    }
165
166    //------------------------------------------------------------------
167    // PluginInterface protocol
168    //------------------------------------------------------------------
169    virtual const char *
170    GetPluginName();
171
172    virtual const char *
173    GetShortPluginName();
174
175    virtual uint32_t
176    GetPluginVersion();
177
178protected:
179    //------------------------------------------------------------------
180    // Classes that inherit from SymbolVendor can see and modify these
181    //------------------------------------------------------------------
182    typedef std::vector<lldb::CompUnitSP> CompileUnits;
183    typedef CompileUnits::iterator CompileUnitIter;
184    typedef CompileUnits::const_iterator CompileUnitConstIter;
185
186    mutable Mutex m_mutex;
187    TypeList m_type_list; // Uniqued types for all parsers owned by this module
188    CompileUnits m_compile_units; // The current compile units
189    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)
190    std::auto_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Suclasses can add more of these if needed.
191
192private:
193    //------------------------------------------------------------------
194    // For SymbolVendor only
195    //------------------------------------------------------------------
196    DISALLOW_COPY_AND_ASSIGN (SymbolVendor);
197};
198
199
200} // namespace lldb_private
201
202#endif  // liblldb_SymbolVendor_h_
203