LLDB mainline
SymbolFilePDB.h
Go to the documentation of this file.
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
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#include <optional>
22
23class PDBASTParser;
24
26 /// LLVM RTTI support.
27 static char ID;
28
29public:
30 /// LLVM RTTI support.
31 /// \{
32 bool isA(const void *ClassID) const override {
33 return ClassID == &ID || SymbolFileCommon::isA(ClassID);
34 }
35 static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
36 /// \}
37
38 // Static Functions
39 static void Initialize();
40
41 static void Terminate();
42
43 static void DebuggerInitialize(lldb_private::Debugger &debugger);
44
45 static llvm::StringRef GetPluginNameStatic() { return "pdb"; }
46
47 static llvm::StringRef GetPluginDescriptionStatic();
48
50 CreateInstance(lldb::ObjectFileSP objfile_sp);
51
52 // Constructors and Destructors
53 SymbolFilePDB(lldb::ObjectFileSP objfile_sp);
54
55 ~SymbolFilePDB() override;
56
58
59 void InitializeObject() override;
60
61 // Compile Unit function calls
62
64 ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
65
66 size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
67
68 bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override;
69
70 bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override;
71
73 lldb_private::FileSpecList &support_files) override;
74
75 size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override;
76
79 std::vector<lldb_private::SourceModule> &imported_modules) override;
80
81 size_t ParseBlocksRecursive(lldb_private::Function &func) override;
82
83 size_t
85
87 std::optional<ArrayInfo> GetDynamicArrayInfoForUID(
88 lldb::user_id_t type_uid,
89 const lldb_private::ExecutionContext *exe_ctx) override;
90
91 bool CompleteType(lldb_private::CompilerType &compiler_type) override;
92
94
97
100
101 void
103
105 lldb::SymbolContextItem resolve_scope,
106 lldb_private::SymbolContext &sc) override;
107
109 const lldb_private::SourceLocationSpec &src_location_spec,
110 lldb::SymbolContextItem resolve_scope,
111 lldb_private::SymbolContextList &sc_list) override;
112
113 void
115 const lldb_private::CompilerDeclContext &parent_decl_ctx,
116 uint32_t max_matches,
117 lldb_private::VariableList &variables) override;
118
120 uint32_t max_matches,
121 lldb_private::VariableList &variables) override;
122
123 void FindFunctions(const lldb_private::Module::LookupInfo &lookup_info,
124 const lldb_private::CompilerDeclContext &parent_decl_ctx,
125 bool include_inlines,
126 lldb_private::SymbolContextList &sc_list) override;
127
129 bool include_inlines,
130 lldb_private::SymbolContextList &sc_list) override;
131
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
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,
147 llvm::DenseSet<SymbolFile *> &searched_symbol_files,
148 lldb_private::TypeMap &types) override;
149
151 uint32_t max_matches, lldb_private::TypeMap &types);
152
154 lldb::TypeClass type_mask,
155 lldb_private::TypeList &type_list) override;
156
157 llvm::Expected<lldb::TypeSystemSP>
159
162 const lldb_private::CompilerDeclContext &parent_decl_ctx,
163 bool only_root_namespaces) override;
164
165 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
166
167 llvm::pdb::IPDBSession &GetPDBSession();
168
169 const llvm::pdb::IPDBSession &GetPDBSession() const;
170
171 void DumpClangAST(lldb_private::Stream &s) override;
172
173private:
178 };
179 using SecContribsMap = std::map<uint32_t, std::vector<SecContribInfo>>;
180
182
183 lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override;
184
185 lldb::CompUnitSP ParseCompileUnitForUID(uint32_t id,
186 uint32_t index = UINT32_MAX);
187
189 uint32_t match_line);
190
192 const llvm::pdb::PDBSymbolCompiland &pdb_compiland,
193 llvm::DenseMap<uint32_t, uint32_t> &index_map) const;
194
195 void FindTypesByName(llvm::StringRef name,
196 const lldb_private::CompilerDeclContext &parent_decl_ctx,
197 uint32_t max_matches, lldb_private::TypeMap &types);
198
199 std::string GetMangledForPDBData(const llvm::pdb::PDBSymbolData &pdb_data);
200
201 lldb::VariableSP
203 const llvm::pdb::PDBSymbolData &pdb_data);
204
206 const llvm::pdb::PDBSymbol &pdb_data,
207 lldb_private::VariableList *variable_list = nullptr);
208
209 lldb::CompUnitSP
211
212 typedef std::vector<lldb_private::Type *> TypeCollection;
213
214 void GetTypesForPDBSymbol(const llvm::pdb::PDBSymbol &pdb_symbol,
215 uint32_t type_mask,
216 TypeCollection &type_collection);
217
219 ParseCompileUnitFunctionForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func,
220 lldb_private::CompileUnit &comp_unit);
221
222 void GetCompileUnitIndex(const llvm::pdb::PDBSymbolCompiland &pdb_compiland,
223 uint32_t &index);
224
226
227 std::unique_ptr<llvm::pdb::PDBSymbolCompiland>
229
230 lldb_private::Mangled
231 GetMangledForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func);
232
233 bool ResolveFunction(const llvm::pdb::PDBSymbolFunc &pdb_func,
234 bool include_inlines,
236
237 bool ResolveFunction(uint32_t uid, bool include_inlines,
239
240 void CacheFunctionNames();
241
243 const lldb_private::CompilerDeclContext &decl_ctx);
244
245 uint32_t GetCompilandId(const llvm::pdb::PDBSymbolData &data);
246
247 llvm::DenseMap<uint32_t, lldb::CompUnitSP> m_comp_units;
248 llvm::DenseMap<uint32_t, lldb::TypeSP> m_types;
249 llvm::DenseMap<uint32_t, lldb::VariableSP> m_variables;
250 llvm::DenseMap<uint64_t, std::string> m_public_names;
251
253
254 std::vector<lldb::TypeSP> m_builtin_types;
255 std::unique_ptr<llvm::pdb::IPDBSession> m_session_up;
256 std::unique_ptr<llvm::pdb::PDBSymbolExe> m_global_scope_up;
257
261};
262
263#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_SYMBOLFILEPDB_H
void FindTypes(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, llvm::DenseSet< lldb_private::SymbolFile * > &searched_symbol_files, lldb_private::TypeMap &types) override
lldb_private::CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) override
std::unique_ptr< llvm::pdb::PDBSymbolCompiland > GetPDBCompilandByUID(uint32_t uid)
static lldb_private::SymbolFile * CreateInstance(lldb::ObjectFileSP objfile_sp)
std::unique_ptr< llvm::pdb::IPDBSession > m_session_up
lldb::CompUnitSP GetCompileUnitContainsAddress(const lldb_private::Address &so_addr)
void GetMangledNamesForFunction(const std::string &scope_qualified_name, std::vector< lldb_private::ConstString > &mangled_names) override
void GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list) override
void FindFunctions(const lldb_private::Module::LookupInfo &lookup_info, const lldb_private::CompilerDeclContext &parent_decl_ctx, bool include_inlines, lldb_private::SymbolContextList &sc_list) override
lldb_private::CompilerDeclContext FindNamespace(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx, bool only_root_namespaces) override
Finds a namespace of name name and whose parent context is parent_decl_ctx.
std::unique_ptr< llvm::pdb::PDBSymbolExe > m_global_scope_up
llvm::DenseMap< uint32_t, lldb::CompUnitSP > m_comp_units
std::optional< ArrayInfo > GetDynamicArrayInfoForUID(lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) override
If type_uid points to an array type, return its characteristics.
size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override
static llvm::StringRef GetPluginNameStatic()
Definition: SymbolFilePDB.h:45
bool ParseCompileUnitLineTable(lldb_private::CompileUnit &comp_unit, uint32_t match_line)
void BuildSupportFileIdToSupportFileIndexMap(const llvm::pdb::PDBSymbolCompiland &pdb_compiland, llvm::DenseMap< uint32_t, uint32_t > &index_map) const
lldb_private::Function * ParseCompileUnitFunctionForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func, lldb_private::CompileUnit &comp_unit)
static bool classof(const SymbolFile *obj)
Definition: SymbolFilePDB.h:35
void FindTypes(llvm::ArrayRef< lldb_private::CompilerContext > pattern, lldb_private::LanguageSet languages, llvm::DenseSet< SymbolFile * > &searched_symbol_files, lldb_private::TypeMap &types) override
lldb_private::UniqueCStringMap< uint32_t > m_func_base_names
bool ParseImportedModules(const lldb_private::SymbolContext &sc, std::vector< lldb_private::SourceModule > &imported_modules) override
bool isA(const void *ClassID) const override
LLVM RTTI support.
Definition: SymbolFilePDB.h:32
void FindGlobalVariables(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, lldb_private::VariableList &variables) override
size_t ParseVariablesForContext(const lldb_private::SymbolContext &sc) override
static void Initialize()
bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override
std::map< uint32_t, std::vector< SecContribInfo > > SecContribsMap
void GetCompileUnitIndex(const llvm::pdb::PDBSymbolCompiland &pdb_compiland, uint32_t &index)
llvm::DenseMap< uint32_t, lldb::TypeSP > m_types
void AddSymbols(lldb_private::Symtab &symtab) override
size_t ParseBlocksRecursive(lldb_private::Function &func) override
void CacheFunctionNames()
llvm::DenseMap< uint64_t, std::string > m_public_names
size_t ParseVariables(const lldb_private::SymbolContext &sc, const llvm::pdb::PDBSymbol &pdb_data, lldb_private::VariableList *variable_list=nullptr)
lldb::LanguageType ParseLanguage(lldb_private::CompileUnit &comp_unit) override
bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override
void InitializeObject() override
Initialize the SymbolFile object.
uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr, lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) override
PDBASTParser * GetPDBAstParser()
uint32_t CalculateNumCompileUnits() override
~SymbolFilePDB() override
uint32_t ResolveSymbolContext(const lldb_private::SourceLocationSpec &src_location_spec, lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContextList &sc_list) override
uint32_t GetCompilandId(const llvm::pdb::PDBSymbolData &data)
std::vector< lldb::TypeSP > m_builtin_types
llvm::pdb::IPDBSession & GetPDBSession()
static char ID
LLVM RTTI support.
Definition: SymbolFilePDB.h:27
void FindTypesByRegex(const lldb_private::RegularExpression &regex, uint32_t max_matches, lldb_private::TypeMap &types)
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override
lldb::CompUnitSP ParseCompileUnitForUID(uint32_t id, uint32_t index=UINT32_MAX)
lldb_private::Mangled GetMangledForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func)
llvm::StringRef GetPluginName() override
std::vector< lldb_private::Type * > TypeCollection
void ParseDeclsForContext(lldb_private::CompilerDeclContext decl_ctx) override
void DumpClangAST(lldb_private::Stream &s) override
void GetTypesForPDBSymbol(const llvm::pdb::PDBSymbol &pdb_symbol, uint32_t type_mask, TypeCollection &type_collection)
bool CompleteType(lldb_private::CompilerType &compiler_type) override
static void DebuggerInitialize(lldb_private::Debugger &debugger)
bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, lldb_private::FileSpecList &support_files) override
static llvm::StringRef GetPluginDescriptionStatic()
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override
std::string GetMangledForPDBData(const llvm::pdb::PDBSymbolData &pdb_data)
lldb_private::Type * ResolveTypeUID(lldb::user_id_t type_uid) override
lldb_private::UniqueCStringMap< uint32_t > m_func_full_names
static void Terminate()
lldb_private::UniqueCStringMap< uint32_t > m_func_method_names
bool DeclContextMatchesThisSymbolFile(const lldb_private::CompilerDeclContext &decl_ctx)
lldb_private::CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) override
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language) override
SecContribsMap m_sec_contribs
lldb::VariableSP ParseVariableForPDBData(const lldb_private::SymbolContext &sc, const llvm::pdb::PDBSymbolData &pdb_data)
bool ResolveFunction(const llvm::pdb::PDBSymbolFunc &pdb_func, bool include_inlines, lldb_private::SymbolContextList &sc_list)
uint32_t CalculateAbilities() override
llvm::DenseMap< uint32_t, lldb::VariableSP > m_variables
void FindTypesByName(llvm::StringRef name, const lldb_private::CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, lldb_private::TypeMap &types)
lldb_private::CompilerDecl GetDeclForUID(lldb::user_id_t uid) override
A section + offset based address class.
Definition: Address.h:59
A class that describes a compilation unit.
Definition: CompileUnit.h:41
Represents a generic declaration context in a program.
Represents a generic declaration such as a function declaration.
Definition: CompilerDecl.h:28
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
A uniqued constant string class.
Definition: ConstString.h:39
A class to manage flag bits.
Definition: Debugger.h:78
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A file collection class.
Definition: FileSpecList.h:24
A class that describes a function.
Definition: Function.h:409
A class that encapsulates name lookup information.
Definition: Module.h:950
"lldb/Core/SourceLocationSpec.h" A source location specifier class.
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
Defines a list of symbol context objects.
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
Containing protected virtual methods for child classes to override.
Definition: SymbolFile.h:469
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:49
#define UINT32_MAX
Definition: lldb-defines.h:19
LanguageType
Programming language type.
uint64_t user_id_t
Definition: lldb-types.h:80
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
Definition: TypeSystem.h:45