Coverage Report

Created: 2022-01-15 10:30

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
Line
Count
Source (jump to first uncovered line)
1
//===-- SymbolFilePDB.h -------------------------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_SYMBOLFILEPDB_H
10
#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_SYMBOLFILEPDB_H
11
12
#include "lldb/Core/UniqueCStringMap.h"
13
#include "lldb/Symbol/SymbolFile.h"
14
#include "lldb/Symbol/VariableList.h"
15
#include "lldb/Utility/UserID.h"
16
17
#include "llvm/ADT/DenseMap.h"
18
#include "llvm/DebugInfo/PDB/IPDBSession.h"
19
#include "llvm/DebugInfo/PDB/PDB.h"
20
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
21
22
class PDBASTParser;
23
24
class SymbolFilePDB : public lldb_private::SymbolFile {
25
  /// LLVM RTTI support.
26
  static char ID;
27
28
public:
29
  /// LLVM RTTI support.
30
  /// \{
31
0
  bool isA(const void *ClassID) const override {
32
0
    return ClassID == &ID || SymbolFile::isA(ClassID);
33
0
  }
34
0
  static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
35
  /// \}
36
37
  // Static Functions
38
  static void Initialize();
39
40
  static void Terminate();
41
42
  static void DebuggerInitialize(lldb_private::Debugger &debugger);
43
44
0
  static llvm::StringRef GetPluginNameStatic() { return "pdb"; }
45
46
  static llvm::StringRef GetPluginDescriptionStatic();
47
48
  static lldb_private::SymbolFile *
49
  CreateInstance(lldb::ObjectFileSP objfile_sp);
50
51
  // Constructors and Destructors
52
  SymbolFilePDB(lldb::ObjectFileSP objfile_sp);
53
54
  ~SymbolFilePDB() override;
55
56
  uint32_t CalculateAbilities() override;
57
58
  void InitializeObject() override;
59
60
  // Compile Unit function calls
61
62
  lldb::LanguageType
63
  ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
64
65
  size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
66
67
  bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override;
68
69
  bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override;
70
71
  bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit,
72
                         lldb_private::FileSpecList &support_files) override;
73
74
  size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override;
75
76
  bool ParseImportedModules(
77
      const lldb_private::SymbolContext &sc,
78
      std::vector<lldb_private::SourceModule> &imported_modules) override;
79
80
  size_t ParseBlocksRecursive(lldb_private::Function &func) override;
81
82
  size_t
83
  ParseVariablesForContext(const lldb_private::SymbolContext &sc) override;
84
85
  lldb_private::Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
86
  llvm::Optional<ArrayInfo> GetDynamicArrayInfoForUID(
87
      lldb::user_id_t type_uid,
88
      const lldb_private::ExecutionContext *exe_ctx) override;
89
90
  bool CompleteType(lldb_private::CompilerType &compiler_type) override;
91
92
  lldb_private::CompilerDecl GetDeclForUID(lldb::user_id_t uid) override;
93
94
  lldb_private::CompilerDeclContext
95
  GetDeclContextForUID(lldb::user_id_t uid) override;
96
97
  lldb_private::CompilerDeclContext
98
  GetDeclContextContainingUID(lldb::user_id_t uid) override;
99
100
  void
101
  ParseDeclsForContext(lldb_private::CompilerDeclContext decl_ctx) override;
102
103
  uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr,
104
                                lldb::SymbolContextItem resolve_scope,
105
                                lldb_private::SymbolContext &sc) override;
106
107
  uint32_t ResolveSymbolContext(
108
      const lldb_private::SourceLocationSpec &src_location_spec,
109
      lldb::SymbolContextItem resolve_scope,
110
      lldb_private::SymbolContextList &sc_list) override;
111
112
  void
113
  FindGlobalVariables(lldb_private::ConstString name,
114
                      const lldb_private::CompilerDeclContext &parent_decl_ctx,
115
                      uint32_t max_matches,
116
                      lldb_private::VariableList &variables) override;
117
118
  void FindGlobalVariables(const lldb_private::RegularExpression &regex,
119
                           uint32_t max_matches,
120
                           lldb_private::VariableList &variables) override;
121
122
  void FindFunctions(lldb_private::ConstString name,
123
                     const lldb_private::CompilerDeclContext &parent_decl_ctx,
124
                     lldb::FunctionNameType name_type_mask,
125
                     bool include_inlines,
126
                     lldb_private::SymbolContextList &sc_list) override;
127
128
  void FindFunctions(const lldb_private::RegularExpression &regex,
129
                     bool include_inlines,
130
                     lldb_private::SymbolContextList &sc_list) override;
131
132
  void GetMangledNamesForFunction(
133
      const std::string &scope_qualified_name,
134
      std::vector<lldb_private::ConstString> &mangled_names) override;
135
136
  void AddSymbols(lldb_private::Symtab &symtab) override;
137
138
  void
139
  FindTypes(lldb_private::ConstString name,
140
            const lldb_private::CompilerDeclContext &parent_decl_ctx,
141
            uint32_t max_matches,
142
            llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
143
            lldb_private::TypeMap &types) override;
144
145
  void FindTypes(llvm::ArrayRef<lldb_private::CompilerContext> pattern,
146
                 lldb_private::LanguageSet languages,
147
                 llvm::DenseSet<SymbolFile *> &searched_symbol_files,
148
                 lldb_private::TypeMap &types) override;
