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