diff options
Diffstat (limited to 'include/llvm/DebugInfo/PDB/Native')
-rw-r--r-- | include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h | 11 | ||||
-rw-r--r-- | include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h | 82 | ||||
-rw-r--r-- | include/llvm/DebugInfo/PDB/Native/GlobalsStream.h | 57 | ||||
-rw-r--r-- | include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h | 4 | ||||
-rw-r--r-- | include/llvm/DebugInfo/PDB/Native/NativeEnumSymbol.h | 60 | ||||
-rw-r--r-- | include/llvm/DebugInfo/PDB/Native/NativeEnumTypes.h | 51 | ||||
-rw-r--r-- | include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h | 1 | ||||
-rw-r--r-- | include/llvm/DebugInfo/PDB/Native/NativeSession.h | 11 | ||||
-rw-r--r-- | include/llvm/DebugInfo/PDB/Native/PDBFile.h | 10 | ||||
-rw-r--r-- | include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h | 8 | ||||
-rw-r--r-- | include/llvm/DebugInfo/PDB/Native/PublicsStream.h | 24 | ||||
-rw-r--r-- | include/llvm/DebugInfo/PDB/Native/PublicsStreamBuilder.h | 54 | ||||
-rw-r--r-- | include/llvm/DebugInfo/PDB/Native/RawTypes.h | 14 | ||||
-rw-r--r-- | include/llvm/DebugInfo/PDB/Native/SymbolStream.h | 2 |
14 files changed, 294 insertions, 95 deletions
diff --git a/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h b/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h index 63eb34f0326af..ad4a0d1bcb6bf 100644 --- a/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h +++ b/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h @@ -59,11 +59,11 @@ public: uint32_t calculateSerializedLength() const; + void setGlobalsStreamIndex(uint32_t Index); void setPublicsStreamIndex(uint32_t Index); void setSymbolRecordStreamIndex(uint32_t Index); Expected<DbiModuleDescriptorBuilder &> addModuleInfo(StringRef ModuleName); - Error addModuleSourceFile(StringRef Module, StringRef File); Error addModuleSourceFile(DbiModuleDescriptorBuilder &Module, StringRef File); Expected<uint32_t> getSourceFileNameIndex(StringRef FileName); @@ -71,8 +71,9 @@ public: Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef MsfBuffer); - void addSectionContrib(DbiModuleDescriptorBuilder *ModuleDbi, - const llvm::object::coff_section *SecHdr); + void addSectionContrib(const SectionContrib &SC) { + SectionContribs.emplace_back(SC); + } // A helper function to create a Section Map from a COFF section header. static std::vector<SecMapEntry> @@ -105,13 +106,13 @@ private: uint16_t PdbDllRbld; uint16_t Flags; PDB_Machine MachineType; + uint32_t GlobalsStreamIndex = kInvalidStreamIndex; uint32_t PublicsStreamIndex = kInvalidStreamIndex; uint32_t SymRecordStreamIndex = kInvalidStreamIndex; const DbiStreamHeader *Header; - StringMap<std::unique_ptr<DbiModuleDescriptorBuilder>> ModiMap; - std::vector<DbiModuleDescriptorBuilder *> ModiList; + std::vector<std::unique_ptr<DbiModuleDescriptorBuilder>> ModiList; StringMap<uint32_t> SourceFileNames; diff --git a/include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h b/include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h new file mode 100644 index 0000000000000..1a4f89d607dff --- /dev/null +++ b/include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h @@ -0,0 +1,82 @@ +//===- GSIStreamBuilder.h - PDB Publics/Globals Stream Creation -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H +#define LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H + +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h" +#include "llvm/DebugInfo/PDB/Native/RawConstants.h" +#include "llvm/DebugInfo/PDB/Native/RawTypes.h" +#include "llvm/Support/BinaryByteStream.h" +#include "llvm/Support/BinaryItemStream.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/BinaryStreamWriter.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" + +namespace llvm { + +template <> struct BinaryItemTraits<codeview::CVSymbol> { + static size_t length(const codeview::CVSymbol &Item) { + return Item.RecordData.size(); + } + static ArrayRef<uint8_t> bytes(const codeview::CVSymbol &Item) { + return Item.RecordData; + } +}; + +namespace msf { +class MSFBuilder; +struct MSFLayout; +} // namespace msf +namespace pdb { +struct GSIHashStreamBuilder; + +class GSIStreamBuilder { + +public: + explicit GSIStreamBuilder(msf::MSFBuilder &Msf); + ~GSIStreamBuilder(); + + GSIStreamBuilder(const GSIStreamBuilder &) = delete; + GSIStreamBuilder &operator=(const GSIStreamBuilder &) = delete; + + Error finalizeMsfLayout(); + + Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer); + + uint32_t getPublicsStreamIndex() const; + uint32_t getGlobalsStreamIndex() const; + uint32_t getRecordStreamIdx() const { return RecordStreamIdx; } + + void addPublicSymbol(const codeview::PublicSym32 &Pub); + + void addGlobalSymbol(const codeview::ProcRefSym &Sym); + void addGlobalSymbol(const codeview::DataSym &Sym); + void addGlobalSymbol(const codeview::ConstantSym &Sym); + void addGlobalSymbol(const codeview::UDTSym &Sym); + void addGlobalSymbol(const codeview::CVSymbol &Sym); + +private: + uint32_t calculatePublicsHashStreamSize() const; + uint32_t calculateGlobalsHashStreamSize() const; + Error commitSymbolRecordStream(WritableBinaryStreamRef Stream); + Error commitPublicsHashStream(WritableBinaryStreamRef Stream); + Error commitGlobalsHashStream(WritableBinaryStreamRef Stream); + + uint32_t RecordStreamIdx = kInvalidStreamIndex; + msf::MSFBuilder &Msf; + std::unique_ptr<GSIHashStreamBuilder> PSH; + std::unique_ptr<GSIHashStreamBuilder> GSH; +}; +} // namespace pdb +} // namespace llvm + +#endif diff --git a/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h b/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h index dcea3d3be0ab8..fdc58dc60f7e0 100644 --- a/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h +++ b/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h @@ -1,4 +1,4 @@ -//===- GlobalsStream.h - PDB Index of Symbols by Name ------ ----*- C++ -*-===// +//===- GlobalsStream.h - PDB Index of Symbols by Name -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -16,27 +16,66 @@ #include "llvm/DebugInfo/PDB/PDBTypes.h" #include "llvm/Support/BinaryStreamArray.h" #include "llvm/Support/Error.h" +#include "llvm/ADT/iterator.h" namespace llvm { namespace pdb { class DbiStream; class PDBFile; +/// Iterator over hash records producing symbol record offsets. Abstracts away +/// the fact that symbol record offsets on disk are off-by-one. +class GSIHashIterator + : public iterator_adaptor_base< + GSIHashIterator, FixedStreamArrayIterator<PSHashRecord>, + std::random_access_iterator_tag, const uint32_t> { +public: + GSIHashIterator() = default; + + template <typename T> + GSIHashIterator(T &&v) + : GSIHashIterator::iterator_adaptor_base(std::forward<T &&>(v)) {} + + uint32_t operator*() const { + uint32_t Off = this->I->Off; + return --Off; + } +}; + +/// From https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.cpp +enum : unsigned { IPHR_HASH = 4096 }; + +/// A readonly view of a hash table used in the globals and publics streams. +/// Most clients will only want to iterate this to get symbol record offsets +/// into the PDB symbol stream. +class GSIHashTable { +public: + const GSIHashHeader *HashHdr; + FixedStreamArray<PSHashRecord> HashRecords; + ArrayRef<uint8_t> HashBitmap; + FixedStreamArray<support::ulittle32_t> HashBuckets; + + Error read(BinaryStreamReader &Reader); + + uint32_t getVerSignature() const { return HashHdr->VerSignature; } + uint32_t getVerHeader() const { return HashHdr->VerHdr; } + uint32_t getHashRecordSize() const { return HashHdr->HrSize; } + uint32_t getNumBuckets() const { return HashHdr->NumBuckets; } + + typedef GSIHashHeader iterator; + GSIHashIterator begin() const { return GSIHashIterator(HashRecords.begin()); } + GSIHashIterator end() const { return GSIHashIterator(HashRecords.end()); } +}; + class GlobalsStream { public: explicit GlobalsStream(std::unique_ptr<msf::MappedBlockStream> Stream); ~GlobalsStream(); - Error commit(); - FixedStreamArray<support::ulittle32_t> getHashBuckets() const { - return HashBuckets; - } - uint32_t getNumBuckets() const { return NumBuckets; } + const GSIHashTable &getGlobalsTable() const { return GlobalsTable; } Error reload(); private: - FixedStreamArray<support::ulittle32_t> HashBuckets; - FixedStreamArray<PSHashRecord> HashRecords; - uint32_t NumBuckets; + GSIHashTable GlobalsTable; std::unique_ptr<msf::MappedBlockStream> Stream; }; } diff --git a/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h b/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h index f413fd1b336ec..6602264d1b747 100644 --- a/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h +++ b/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h @@ -32,6 +32,7 @@ public: ModuleDebugStreamRef(const DbiModuleDescriptor &Module, std::unique_ptr<msf::MappedBlockStream> Stream); ModuleDebugStreamRef(ModuleDebugStreamRef &&Other) = default; + ModuleDebugStreamRef(const ModuleDebugStreamRef &Other) = default; ~ModuleDebugStreamRef(); Error reload(); @@ -51,6 +52,9 @@ public: ModuleDebugStreamRef &operator=(ModuleDebugStreamRef &&Other) = default; iterator_range<DebugSubsectionIterator> subsections() const; + codeview::DebugSubsectionArray getSubsectionsArray() const { + return Subsections; + } bool hasDebugSubsections() const; diff --git a/include/llvm/DebugInfo/PDB/Native/NativeEnumSymbol.h b/include/llvm/DebugInfo/PDB/Native/NativeEnumSymbol.h new file mode 100644 index 0000000000000..41b7b78b8d80a --- /dev/null +++ b/include/llvm/DebugInfo/PDB/Native/NativeEnumSymbol.h @@ -0,0 +1,60 @@ +//===- NativeEnumSymbol.h - info about enum type ----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMSYMBOL_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMSYMBOL_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" +#include "llvm/DebugInfo/PDB/Native/NativeSession.h" + +namespace llvm { +namespace pdb { + +class NativeEnumSymbol : public NativeRawSymbol, + public codeview::TypeVisitorCallbacks { +public: + NativeEnumSymbol(NativeSession &Session, SymIndexId Id, + const codeview::CVType &CV); + ~NativeEnumSymbol() override; + + std::unique_ptr<NativeRawSymbol> clone() const override; + + std::unique_ptr<IPDBEnumSymbols> + findChildren(PDB_SymType Type) const override; + + Error visitKnownRecord(codeview::CVType &CVR, + codeview::EnumRecord &Record) override; + Error visitKnownMember(codeview::CVMemberRecord &CVM, + codeview::EnumeratorRecord &Record) override; + + PDB_SymType getSymTag() const override; + uint32_t getClassParentId() const override; + uint32_t getUnmodifiedTypeId() const override; + bool hasConstructor() const override; + bool hasAssignmentOperator() const override; + bool hasCastOperator() const override; + uint64_t getLength() const override; + std::string getName() const override; + bool isNested() const override; + bool hasOverloadedOperator() const override; + bool isPacked() const override; + bool isScoped() const override; + uint32_t getTypeId() const override; + +protected: + codeview::CVType CV; + codeview::EnumRecord Record; +}; + +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMSYMBOL_H diff --git a/include/llvm/DebugInfo/PDB/Native/NativeEnumTypes.h b/include/llvm/DebugInfo/PDB/Native/NativeEnumTypes.h new file mode 100644 index 0000000000000..e0a5c8d9ad814 --- /dev/null +++ b/include/llvm/DebugInfo/PDB/Native/NativeEnumTypes.h @@ -0,0 +1,51 @@ +//==- NativeEnumTypes.h - Native Type Enumerator impl ------------*- C++ -*-==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMTYPES_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMTYPES_H + +#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/PDBSymbol.h" + +#include <vector> + +namespace llvm { +namespace pdb { + +class NativeSession; + +class NativeEnumTypes : public IPDBEnumChildren<PDBSymbol> { +public: + NativeEnumTypes(NativeSession &Session, + codeview::LazyRandomTypeCollection &TypeCollection, + codeview::TypeLeafKind Kind); + + uint32_t getChildCount() const override; + std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override; + std::unique_ptr<PDBSymbol> getNext() override; + void reset() override; + NativeEnumTypes *clone() const override; + +private: + NativeEnumTypes(NativeSession &Session, + const std::vector<codeview::TypeIndex> &Matches, + codeview::TypeLeafKind Kind); + + std::vector<codeview::TypeIndex> Matches; + uint32_t Index; + NativeSession &Session; + codeview::TypeLeafKind Kind; +}; + +} // namespace pdb +} // namespace llvm + +#endif diff --git a/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h b/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h index 2c6548dcce21f..931b93fb7266c 100644 --- a/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h +++ b/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h @@ -101,6 +101,7 @@ public: uint32_t getTypeId() const override; uint32_t getUavSlot() const override; std::string getUndecoratedName() const override; + std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const override; uint32_t getUnmodifiedTypeId() const override; uint32_t getUpperBoundId() const override; Variant getValue() const override; diff --git a/include/llvm/DebugInfo/PDB/Native/NativeSession.h b/include/llvm/DebugInfo/PDB/Native/NativeSession.h index b16ce231c349c..2e68ced46bfe8 100644 --- a/include/llvm/DebugInfo/PDB/Native/NativeSession.h +++ b/include/llvm/DebugInfo/PDB/Native/NativeSession.h @@ -22,6 +22,7 @@ #include "llvm/Support/Error.h" namespace llvm { +class MemoryBuffer; namespace pdb { class PDBFile; @@ -31,7 +32,7 @@ public: std::unique_ptr<BumpPtrAllocator> Allocator); ~NativeSession() override; - static Error createFromPdb(StringRef Path, + static Error createFromPdb(std::unique_ptr<MemoryBuffer> MB, std::unique_ptr<IPDBSession> &Session); static Error createFromExe(StringRef Path, std::unique_ptr<IPDBSession> &Session); @@ -39,6 +40,12 @@ public: std::unique_ptr<PDBSymbolCompiland> createCompilandSymbol(DbiModuleDescriptor MI); + std::unique_ptr<PDBSymbolTypeEnum> + createEnumSymbol(codeview::TypeIndex Index); + + std::unique_ptr<IPDBEnumSymbols> + createTypeEnumerator(codeview::TypeLeafKind Kind); + SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI); uint64_t getLoadAddress() const override; @@ -76,6 +83,8 @@ public: std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override; + std::unique_ptr<IPDBEnumTables> getEnumTables() const override; + PDBFile &getPDBFile() { return *Pdb; } const PDBFile &getPDBFile() const { return *Pdb; } diff --git a/include/llvm/DebugInfo/PDB/Native/PDBFile.h b/include/llvm/DebugInfo/PDB/Native/PDBFile.h index 4f6ad115e7dfd..5e39ac3e37b72 100644 --- a/include/llvm/DebugInfo/PDB/Native/PDBFile.h +++ b/include/llvm/DebugInfo/PDB/Native/PDBFile.h @@ -13,7 +13,6 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/DebugInfo/MSF/IMSFFile.h" #include "llvm/DebugInfo/MSF/MSFCommon.h" -#include "llvm/DebugInfo/MSF/MSFStreamLayout.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/BinaryStreamRef.h" #include "llvm/Support/Endian.h" @@ -62,6 +61,7 @@ public: uint64_t getBlockMapOffset() const; uint32_t getNumStreams() const override; + uint32_t getMaxStreamSize() const; uint32_t getStreamByteSize(uint32_t StreamIndex) const override; ArrayRef<support::ulittle32_t> getStreamBlockList(uint32_t StreamIndex) const override; @@ -72,8 +72,6 @@ public: Error setBlockData(uint32_t BlockIndex, uint32_t Offset, ArrayRef<uint8_t> Data) const override; - ArrayRef<uint32_t> getFpmPages() const { return FpmPages; } - ArrayRef<support::ulittle32_t> getStreamSizes() const { return ContainerLayout.StreamSizes; } @@ -86,7 +84,10 @@ public: ArrayRef<support::ulittle32_t> getDirectoryBlockArray() const; + std::unique_ptr<msf::MappedBlockStream> createIndexedStream(uint16_t SN); + msf::MSFStreamLayout getStreamLayout(uint32_t StreamIdx) const; + msf::MSFStreamLayout getFpmStreamLayout() const; Error parseFileHeaders(); Error parseStreamData(); @@ -104,7 +105,7 @@ public: bool hasPDBDbiStream() const; bool hasPDBGlobalsStream(); - bool hasPDBInfoStream(); + bool hasPDBInfoStream() const; bool hasPDBIpiStream() const; bool hasPDBPublicsStream(); bool hasPDBSymbolStream(); @@ -124,7 +125,6 @@ private: std::unique_ptr<BinaryStream> Buffer; - std::vector<uint32_t> FpmPages; msf::MSFLayout ContainerLayout; std::unique_ptr<GlobalsStream> Globals; diff --git a/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h b/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h index 2dc23f819d3bd..7ed164bee9ee2 100644 --- a/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h +++ b/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h @@ -31,7 +31,7 @@ class MSFBuilder; namespace pdb { class DbiStreamBuilder; class InfoStreamBuilder; -class PublicsStreamBuilder; +class GSIStreamBuilder; class TpiStreamBuilder; class PDBFileBuilder { @@ -49,7 +49,7 @@ public: TpiStreamBuilder &getTpiBuilder(); TpiStreamBuilder &getIpiBuilder(); PDBStringTableBuilder &getStringTableBuilder(); - PublicsStreamBuilder &getPublicsBuilder(); + GSIStreamBuilder &getGsiBuilder(); Error commit(StringRef Filename); @@ -59,12 +59,14 @@ public: private: Expected<msf::MSFLayout> finalizeMsfLayout(); + void commitFpm(WritableBinaryStream &MsfBuffer, const msf::MSFLayout &Layout); + BumpPtrAllocator &Allocator; std::unique_ptr<msf::MSFBuilder> Msf; std::unique_ptr<InfoStreamBuilder> Info; std::unique_ptr<DbiStreamBuilder> Dbi; - std::unique_ptr<PublicsStreamBuilder> Publics; + std::unique_ptr<GSIStreamBuilder> Gsi; std::unique_ptr<TpiStreamBuilder> Tpi; std::unique_ptr<TpiStreamBuilder> Ipi; diff --git a/include/llvm/DebugInfo/PDB/Native/PublicsStream.h b/include/llvm/DebugInfo/PDB/Native/PublicsStream.h index 9ace826bd8f71..2d0222a9071a0 100644 --- a/include/llvm/DebugInfo/PDB/Native/PublicsStream.h +++ b/include/llvm/DebugInfo/PDB/Native/PublicsStream.h @@ -12,6 +12,7 @@ #include "llvm/DebugInfo/CodeView/SymbolRecord.h" #include "llvm/DebugInfo/MSF/MappedBlockStream.h" +#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h" #include "llvm/DebugInfo/PDB/Native/RawConstants.h" #include "llvm/DebugInfo/PDB/Native/RawTypes.h" #include "llvm/DebugInfo/PDB/PDBTypes.h" @@ -26,19 +27,14 @@ class PDBFile; class PublicsStream { public: - PublicsStream(PDBFile &File, std::unique_ptr<msf::MappedBlockStream> Stream); + PublicsStream(std::unique_ptr<msf::MappedBlockStream> Stream); ~PublicsStream(); Error reload(); uint32_t getSymHash() const; - uint32_t getAddrMap() const; - uint32_t getNumBuckets() const { return NumBuckets; } - Expected<const codeview::CVSymbolArray &> getSymbolArray() const; - iterator_range<codeview::CVSymbolArray::Iterator> - getSymbols(bool *HadError) const; - FixedStreamArray<support::ulittle32_t> getHashBuckets() const { - return HashBuckets; - } + uint16_t getThunkTableSection() const; + uint32_t getThunkTableOffset() const; + const GSIHashTable &getPublicsTable() const { return PublicsTable; } FixedStreamArray<support::ulittle32_t> getAddressMap() const { return AddressMap; } @@ -49,22 +45,14 @@ public: return SectionOffsets; } - Error commit(); - private: - PDBFile &Pdb; - std::unique_ptr<msf::MappedBlockStream> Stream; - uint32_t NumBuckets = 0; - ArrayRef<uint8_t> Bitmap; - FixedStreamArray<PSHashRecord> HashRecords; - FixedStreamArray<support::ulittle32_t> HashBuckets; + GSIHashTable PublicsTable; FixedStreamArray<support::ulittle32_t> AddressMap; FixedStreamArray<support::ulittle32_t> ThunkMap; FixedStreamArray<SectionOffset> SectionOffsets; const PublicsStreamHeader *Header; - const GSIHashHeader *HashHdr; }; } } diff --git a/include/llvm/DebugInfo/PDB/Native/PublicsStreamBuilder.h b/include/llvm/DebugInfo/PDB/Native/PublicsStreamBuilder.h deleted file mode 100644 index 5ab57ebef53d4..0000000000000 --- a/include/llvm/DebugInfo/PDB/Native/PublicsStreamBuilder.h +++ /dev/null @@ -1,54 +0,0 @@ -//===- PublicsStreamBuilder.h - PDB Publics Stream Creation -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBPUBLICSTREAMBUILDER_H -#define LLVM_DEBUGINFO_PDB_RAW_PDBPUBLICSTREAMBUILDER_H - -#include "llvm/DebugInfo/PDB/Native/RawConstants.h" -#include "llvm/DebugInfo/PDB/Native/RawTypes.h" -#include "llvm/Support/BinaryByteStream.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/BinaryStreamWriter.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace msf { -class MSFBuilder; -} -namespace pdb { -class PublicsStream; -struct PublicsStreamHeader; - -class PublicsStreamBuilder { -public: - explicit PublicsStreamBuilder(msf::MSFBuilder &Msf); - ~PublicsStreamBuilder(); - - PublicsStreamBuilder(const PublicsStreamBuilder &) = delete; - PublicsStreamBuilder &operator=(const PublicsStreamBuilder &) = delete; - - Error finalizeMsfLayout(); - uint32_t calculateSerializedLength() const; - - Error commit(BinaryStreamWriter &PublicsWriter); - - uint32_t getStreamIndex() const { return StreamIdx; } - uint32_t getRecordStreamIdx() const { return RecordStreamIdx; } - -private: - uint32_t StreamIdx = kInvalidStreamIndex; - uint32_t RecordStreamIdx = kInvalidStreamIndex; - std::vector<PSHashRecord> HashRecords; - msf::MSFBuilder &Msf; -}; -} // namespace pdb -} // namespace llvm - -#endif diff --git a/include/llvm/DebugInfo/PDB/Native/RawTypes.h b/include/llvm/DebugInfo/PDB/Native/RawTypes.h index b6321cbf45a82..8cc083685265a 100644 --- a/include/llvm/DebugInfo/PDB/Native/RawTypes.h +++ b/include/llvm/DebugInfo/PDB/Native/RawTypes.h @@ -23,6 +23,20 @@ struct SectionOffset { char Padding[2]; }; +/// Header of the hash tables found in the globals and publics sections. +/// Based on GSIHashHdr in +/// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h +struct GSIHashHeader { + enum : unsigned { + HdrSignature = ~0U, + HdrVersion = 0xeffe0000 + 19990810, + }; + support::ulittle32_t VerSignature; + support::ulittle32_t VerHdr; + support::ulittle32_t HrSize; + support::ulittle32_t NumBuckets; +}; + // This is HRFile. struct PSHashRecord { support::ulittle32_t Off; // Offset in the symbol record stream diff --git a/include/llvm/DebugInfo/PDB/Native/SymbolStream.h b/include/llvm/DebugInfo/PDB/Native/SymbolStream.h index 17695f587849e..ae9f7d657b701 100644 --- a/include/llvm/DebugInfo/PDB/Native/SymbolStream.h +++ b/include/llvm/DebugInfo/PDB/Native/SymbolStream.h @@ -31,6 +31,8 @@ public: return SymbolRecords; } + codeview::CVSymbol readRecord(uint32_t Offset) const; + iterator_range<codeview::CVSymbolArray::Iterator> getSymbols(bool *HadError) const; |