1//===- NativeSession.h - Native implementation of IPDBSession ---*- 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 LLVM_DEBUGINFO_PDB_NATIVE_NATIVESESSION_H 10#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVESESSION_H 11 12#include "llvm/ADT/DenseMap.h" 13#include "llvm/ADT/StringRef.h" 14#include "llvm/DebugInfo/CodeView/TypeIndex.h" 15#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" 16#include "llvm/DebugInfo/PDB/IPDBSession.h" 17#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" 18#include "llvm/DebugInfo/PDB/Native/SymbolCache.h" 19#include "llvm/Support/Allocator.h" 20#include "llvm/Support/Error.h" 21 22namespace llvm { 23class MemoryBuffer; 24namespace pdb { 25class PDBFile; 26class NativeExeSymbol; 27 28class NativeSession : public IPDBSession { 29public: 30 NativeSession(std::unique_ptr<PDBFile> PdbFile, 31 std::unique_ptr<BumpPtrAllocator> Allocator); 32 ~NativeSession() override; 33 34 static Error createFromPdb(std::unique_ptr<MemoryBuffer> MB, 35 std::unique_ptr<IPDBSession> &Session); 36 static Error createFromExe(StringRef Path, 37 std::unique_ptr<IPDBSession> &Session); 38 39 uint64_t getLoadAddress() const override; 40 bool setLoadAddress(uint64_t Address) override; 41 std::unique_ptr<PDBSymbolExe> getGlobalScope() override; 42 std::unique_ptr<PDBSymbol> getSymbolById(SymIndexId SymbolId) const override; 43 44 bool addressForVA(uint64_t VA, uint32_t &Section, 45 uint32_t &Offset) const override; 46 bool addressForRVA(uint32_t RVA, uint32_t &Section, 47 uint32_t &Offset) const override; 48 49 std::unique_ptr<PDBSymbol> 50 findSymbolByAddress(uint64_t Address, PDB_SymType Type) const override; 51 std::unique_ptr<PDBSymbol> findSymbolByRVA(uint32_t RVA, 52 PDB_SymType Type) const override; 53 std::unique_ptr<PDBSymbol> 54 findSymbolBySectOffset(uint32_t Sect, uint32_t Offset, 55 PDB_SymType Type) const override; 56 57 std::unique_ptr<IPDBEnumLineNumbers> 58 findLineNumbers(const PDBSymbolCompiland &Compiland, 59 const IPDBSourceFile &File) const override; 60 std::unique_ptr<IPDBEnumLineNumbers> 61 findLineNumbersByAddress(uint64_t Address, uint32_t Length) const override; 62 std::unique_ptr<IPDBEnumLineNumbers> 63 findLineNumbersByRVA(uint32_t RVA, uint32_t Length) const override; 64 std::unique_ptr<IPDBEnumLineNumbers> 65 findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, 66 uint32_t Length) const override; 67 68 std::unique_ptr<IPDBEnumSourceFiles> 69 findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern, 70 PDB_NameSearchFlags Flags) const override; 71 std::unique_ptr<IPDBSourceFile> 72 findOneSourceFile(const PDBSymbolCompiland *Compiland, 73 llvm::StringRef Pattern, 74 PDB_NameSearchFlags Flags) const override; 75 std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>> 76 findCompilandsForSourceFile(llvm::StringRef Pattern, 77 PDB_NameSearchFlags Flags) const override; 78 std::unique_ptr<PDBSymbolCompiland> 79 findOneCompilandForSourceFile(llvm::StringRef Pattern, 80 PDB_NameSearchFlags Flags) const override; 81 std::unique_ptr<IPDBEnumSourceFiles> getAllSourceFiles() const override; 82 std::unique_ptr<IPDBEnumSourceFiles> getSourceFilesForCompiland( 83 const PDBSymbolCompiland &Compiland) const override; 84 std::unique_ptr<IPDBSourceFile> 85 getSourceFileById(uint32_t FileId) const override; 86 87 std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override; 88 89 std::unique_ptr<IPDBEnumTables> getEnumTables() const override; 90 91 std::unique_ptr<IPDBEnumInjectedSources> getInjectedSources() const override; 92 93 std::unique_ptr<IPDBEnumSectionContribs> getSectionContribs() const override; 94 95 std::unique_ptr<IPDBEnumFrameData> getFrameData() const override; 96 97 PDBFile &getPDBFile() { return *Pdb; } 98 const PDBFile &getPDBFile() const { return *Pdb; } 99 100 NativeExeSymbol &getNativeGlobalScope() const; 101 SymbolCache &getSymbolCache() { return Cache; } 102 const SymbolCache &getSymbolCache() const { return Cache; } 103 104private: 105 void initializeExeSymbol(); 106 107 std::unique_ptr<PDBFile> Pdb; 108 std::unique_ptr<BumpPtrAllocator> Allocator; 109 110 SymbolCache Cache; 111 SymIndexId ExeSymbol = 0; 112}; 113} // namespace pdb 114} // namespace llvm 115 116#endif 117