SymbolVendor.h revision 12bec71b323dc520f0e985a86e09c4712559e115
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/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 (Module* module);
50
51    //------------------------------------------------------------------
52    // Constructors and Destructors
53    //------------------------------------------------------------------
54    SymbolVendor(Module *module);
55
56    virtual
57    ~SymbolVendor();
58
59    void
60    AddSymbolFileRepresendation(ObjectFile *obj_file);
61
62    virtual void
63    Dump(Stream *s);
64
65    virtual size_t
66    ParseCompileUnitFunctions (const SymbolContext& sc);
67
68    virtual bool
69    ParseCompileUnitLineTable (const SymbolContext& sc);
70
71    virtual bool
72    ParseCompileUnitSupportFiles (const SymbolContext& sc,
73                                  FileSpecList& support_files);
74
75    virtual size_t
76    ParseFunctionBlocks (const SymbolContext& sc);
77
78    virtual size_t
79    ParseTypes (const SymbolContext& sc);
80
81    virtual size_t
82    ParseVariablesForContext (const SymbolContext& sc);
83
84    virtual Type*
85    ResolveTypeUID(lldb::user_id_t type_uid);
86
87    virtual uint32_t
88    ResolveSymbolContext (const Address& so_addr,
89                          uint32_t resolve_scope,
90                          SymbolContext& sc);
91
92    virtual uint32_t
93    ResolveSymbolContext (const FileSpec& file_spec,
94                          uint32_t line,
95                          bool check_inlines,
96                          uint32_t resolve_scope,
97                          SymbolContextList& sc_list);
98
99    virtual uint32_t
100    FindGlobalVariables(const ConstString &name,
101                        bool append,
102                        uint32_t max_matches,
103                        VariableList& variables);
104
105    virtual uint32_t
106    FindGlobalVariables(const RegularExpression& regex,
107                        bool append,
108                        uint32_t max_matches,
109                        VariableList& variables);
110
111    virtual uint32_t
112    FindFunctions(const ConstString &name,
113                  uint32_t name_type_mask,
114                  bool append,
115                  SymbolContextList& sc_list);
116
117    virtual uint32_t
118    FindFunctions(const RegularExpression& regex,
119                  bool append,
120                  SymbolContextList& sc_list);
121
122    virtual uint32_t
123    GetNumCompileUnits();
124
125    virtual bool
126    SetCompileUnitAtIndex (lldb::CompUnitSP& cu,
127                           uint32_t index);
128
129    virtual lldb::CompUnitSP
130    GetCompileUnitAtIndex(uint32_t idx);
131
132    TypeList&
133    GetTypeList()
134    {
135        return m_type_list;
136    }
137
138    const TypeList&
139    GetTypeList() const
140    {
141        return m_type_list;
142    }
143
144    SymbolFile *
145    GetSymbolFile()
146    {
147        return m_sym_file_ap.get();
148    }
149
150    //------------------------------------------------------------------
151    // PluginInterface protocol
152    //------------------------------------------------------------------
153    virtual const char *
154    GetPluginName();
155
156    virtual const char *
157    GetShortPluginName();
158
159    virtual uint32_t
160    GetPluginVersion();
161
162    virtual void
163    GetPluginCommandHelp (const char *command, Stream *strm);
164
165    virtual Error
166    ExecutePluginCommand (Args &command, Stream *strm);
167
168    virtual Log *
169    EnablePluginLogging (Stream *strm, Args &command);
170
171protected:
172    //------------------------------------------------------------------
173    // Classes that inherit from SymbolVendor can see and modify these
174    //------------------------------------------------------------------
175    typedef std::vector<lldb::CompUnitSP> CompileUnits;
176    typedef CompileUnits::iterator CompileUnitIter;
177    typedef CompileUnits::const_iterator CompileUnitConstIter;
178
179    mutable Mutex m_mutex;
180    TypeList m_type_list; // Uniqued types for all parsers owned by this module
181    CompileUnits m_compile_units; // The current compile units
182    std::auto_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Suclasses can add more of these if needed.
183
184private:
185    //------------------------------------------------------------------
186    // For SymbolVendor only
187    //------------------------------------------------------------------
188    DISALLOW_COPY_AND_ASSIGN (SymbolVendor);
189};
190
191
192} // namespace lldb_private
193
194#endif  // liblldb_SymbolVendor_h_
195