aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Symbol/SymbolVendor.h
blob: 0eeea4eb466bc3a77d8487a17a940cd1211322f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
//===-- SymbolVendor.h ------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef liblldb_SymbolVendor_h_
#define liblldb_SymbolVendor_h_

#include <vector>

#include "lldb/lldb-private.h"
#include "lldb/Core/ModuleChild.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Symbol/ClangNamespaceDecl.h"
#include "lldb/Symbol/TypeList.h"


namespace lldb_private {

//----------------------------------------------------------------------
// The symbol vendor class is designed to abstract the process of
// searching for debug information for a given module. Platforms can
// subclass this class and provide extra ways to find debug information.
// Examples would be a subclass that would allow for locating a stand
// alone debug file, parsing debug maps, or runtime data in the object
// files. A symbol vendor can use multiple sources (SymbolFile
// objects) to provide the information and only parse as deep as needed
// in order to provide the information that is requested.
//----------------------------------------------------------------------
class SymbolVendor :
    public ModuleChild,
    public PluginInterface
{
public:
    static SymbolVendor*
    FindPlugin (const lldb::ModuleSP &module_sp,
                Stream *feedback_strm);

    //------------------------------------------------------------------
    // Constructors and Destructors
    //------------------------------------------------------------------
    SymbolVendor(const lldb::ModuleSP &module_sp);

    virtual
    ~SymbolVendor();

    void
    AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp);

    virtual void
    Dump(Stream *s);

    virtual lldb::LanguageType
    ParseCompileUnitLanguage (const SymbolContext& sc);
    
    virtual size_t
    ParseCompileUnitFunctions (const SymbolContext& sc);

    virtual bool
    ParseCompileUnitLineTable (const SymbolContext& sc);

    virtual bool
    ParseCompileUnitSupportFiles (const SymbolContext& sc,
                                  FileSpecList& support_files);

    virtual size_t
    ParseFunctionBlocks (const SymbolContext& sc);

    virtual size_t
    ParseTypes (const SymbolContext& sc);

    virtual size_t
    ParseVariablesForContext (const SymbolContext& sc);

    virtual Type*
    ResolveTypeUID(lldb::user_id_t type_uid);

    virtual uint32_t
    ResolveSymbolContext (const Address& so_addr,
                          uint32_t resolve_scope,
                          SymbolContext& sc);

    virtual uint32_t
    ResolveSymbolContext (const FileSpec& file_spec,
                          uint32_t line,
                          bool check_inlines,
                          uint32_t resolve_scope,
                          SymbolContextList& sc_list);

    virtual size_t
    FindGlobalVariables (const ConstString &name,
                         const ClangNamespaceDecl *namespace_decl,
                         bool append,
                         size_t max_matches,
                         VariableList& variables);

    virtual size_t
    FindGlobalVariables (const RegularExpression& regex,
                         bool append,
                         size_t max_matches,
                         VariableList& variables);

    virtual size_t
    FindFunctions (const ConstString &name,
                   const ClangNamespaceDecl *namespace_decl,
                   uint32_t name_type_mask,
                   bool include_inlines,
                   bool append,
                   SymbolContextList& sc_list);

    virtual size_t
    FindFunctions (const RegularExpression& regex,
                   bool include_inlines,
                   bool append,
                   SymbolContextList& sc_list);

    virtual size_t
    FindTypes (const SymbolContext& sc, 
               const ConstString &name,
               const ClangNamespaceDecl *namespace_decl, 
               bool append, 
               size_t max_matches,
               TypeList& types);

    virtual ClangNamespaceDecl
    FindNamespace (const SymbolContext& sc, 
                   const ConstString &name,
                   const ClangNamespaceDecl *parent_namespace_decl);
    
    virtual size_t
    GetNumCompileUnits();

    virtual bool
    SetCompileUnitAtIndex (size_t cu_idx,
                           const lldb::CompUnitSP &cu_sp);

    virtual lldb::CompUnitSP
    GetCompileUnitAtIndex(size_t idx);

    TypeList&
    GetTypeList()
    {
        return m_type_list;
    }

    const TypeList&
    GetTypeList() const
    {
        return m_type_list;
    }

    virtual size_t
    GetTypes (SymbolContextScope *sc_scope,
              uint32_t type_mask,
              TypeList &type_list);

    SymbolFile *
    GetSymbolFile()
    {
        return m_sym_file_ap.get();
    }

    // Get module unified section list symbol table.
    virtual Symtab *
    GetSymtab ();

    // Clear module unified section list symbol table.
    virtual void
    ClearSymtab ();

    //------------------------------------------------------------------
    // PluginInterface protocol
    //------------------------------------------------------------------
    virtual ConstString
    GetPluginName();

    virtual uint32_t
    GetPluginVersion();

protected:
    //------------------------------------------------------------------
    // Classes that inherit from SymbolVendor can see and modify these
    //------------------------------------------------------------------
    typedef std::vector<lldb::CompUnitSP> CompileUnits;
    typedef CompileUnits::iterator CompileUnitIter;
    typedef CompileUnits::const_iterator CompileUnitConstIter;

    TypeList m_type_list; // Uniqued types for all parsers owned by this module
    CompileUnits m_compile_units; // The current compile units
    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)
    std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Subclasses can add more of these if needed.

private:
    //------------------------------------------------------------------
    // For SymbolVendor only
    //------------------------------------------------------------------
    DISALLOW_COPY_AND_ASSIGN (SymbolVendor);
};


} // namespace lldb_private

#endif  // liblldb_SymbolVendor_h_