SymbolVendor.h revision 188091899842b140313b54e097f16efbe165c998
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//===-- SymbolVendor.h ------------------------------------------*- C++ -*-===//
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//                     The LLVM Compiler Infrastructure
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This file is distributed under the University of Illinois Open Source
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// License. See LICENSE.TXT for details.
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
858e6fbe4ee35d65e14b626c557d37565bf8ad179Ben Murdoch//===----------------------------------------------------------------------===//
97d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef liblldb_SymbolVendor_h_
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define liblldb_SymbolVendor_h_
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "lldb/lldb-private.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "lldb/Core/ModuleChild.h"
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "lldb/Core/PluginInterface.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "lldb/Symbol/ClangNamespaceDecl.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "lldb/Symbol/TypeList.h"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
21a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace lldb_private {
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//----------------------------------------------------------------------
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The symbol vendor class is designed to abstract the process of
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// searching for debug information for a given module. Platforms can
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// subclass this class and provide extra ways to find debug information.
28f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// Examples would be a subclass that would allow for locating a stand
29f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// alone debug file, parsing debug maps, or runtime data in the object
30f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// files. A symbol vendor can use multiple sources (SymbolFile
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// objects) to provide the information and only parse as deep as needed
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// in order to provide the information that is requested.
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)//----------------------------------------------------------------------
34cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class SymbolVendor :
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    public ModuleChild,
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    public PluginInterface
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles){
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)public:
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    static bool
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    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 uint32_t
104    FindGlobalVariables (const ConstString &name,
105                         const ClangNamespaceDecl *namespace_decl,
106                         bool append,
107                         uint32_t max_matches,
108                         VariableList& variables);
109
110    virtual uint32_t
111    FindGlobalVariables (const RegularExpression& regex,
112                         bool append,
113                         uint32_t max_matches,
114                         VariableList& variables);
115
116    virtual uint32_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 uint32_t
125    FindFunctions (const RegularExpression& regex,
126                   bool include_inlines,
127                   bool append,
128                   SymbolContextList& sc_list);
129
130    virtual uint32_t
131    FindTypes (const SymbolContext& sc,
132               const ConstString &name,
133               const ClangNamespaceDecl *namespace_decl,
134               bool append,
135               uint32_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 uint32_t
144    GetNumCompileUnits();
145
146    virtual bool
147    SetCompileUnitAtIndex (uint32_t cu_idx,
148                           const lldb::CompUnitSP &cu_sp);
149
150    virtual lldb::CompUnitSP
151    GetCompileUnitAtIndex(uint32_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::auto_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