149
150
  void FindTypesByRegex(const lldb_private::RegularExpression &regex,
151
                        uint32_t max_matches, lldb_private::TypeMap &types);
152
153
  void GetTypes(lldb_private::SymbolContextScope *sc_scope,
154
                lldb::TypeClass type_mask,
155
                lldb_private::TypeList &type_list) override;
156
157
  llvm::Expected<lldb_private::TypeSystem &>
158
  GetTypeSystemForLanguage(lldb::LanguageType language) override;
159
160
  lldb_private::CompilerDeclContext FindNamespace(
161
      lldb_private::ConstString name,
162
      const lldb_private::CompilerDeclContext &parent_decl_ctx) override;
163
164
0
  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
165
166
  llvm::pdb::IPDBSession &GetPDBSession();
167
168
  const llvm::pdb::IPDBSession &GetPDBSession() const;
169
170
  void DumpClangAST(lldb_private::Stream &s) override;
171
172
private:
173
  struct SecContribInfo {
174
    uint32_t Offset;
175
    uint32_t Size;
176
    uint32_t CompilandId;
177
  };
178
  using SecContribsMap = std::map<uint32_t, std::vector<SecContribInfo>>;
179
180
  uint32_t CalculateNumCompileUnits() override;
181
182
  lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override;
183
184
  lldb::CompUnitSP ParseCompileUnitForUID(uint32_t id,
185
                                          uint32_t index = UINT32_MAX);
186
187
  bool ParseCompileUnitLineTable(lldb_private::CompileUnit &comp_unit,
188
                                 uint32_t match_line);
189
190
  void BuildSupportFileIdToSupportFileIndexMap(
191
      const llvm::pdb::PDBSymbolCompiland &pdb_compiland,
192
      llvm::DenseMap<uint32_t, uint32_t> &index_map) const;
193
194
  void FindTypesByName(llvm::StringRef name,
195
                       const lldb_private::CompilerDeclContext &parent_decl_ctx,
196
                       uint32_t max_matches, lldb_private::TypeMap &types);
197
198
  std::string GetMangledForPDBData(const llvm::pdb::PDBSymbolData &pdb_data);
199
200
  lldb::VariableSP
201
  ParseVariableForPDBData(const lldb_private::SymbolContext &sc,
202
                          const llvm::pdb::PDBSymbolData &pdb_data);
203
204
  size_t ParseVariables(const lldb_private::SymbolContext &sc,
205
                        const llvm::pdb::PDBSymbol &pdb_data,
206
                        lldb_private::VariableList *variable_list = nullptr);
207
208
  lldb::CompUnitSP
209
  GetCompileUnitContainsAddress(const lldb_private::Address &so_addr);
210
211
  typedef std::vector<lldb_private::Type *> TypeCollection;
212
213
  void GetTypesForPDBSymbol(const llvm::pdb::PDBSymbol &pdb_symbol,
214
                            uint32_t type_mask,
215
                            TypeCollection &type_collection);
216
217
  lldb_private::Function *
218
  ParseCompileUnitFunctionForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func,
219
                                     lldb_private::CompileUnit &comp_unit);
220
221
  void GetCompileUnitIndex(const llvm::pdb::PDBSymbolCompiland &pdb_compiland,
222
                           uint32_t &index);
223
224
  PDBASTParser *GetPDBAstParser();
225
226
  std::unique_ptr<llvm::pdb::PDBSymbolCompiland>
227
  GetPDBCompilandByUID(uint32_t uid);
228
229
  lldb_private::Mangled
230
  GetMangledForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func);
231
232
  bool ResolveFunction(const llvm::pdb::PDBSymbolFunc &pdb_func,
233
                       bool include_inlines,
234
                       lldb_private::SymbolContextList &sc_list);
235
236
  bool ResolveFunction(uint32_t uid, bool include_inlines,
237
                       lldb_private::SymbolContextList &sc_list);
238
239
  void CacheFunctionNames();
240
241
  bool DeclContextMatchesThisSymbolFile(
242
      const lldb_private::CompilerDeclContext &decl_ctx);
243
244
  uint32_t GetCompilandId(const llvm::pdb::PDBSymbolData &data);
245
246
  llvm::DenseMap<uint32_t, lldb::CompUnitSP> m_comp_units;
247
  llvm::DenseMap<uint32_t, lldb::TypeSP> m_types;
248
  llvm::DenseMap<uint32_t, lldb::VariableSP> m_variables;
249
  llvm::DenseMap<uint64_t, std::string> m_public_names;
250
251
  SecContribsMap m_sec_contribs;
252
253
  std::vector<lldb::TypeSP> m_builtin_types;
254
  std::unique_ptr<llvm::pdb::IPDBSession> m_session_up;
255
  std::unique_ptr<llvm::pdb::PDBSymbolExe> m_global_scope_up;
256
257
  lldb_private::UniqueCStringMap<uint32_t> m_func_full_names;
258
  lldb_private::UniqueCStringMap<uint32_t> m_func_base_names;
259
  lldb_private::UniqueCStringMap<uint32_t> m_func_method_names;
260
};
261
262
#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_SYMBOLFILEPDB_H