Path: blob/main/contrib/llvm-project/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
39642 views
//===-- SymbolFilePDB.h -------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_SYMBOLFILEPDB_H9#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_SYMBOLFILEPDB_H1011#include "lldb/Core/UniqueCStringMap.h"12#include "lldb/Symbol/SymbolFile.h"13#include "lldb/Symbol/VariableList.h"14#include "lldb/Utility/UserID.h"1516#include "llvm/ADT/DenseMap.h"17#include "llvm/DebugInfo/PDB/IPDBSession.h"18#include "llvm/DebugInfo/PDB/PDB.h"19#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"20#include <optional>2122class PDBASTParser;2324class SymbolFilePDB : public lldb_private::SymbolFileCommon {25/// LLVM RTTI support.26static char ID;2728public:29/// LLVM RTTI support.30/// \{31bool isA(const void *ClassID) const override {32return ClassID == &ID || SymbolFileCommon::isA(ClassID);33}34static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }35/// \}3637// Static Functions38static void Initialize();3940static void Terminate();4142static void DebuggerInitialize(lldb_private::Debugger &debugger);4344static llvm::StringRef GetPluginNameStatic() { return "pdb"; }4546static llvm::StringRef GetPluginDescriptionStatic();4748static lldb_private::SymbolFile *49CreateInstance(lldb::ObjectFileSP objfile_sp);5051// Constructors and Destructors52SymbolFilePDB(lldb::ObjectFileSP objfile_sp);5354~SymbolFilePDB() override;5556uint32_t CalculateAbilities() override;5758void InitializeObject() override;5960// Compile Unit function calls6162lldb::LanguageType63ParseLanguage(lldb_private::CompileUnit &comp_unit) override;6465size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;6667bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override;6869bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override;7071bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit,72lldb_private::SupportFileList &support_files) override;7374size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override;7576bool ParseImportedModules(77const lldb_private::SymbolContext &sc,78std::vector<lldb_private::SourceModule> &imported_modules) override;7980size_t ParseBlocksRecursive(lldb_private::Function &func) override;8182size_t83ParseVariablesForContext(const lldb_private::SymbolContext &sc) override;8485lldb_private::Type *ResolveTypeUID(lldb::user_id_t type_uid) override;86std::optional<ArrayInfo> GetDynamicArrayInfoForUID(87lldb::user_id_t type_uid,88const lldb_private::ExecutionContext *exe_ctx) override;8990bool CompleteType(lldb_private::CompilerType &compiler_type) override;9192lldb_private::CompilerDecl GetDeclForUID(lldb::user_id_t uid) override;9394lldb_private::CompilerDeclContext95GetDeclContextForUID(lldb::user_id_t uid) override;9697lldb_private::CompilerDeclContext98GetDeclContextContainingUID(lldb::user_id_t uid) override;99100void101ParseDeclsForContext(lldb_private::CompilerDeclContext decl_ctx) override;102103uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr,104lldb::SymbolContextItem resolve_scope,105lldb_private::SymbolContext &sc) override;106107uint32_t ResolveSymbolContext(108const lldb_private::SourceLocationSpec &src_location_spec,109lldb::SymbolContextItem resolve_scope,110lldb_private::SymbolContextList &sc_list) override;111112void113FindGlobalVariables(lldb_private::ConstString name,114const lldb_private::CompilerDeclContext &parent_decl_ctx,115uint32_t max_matches,116lldb_private::VariableList &variables) override;117118void FindGlobalVariables(const lldb_private::RegularExpression ®ex,119uint32_t max_matches,120lldb_private::VariableList &variables) override;121122void FindFunctions(const lldb_private::Module::LookupInfo &lookup_info,123const lldb_private::CompilerDeclContext &parent_decl_ctx,124bool include_inlines,125lldb_private::SymbolContextList &sc_list) override;126127void FindFunctions(const lldb_private::RegularExpression ®ex,128bool include_inlines,129lldb_private::SymbolContextList &sc_list) override;130131void GetMangledNamesForFunction(132const std::string &scope_qualified_name,133std::vector<lldb_private::ConstString> &mangled_names) override;134135void AddSymbols(lldb_private::Symtab &symtab) override;136void FindTypes(const lldb_private::TypeQuery &match,137lldb_private::TypeResults &results) override;138void FindTypesByRegex(const lldb_private::RegularExpression ®ex,139uint32_t max_matches, lldb_private::TypeMap &types);140141void GetTypes(lldb_private::SymbolContextScope *sc_scope,142lldb::TypeClass type_mask,143lldb_private::TypeList &type_list) override;144145llvm::Expected<lldb::TypeSystemSP>146GetTypeSystemForLanguage(lldb::LanguageType language) override;147148lldb_private::CompilerDeclContext149FindNamespace(lldb_private::ConstString name,150const lldb_private::CompilerDeclContext &parent_decl_ctx,151bool only_root_namespaces) override;152153llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }154155llvm::pdb::IPDBSession &GetPDBSession();156157const llvm::pdb::IPDBSession &GetPDBSession() const;158159void DumpClangAST(lldb_private::Stream &s) override;160161private:162struct SecContribInfo {163uint32_t Offset;164uint32_t Size;165uint32_t CompilandId;166};167using SecContribsMap = std::map<uint32_t, std::vector<SecContribInfo>>;168169uint32_t CalculateNumCompileUnits() override;170171lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override;172173lldb::CompUnitSP ParseCompileUnitForUID(uint32_t id,174uint32_t index = UINT32_MAX);175176bool ParseCompileUnitLineTable(lldb_private::CompileUnit &comp_unit,177uint32_t match_line);178179void BuildSupportFileIdToSupportFileIndexMap(180const llvm::pdb::PDBSymbolCompiland &pdb_compiland,181llvm::DenseMap<uint32_t, uint32_t> &index_map) const;182183void FindTypesByName(llvm::StringRef name,184const lldb_private::CompilerDeclContext &parent_decl_ctx,185uint32_t max_matches, lldb_private::TypeMap &types);186187std::string GetMangledForPDBData(const llvm::pdb::PDBSymbolData &pdb_data);188189lldb::VariableSP190ParseVariableForPDBData(const lldb_private::SymbolContext &sc,191const llvm::pdb::PDBSymbolData &pdb_data);192193size_t ParseVariables(const lldb_private::SymbolContext &sc,194const llvm::pdb::PDBSymbol &pdb_data,195lldb_private::VariableList *variable_list = nullptr);196197lldb::CompUnitSP198GetCompileUnitContainsAddress(const lldb_private::Address &so_addr);199200typedef std::vector<lldb_private::Type *> TypeCollection;201202void GetTypesForPDBSymbol(const llvm::pdb::PDBSymbol &pdb_symbol,203uint32_t type_mask,204TypeCollection &type_collection);205206lldb_private::Function *207ParseCompileUnitFunctionForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func,208lldb_private::CompileUnit &comp_unit);209210void GetCompileUnitIndex(const llvm::pdb::PDBSymbolCompiland &pdb_compiland,211uint32_t &index);212213PDBASTParser *GetPDBAstParser();214215std::unique_ptr<llvm::pdb::PDBSymbolCompiland>216GetPDBCompilandByUID(uint32_t uid);217218lldb_private::Mangled219GetMangledForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func);220221bool ResolveFunction(const llvm::pdb::PDBSymbolFunc &pdb_func,222bool include_inlines,223lldb_private::SymbolContextList &sc_list);224225bool ResolveFunction(uint32_t uid, bool include_inlines,226lldb_private::SymbolContextList &sc_list);227228void CacheFunctionNames();229230bool DeclContextMatchesThisSymbolFile(231const lldb_private::CompilerDeclContext &decl_ctx);232233uint32_t GetCompilandId(const llvm::pdb::PDBSymbolData &data);234235llvm::DenseMap<uint32_t, lldb::CompUnitSP> m_comp_units;236llvm::DenseMap<uint32_t, lldb::TypeSP> m_types;237llvm::DenseMap<uint32_t, lldb::VariableSP> m_variables;238llvm::DenseMap<uint64_t, std::string> m_public_names;239240SecContribsMap m_sec_contribs;241242std::vector<lldb::TypeSP> m_builtin_types;243std::unique_ptr<llvm::pdb::IPDBSession> m_session_up;244std::unique_ptr<llvm::pdb::PDBSymbolExe> m_global_scope_up;245246lldb_private::UniqueCStringMap<uint32_t> m_func_full_names;247lldb_private::UniqueCStringMap<uint32_t> m_func_base_names;248lldb_private::UniqueCStringMap<uint32_t> m_func_method_names;249};250251#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_SYMBOLFILEPDB_H252253254