SymbolFileNativePDB.h
9.47 KB
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
//===-- SymbolFileNativePDB.h -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_SYMBOLFILENATIVEPDB_H
#define LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_SYMBOLFILENATIVEPDB_H
#include "lldb/Symbol/SymbolFile.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/DebugInfo/CodeView/CVRecord.h"
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
#include "CompileUnitIndex.h"
#include "PdbIndex.h"
namespace clang {
class TagDecl;
}
namespace llvm {
namespace codeview {
class ClassRecord;
class EnumRecord;
class ModifierRecord;
class PointerRecord;
struct UnionRecord;
} // namespace codeview
} // namespace llvm
namespace lldb_private {
namespace npdb {
class PdbAstBuilder;
class SymbolFileNativePDB : public SymbolFile {
friend class UdtRecordCompleter;
/// LLVM RTTI support.
static char ID;
public:
/// LLVM RTTI support.
/// \{
bool isA(const void *ClassID) const override {
return ClassID == &ID || SymbolFile::isA(ClassID);
}
static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
/// \}
// Static Functions
static void Initialize();
static void Terminate();
static void DebuggerInitialize(Debugger &debugger);
static ConstString GetPluginNameStatic();
static const char *GetPluginDescriptionStatic();
static SymbolFile *CreateInstance(lldb::ObjectFileSP objfile_sp);
// Constructors and Destructors
SymbolFileNativePDB(lldb::ObjectFileSP objfile_sp);
~SymbolFileNativePDB() override;
uint32_t CalculateAbilities() override;
void InitializeObject() override;
// Compile Unit function calls
void
ParseDeclsForContext(lldb_private::CompilerDeclContext decl_ctx) override;
lldb::LanguageType
ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override;
bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override;
bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit,
FileSpecList &support_files) override;
size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override;
bool ParseImportedModules(
const SymbolContext &sc,
std::vector<lldb_private::SourceModule> &imported_modules) override;
size_t ParseBlocksRecursive(Function &func) override;
void FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
VariableList &variables) override;
size_t ParseVariablesForContext(const SymbolContext &sc) override;
void AddSymbols(Symtab &symtab) override;
CompilerDecl GetDeclForUID(lldb::user_id_t uid) override;
CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) override;
CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) override;
Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
llvm::Optional<ArrayInfo> GetDynamicArrayInfoForUID(
lldb::user_id_t type_uid,
const lldb_private::ExecutionContext *exe_ctx) override;
bool CompleteType(CompilerType &compiler_type) override;
uint32_t ResolveSymbolContext(const Address &so_addr,
lldb::SymbolContextItem resolve_scope,
SymbolContext &sc) override;
uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line,
bool check_inlines,
lldb::SymbolContextItem resolve_scope,
SymbolContextList &sc_list) override;
void GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask,
TypeList &type_list) override;
void FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, SymbolContextList &sc_list) override;
void FindFunctions(const RegularExpression ®ex, bool include_inlines,
SymbolContextList &sc_list) override;
void FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) override;
void FindTypes(llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) override;
llvm::Expected<TypeSystem &>
GetTypeSystemForLanguage(lldb::LanguageType language) override;
CompilerDeclContext
FindNamespace(ConstString name,
const CompilerDeclContext *parent_decl_ctx) override;
ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
llvm::pdb::PDBFile &GetPDBFile() { return m_index->pdb(); }
const llvm::pdb::PDBFile &GetPDBFile() const { return m_index->pdb(); }
void DumpClangAST(Stream &s) override;
private:
uint32_t CalculateNumCompileUnits() override;
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override;
void FindTypesByName(llvm::StringRef name, uint32_t max_matches,
TypeMap &types);
lldb::TypeSP CreateModifierType(PdbTypeSymId type_id,
const llvm::codeview::ModifierRecord &mr,
CompilerType ct);
lldb::TypeSP CreatePointerType(PdbTypeSymId type_id,
const llvm::codeview::PointerRecord &pr,
CompilerType ct);
lldb::TypeSP CreateSimpleType(llvm::codeview::TypeIndex ti, CompilerType ct);
lldb::TypeSP CreateTagType(PdbTypeSymId type_id,
const llvm::codeview::ClassRecord &cr,
CompilerType ct);
lldb::TypeSP CreateTagType(PdbTypeSymId type_id,
const llvm::codeview::EnumRecord &er,
CompilerType ct);
lldb::TypeSP CreateTagType(PdbTypeSymId type_id,
const llvm::codeview::UnionRecord &ur,
CompilerType ct);
lldb::TypeSP CreateArrayType(PdbTypeSymId type_id,
const llvm::codeview::ArrayRecord &ar,
CompilerType ct);
lldb::TypeSP CreateFunctionType(PdbTypeSymId type_id,
const llvm::codeview::MemberFunctionRecord &pr,
CompilerType ct);
lldb::TypeSP CreateProcedureType(PdbTypeSymId type_id,
const llvm::codeview::ProcedureRecord &pr,
CompilerType ct);
lldb::TypeSP CreateClassStructUnion(PdbTypeSymId type_id,
const llvm::codeview::TagRecord &record,
size_t size, CompilerType ct);
lldb::FunctionSP GetOrCreateFunction(PdbCompilandSymId func_id,
CompileUnit &comp_unit);
lldb::CompUnitSP GetOrCreateCompileUnit(const CompilandIndexItem &cci);
lldb::TypeSP GetOrCreateType(PdbTypeSymId type_id);
lldb::TypeSP GetOrCreateType(llvm::codeview::TypeIndex ti);
lldb::VariableSP GetOrCreateGlobalVariable(PdbGlobalSymId var_id);
Block &GetOrCreateBlock(PdbCompilandSymId block_id);
lldb::VariableSP GetOrCreateLocalVariable(PdbCompilandSymId scope_id,
PdbCompilandSymId var_id,
bool is_param);
lldb::TypeSP GetOrCreateTypedef(PdbGlobalSymId id);
lldb::FunctionSP CreateFunction(PdbCompilandSymId func_id,
CompileUnit &comp_unit);
Block &CreateBlock(PdbCompilandSymId block_id);
lldb::VariableSP CreateLocalVariable(PdbCompilandSymId scope_id,
PdbCompilandSymId var_id, bool is_param);
lldb::TypeSP CreateTypedef(PdbGlobalSymId id);
lldb::CompUnitSP CreateCompileUnit(const CompilandIndexItem &cci);
lldb::TypeSP CreateType(PdbTypeSymId type_id, CompilerType ct);
lldb::TypeSP CreateAndCacheType(PdbTypeSymId type_id);
lldb::VariableSP CreateGlobalVariable(PdbGlobalSymId var_id);
lldb::VariableSP CreateConstantSymbol(PdbGlobalSymId var_id,
const llvm::codeview::CVSymbol &cvs);
size_t ParseVariablesForCompileUnit(CompileUnit &comp_unit,
VariableList &variables);
size_t ParseVariablesForBlock(PdbCompilandSymId block_id);
llvm::BumpPtrAllocator m_allocator;
lldb::addr_t m_obj_load_address = 0;
bool m_done_full_type_scan = false;
std::unique_ptr<PdbIndex> m_index;
std::unique_ptr<PdbAstBuilder> m_ast;
llvm::DenseMap<lldb::user_id_t, lldb::VariableSP> m_global_vars;
llvm::DenseMap<lldb::user_id_t, lldb::VariableSP> m_local_variables;
llvm::DenseMap<lldb::user_id_t, lldb::BlockSP> m_blocks;
llvm::DenseMap<lldb::user_id_t, lldb::FunctionSP> m_functions;
llvm::DenseMap<lldb::user_id_t, lldb::CompUnitSP> m_compilands;
llvm::DenseMap<lldb::user_id_t, lldb::TypeSP> m_types;
};
} // namespace npdb
} // namespace lldb_private
#endif // lldb_Plugins_SymbolFile_PDB_SymbolFilePDB_h_