1 //===- TpiStream.cpp - PDB Type Info (TPI) Stream 2 Access ------*- 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_TPISTREAM_H 10 #define LLVM_DEBUGINFO_PDB_NATIVE_TPISTREAM_H 11 12 #include "llvm/DebugInfo/CodeView/CVRecord.h" 13 #include "llvm/DebugInfo/PDB/Native/HashTable.h" 14 #include "llvm/DebugInfo/PDB/Native/RawConstants.h" 15 #include "llvm/Support/BinaryStreamArray.h" 16 #include "llvm/Support/BinaryStreamRef.h" 17 #include "llvm/Support/Compiler.h" 18 19 #include "llvm/Support/Error.h" 20 21 namespace llvm { 22 class BinaryStream; 23 namespace codeview { 24 class TypeIndex; 25 struct TypeIndexOffset; 26 class LazyRandomTypeCollection; 27 } 28 namespace msf { 29 class MappedBlockStream; 30 } 31 namespace pdb { 32 struct TpiStreamHeader; 33 class PDBFile; 34 35 class TpiStream { 36 friend class TpiStreamBuilder; 37 38 public: 39 LLVM_ABI TpiStream(PDBFile &File, 40 std::unique_ptr<msf::MappedBlockStream> Stream); 41 LLVM_ABI ~TpiStream(); 42 LLVM_ABI Error reload(); 43 44 LLVM_ABI PdbRaw_TpiVer getTpiVersion() const; 45 46 LLVM_ABI uint32_t TypeIndexBegin() const; 47 LLVM_ABI uint32_t TypeIndexEnd() const; 48 LLVM_ABI uint32_t getNumTypeRecords() const; 49 LLVM_ABI uint16_t getTypeHashStreamIndex() const; 50 LLVM_ABI uint16_t getTypeHashStreamAuxIndex() const; 51 52 LLVM_ABI uint32_t getHashKeySize() const; 53 LLVM_ABI uint32_t getNumHashBuckets() const; 54 LLVM_ABI FixedStreamArray<support::ulittle32_t> getHashValues() const; 55 LLVM_ABI FixedStreamArray<codeview::TypeIndexOffset> 56 getTypeIndexOffsets() const; 57 LLVM_ABI HashTable<support::ulittle32_t> &getHashAdjusters(); 58 59 LLVM_ABI codeview::CVTypeRange types(bool *HadError) const; typeArray()60 const codeview::CVTypeArray &typeArray() const { return TypeRecords; } 61 typeCollection()62 codeview::LazyRandomTypeCollection &typeCollection() { return *Types; } 63 64 LLVM_ABI Expected<codeview::TypeIndex> 65 findFullDeclForForwardRef(codeview::TypeIndex ForwardRefTI) const; 66 67 LLVM_ABI std::vector<codeview::TypeIndex> 68 findRecordsByName(StringRef Name) const; 69 70 LLVM_ABI codeview::CVType getType(codeview::TypeIndex Index); 71 72 LLVM_ABI BinarySubstreamRef getTypeRecordsSubstream() const; 73 74 LLVM_ABI Error commit(); 75 76 LLVM_ABI void buildHashMap(); 77 78 LLVM_ABI bool supportsTypeLookup() const; 79 80 private: 81 PDBFile &Pdb; 82 std::unique_ptr<msf::MappedBlockStream> Stream; 83 84 std::unique_ptr<codeview::LazyRandomTypeCollection> Types; 85 86 BinarySubstreamRef TypeRecordsSubstream; 87 88 codeview::CVTypeArray TypeRecords; 89 90 std::unique_ptr<BinaryStream> HashStream; 91 FixedStreamArray<support::ulittle32_t> HashValues; 92 FixedStreamArray<codeview::TypeIndexOffset> TypeIndexOffsets; 93 HashTable<support::ulittle32_t> HashAdjusters; 94 95 std::vector<std::vector<codeview::TypeIndex>> HashMap; 96 97 const TpiStreamHeader *Header; 98 }; 99 } 100 } 101 102 #endif 103