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
51
52 // Constructors and Destructors
54
55 ~SymbolFilePDB() override;
56
57 uint32_t CalculateAbilities() override;
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::SupportFileList &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 void FindTypes(const lldb_private::TypeQuery &match,
138 lldb_private::TypeResults &results) override;
140 uint32_t max_matches, lldb_private::TypeMap &types);
141
143 lldb::TypeClass type_mask,
144 lldb_private::TypeList &type_list) override;
145
146 llvm::Expected<lldb::TypeSystemSP>
148
151 const lldb_private::CompilerDeclContext &parent_decl_ctx,
152 bool only_root_namespaces) override;
153
154 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
155
156 llvm::pdb::IPDBSession &GetPDBSession();
157
158 const llvm::pdb::IPDBSession &GetPDBSession() const;
159
160 void DumpClangAST(lldb_private::Stream &s) override;
161
162private:
164 uint32_t Offset;
165 uint32_t Size;
166 uint32_t CompilandId;
167 };
168 using SecContribsMap = std::map<uint32_t, std::vector<SecContribInfo>>;
169
170 uint32_t CalculateNumCompileUnits() override;
171
172 lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override;
173
175 uint32_t index = UINT32_MAX);
176
178 uint32_t match_line);
179
181 const llvm::pdb::PDBSymbolCompiland &pdb_compiland,
182 llvm::DenseMap<uint32_t, uint32_t> &index_map) const;
183
184 void FindTypesByName(llvm::StringRef name,
185 const lldb_private::CompilerDeclContext &parent_decl_ctx,
186 uint32_t max_matches, lldb_private::TypeMap &types);
187
188 std::string GetMangledForPDBData(const llvm::pdb::PDBSymbolData &pdb_data);
189
192 const llvm::pdb::PDBSymbolData &pdb_data);
193
195 const llvm::pdb::PDBSymbol &pdb_data,
196 lldb_private::VariableList *variable_list = nullptr);
197
200
201 typedef std::vector<lldb_private::Type *> TypeCollection;
202
203 void GetTypesForPDBSymbol(const llvm::pdb::PDBSymbol &pdb_symbol,
204 uint32_t type_mask,
205 TypeCollection &type_collection);
206
208 ParseCompileUnitFunctionForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func,
209 lldb_private::CompileUnit &comp_unit);
210
211 void GetCompileUnitIndex(const llvm::pdb::PDBSymbolCompiland &pdb_compiland,
212 uint32_t &index);
213
215
216 std::unique_ptr<llvm::pdb::PDBSymbolCompiland>
217 GetPDBCompilandByUID(uint32_t uid);
218
220 GetMangledForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func);
221
222 bool ResolveFunction(const llvm::pdb::PDBSymbolFunc &pdb_func,
223 bool include_inlines,
225
226 bool ResolveFunction(uint32_t uid, bool include_inlines,
228
229 void CacheFunctionNames();
230
232 const lldb_private::CompilerDeclContext &decl_ctx);
233
234 uint32_t GetCompilandId(const llvm::pdb::PDBSymbolData &data);
235
236 llvm::DenseMap<uint32_t, lldb::CompUnitSP> m_comp_units;
237 llvm::DenseMap<uint32_t, lldb::TypeSP> m_types;
238 llvm::DenseMap<uint32_t, lldb::VariableSP> m_variables;
239 llvm::DenseMap<uint64_t, std::string> m_public_names;
240
242
243 std::vector<lldb::TypeSP> m_builtin_types;
244 std::unique_ptr<llvm::pdb::IPDBSession> m_session_up;
245 std::unique_ptr<llvm::pdb::PDBSymbolExe> m_global_scope_up;
246
250};
251
252#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_SYMBOLFILEPDB_H
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
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()
bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, lldb_private::SupportFileList &support_files) override
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)
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
void FindTypes(const lldb_private::TypeQuery &match, lldb_private::TypeResults &results) override
Find types using a type-matching object that contains all search parameters.
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:62
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:40
A class to manage flag bits.
Definition: Debugger.h:80
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A class that describes a function.
Definition: Function.h:399
A class that handles mangled names.
Definition: Mangled.h:33
A class that encapsulates name lookup information.
Definition: Module.h:904
"lldb/Core/SourceLocationSpec.h" A source location specifier class.
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
A list of support files for a CompileUnit.
Definition: FileSpecList.h:23
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:34
Containing protected virtual methods for child classes to override.
Definition: SymbolFile.h:496
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:50
A class that contains all state required for type lookups.
Definition: Type.h:100
This class tracks the state and results of a TypeQuery.
Definition: Type.h:308
#define UINT32_MAX
Definition: lldb-defines.h:19
std::shared_ptr< lldb_private::ObjectFile > ObjectFileSP
Definition: lldb-forward.h:371
LanguageType
Programming language type.
std::shared_ptr< lldb_private::Variable > VariableSP
Definition: lldb-forward.h:480
uint64_t user_id_t
Definition: lldb-types.h:82
std::shared_ptr< lldb_private::CompileUnit > CompUnitSP
Definition: lldb-forward.h:331