diff options
Diffstat (limited to 'llvm')
19 files changed, 42 insertions, 309 deletions
diff --git a/llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h b/llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h index 9469c06bd0e..7f0f10e4fbf 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h +++ b/llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h @@ -10,7 +10,6 @@ #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H #define LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H -#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/DebugInfo/CodeView/CodeView.h" @@ -67,24 +66,19 @@ public: uint32_t insert(StringRef S); // Return the ID for string S. Assumes S exists in the table. - uint32_t getIdForString(StringRef S) const; - - StringRef getStringForId(uint32_t Id) const; + uint32_t getStringId(StringRef S) const; uint32_t calculateSerializedSize() const override; Error commit(BinaryStreamWriter &Writer) const override; uint32_t size() const; - StringMap<uint32_t>::const_iterator begin() const { - return StringToId.begin(); - } + StringMap<uint32_t>::const_iterator begin() const { return Strings.begin(); } - StringMap<uint32_t>::const_iterator end() const { return StringToId.end(); } + StringMap<uint32_t>::const_iterator end() const { return Strings.end(); } private: - DenseMap<uint32_t, StringRef> IdToString; - StringMap<uint32_t> StringToId; + StringMap<uint32_t> Strings; uint32_t StringSize = 1; }; diff --git a/llvm/include/llvm/DebugInfo/PDB/DIA/DIAInjectedSource.h b/llvm/include/llvm/DebugInfo/PDB/DIA/DIAInjectedSource.h index 635508da84e..1fc4a3a305c 100644 --- a/llvm/include/llvm/DebugInfo/PDB/DIA/DIAInjectedSource.h +++ b/llvm/include/llvm/DebugInfo/PDB/DIA/DIAInjectedSource.h @@ -19,7 +19,8 @@ class DIASession; class DIAInjectedSource : public IPDBInjectedSource { public: - explicit DIAInjectedSource(CComPtr<IDiaInjectedSource> DiaSourceFile); + explicit DIAInjectedSource(const DIASession &Session, + CComPtr<IDiaInjectedSource> DiaSourceFile); uint32_t getCrc32() const override; uint64_t getCodeByteSize() const override; @@ -30,6 +31,7 @@ public: std::string getCode() const override; private: + const DIASession &Session; CComPtr<IDiaInjectedSource> SourceFile; }; } // namespace pdb diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/HashTable.h b/llvm/include/llvm/DebugInfo/PDB/Native/HashTable.h index 34cc6179688..6361c4b76ba 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Native/HashTable.h +++ b/llvm/include/llvm/DebugInfo/PDB/Native/HashTable.h @@ -213,7 +213,6 @@ public: Deleted.clear(); } - bool empty() const { return size() == 0; } uint32_t capacity() const { return Buckets.size(); } uint32_t size() const { return Present.count(); } @@ -304,12 +303,12 @@ private: void grow() { uint32_t S = size(); - uint32_t MaxLoad = maxLoad(capacity()); if (S < maxLoad(capacity())) return; assert(capacity() != UINT32_MAX && "Can't grow Hash table!"); - uint32_t NewCapacity = (capacity() <= INT32_MAX) ? MaxLoad * 2 : UINT32_MAX; + uint32_t NewCapacity = + (capacity() <= INT32_MAX) ? capacity() * 2 : UINT32_MAX; // Growing requires rebuilding the table and re-hashing every item. Make a // copy with a larger capacity, insert everything into the copy, then swap diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h b/llvm/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h index 58dda71bf35..7ed164bee9e 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h +++ b/llvm/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h @@ -17,11 +17,9 @@ #include "llvm/DebugInfo/PDB/Native/PDBFile.h" #include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h" #include "llvm/DebugInfo/PDB/Native/RawConstants.h" -#include "llvm/DebugInfo/PDB/Native/RawTypes.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" -#include "llvm/Support/MemoryBuffer.h" #include <memory> #include <vector> @@ -56,34 +54,12 @@ public: Error commit(StringRef Filename); Expected<uint32_t> getNamedStreamIndex(StringRef Name) const; - Error addNamedStream(StringRef Name, StringRef Data); - void addInjectedSource(StringRef Name, std::unique_ptr<MemoryBuffer> Buffer); + Error addNamedStream(StringRef Name, uint32_t Size); private: - struct InjectedSourceDescriptor { - // The full name of the stream that contains the contents of this injected - // source. This is built as a concatenation of the literal "/src/files" - // plus the "vname". - std::string StreamName; - - // The exact name of the file name as specified by the user. - uint32_t NameIndex; - - // The string table index of the "vname" of the file. As far as we - // understand, this is the same as the name, except it is lowercased and - // forward slashes are converted to backslashes. - uint32_t VNameIndex; - std::unique_ptr<MemoryBuffer> Content; - }; - Expected<msf::MSFLayout> finalizeMsfLayout(); - Expected<uint32_t> allocateNamedStream(StringRef Name, uint32_t Size); void commitFpm(WritableBinaryStream &MsfBuffer, const msf::MSFLayout &Layout); - void commitInjectedSources(WritableBinaryStream &MsfBuffer, - const msf::MSFLayout &Layout); - void commitSrcHeaderBlock(WritableBinaryStream &MsfBuffer, - const msf::MSFLayout &Layout); BumpPtrAllocator &Allocator; @@ -95,13 +71,7 @@ private: std::unique_ptr<TpiStreamBuilder> Ipi; PDBStringTableBuilder Strings; - StringTableHashTraits InjectedSourceHashTraits; - HashTable<SrcHeaderBlockEntry, StringTableHashTraits> InjectedSourceTable; - - SmallVector<InjectedSourceDescriptor, 2> InjectedSources; - NamedStreamMap NamedStreams; - DenseMap<uint32_t, std::string> NamedStreamData; }; } } diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h b/llvm/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h index 0f81c18eafe..b57707ee792 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h +++ b/llvm/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h @@ -31,16 +31,6 @@ struct MSFLayout; namespace pdb { class PDBFileBuilder; -class PDBStringTableBuilder; - -struct StringTableHashTraits { - PDBStringTableBuilder *Table; - - explicit StringTableHashTraits(PDBStringTableBuilder &Table); - uint32_t hashLookupKey(StringRef S) const; - StringRef storageKeyToLookupKey(uint32_t Offset) const; - uint32_t lookupKeyToStorageKey(StringRef S); -}; class PDBStringTableBuilder { public: @@ -48,9 +38,6 @@ public: // Returns the ID for S. uint32_t insert(StringRef S); - uint32_t getIdForString(StringRef S) const; - StringRef getStringForId(uint32_t Id) const; - uint32_t calculateSerializedSize() const; Error commit(BinaryStreamWriter &Writer) const; diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/RawConstants.h b/llvm/include/llvm/DebugInfo/PDB/Native/RawConstants.h index fbbd3318d95..bb1d097b512 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Native/RawConstants.h +++ b/llvm/include/llvm/DebugInfo/PDB/Native/RawConstants.h @@ -32,8 +32,6 @@ enum PdbRaw_ImplVer : uint32_t { PdbImplVC140 = 20140508, }; -enum class PdbRaw_SrcHeaderBlockVer : uint32_t { SrcVerOne = 19980827 }; - enum class PdbRaw_FeatureSig : uint32_t { VC110 = PdbImplVC110, VC140 = PdbImplVC140, diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/RawTypes.h b/llvm/include/llvm/DebugInfo/PDB/Native/RawTypes.h index 5cc8821f729..8cc08368526 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Native/RawTypes.h +++ b/llvm/include/llvm/DebugInfo/PDB/Native/RawTypes.h @@ -328,34 +328,6 @@ struct PDBStringTableHeader { const uint32_t PDBStringTableSignature = 0xEFFEEFFE; -/// The header preceding the /src/headerblock stream. -struct SrcHeaderBlockHeader { - support::ulittle32_t Version; // PdbRaw_SrcHeaderBlockVer enumeration. - support::ulittle32_t Size; // Size of entire stream. - uint64_t FileTime; // Time stamp (Windows FILETIME format). - support::ulittle32_t Age; // Age - uint8_t Padding[44]; // Pad to 64 bytes. -}; -static_assert(sizeof(SrcHeaderBlockHeader) == 64, "Incorrect struct size!"); - -/// A single file record entry within the /src/headerblock stream. -struct SrcHeaderBlockEntry { - support::ulittle32_t Size; // Record Length. - support::ulittle32_t Version; // PdbRaw_SrcHeaderBlockVer enumeration. - support::ulittle32_t CRC; // CRC of the original file contents. - support::ulittle32_t FileSize; // Size of original source file. - support::ulittle32_t FileNI; // String table index of file name. - support::ulittle32_t ObjNI; // String table index of object name. - support::ulittle32_t VFileNI; // String table index of virtual file name. - uint8_t Compression; // PDB_SourceCompression enumeration. - uint8_t IsVirtual; // Is this a virtual file (injected)? - short Padding; // Pad to 4 bytes. - char Reserved[8]; -}; - -constexpr int I = sizeof(SrcHeaderBlockEntry); -static_assert(sizeof(SrcHeaderBlockEntry) == 40, "Incorrect struct size!"); - } // namespace pdb } // namespace llvm diff --git a/llvm/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp b/llvm/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp index 0f155a95d60..ccc20eb7488 100644 --- a/llvm/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp +++ b/llvm/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp @@ -109,7 +109,7 @@ Error DebugChecksumsSubsection::commit(BinaryStreamWriter &Writer) const { } uint32_t DebugChecksumsSubsection::mapChecksumOffset(StringRef FileName) const { - uint32_t Offset = Strings.getIdForString(FileName); + uint32_t Offset = Strings.getStringId(FileName); auto Iter = OffsetMap.find(Offset); assert(Iter != OffsetMap.end()); return Iter->second; diff --git a/llvm/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp b/llvm/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp index 9a3d3e3e247..88c0076915b 100644 --- a/llvm/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp +++ b/llvm/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp @@ -80,13 +80,13 @@ Error DebugCrossModuleImportsSubsection::commit( Ids.push_back(&M); std::sort(Ids.begin(), Ids.end(), [this](const T &L1, const T &L2) { - return Strings.getIdForString(L1->getKey()) < - Strings.getIdForString(L2->getKey()); + return Strings.getStringId(L1->getKey()) < + Strings.getStringId(L2->getKey()); }); for (const auto &Item : Ids) { CrossModuleImport Imp; - Imp.ModuleNameOffset = Strings.getIdForString(Item->getKey()); + Imp.ModuleNameOffset = Strings.getStringId(Item->getKey()); Imp.Count = Item->getValue().size(); if (auto EC = Writer.writeObject(Imp)) return EC; diff --git a/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp b/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp index c731b68625c..d723282eb71 100644 --- a/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp +++ b/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp @@ -46,15 +46,12 @@ DebugStringTableSubsection::DebugStringTableSubsection() : DebugSubsection(DebugSubsectionKind::StringTable) {} uint32_t DebugStringTableSubsection::insert(StringRef S) { - auto P = StringToId.insert({S, StringSize}); + auto P = Strings.insert({S, StringSize}); // If a given string didn't exist in the string table, we want to increment - // the string table size and insert it into the reverse lookup. - if (P.second) { - IdToString.insert({P.first->getValue(), P.first->getKey()}); + // the string table size. + if (P.second) StringSize += S.size() + 1; // +1 for '\0' - } - return P.first->second; } @@ -70,7 +67,7 @@ Error DebugStringTableSubsection::commit(BinaryStreamWriter &Writer) const { if (auto EC = Writer.writeCString(StringRef())) return EC; - for (auto &Pair : StringToId) { + for (auto &Pair : Strings) { StringRef S = Pair.getKey(); uint32_t Offset = Begin + Pair.getValue(); Writer.setOffset(Offset); @@ -84,16 +81,10 @@ Error DebugStringTableSubsection::commit(BinaryStreamWriter &Writer) const { return Error::success(); } -uint32_t DebugStringTableSubsection::size() const { return StringToId.size(); } - -uint32_t DebugStringTableSubsection::getIdForString(StringRef S) const { - auto Iter = StringToId.find(S); - assert(Iter != StringToId.end()); - return Iter->second; -} +uint32_t DebugStringTableSubsection::size() const { return Strings.size(); } -StringRef DebugStringTableSubsection::getStringForId(uint32_t Id) const { - auto Iter = IdToString.find(Id); - assert(Iter != IdToString.end()); +uint32_t DebugStringTableSubsection::getStringId(StringRef S) const { + auto Iter = Strings.find(S); + assert(Iter != Strings.end()); return Iter->second; } diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIAEnumInjectedSources.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIAEnumInjectedSources.cpp index d7c908e0459..873f4a0a8db 100644 --- a/llvm/lib/DebugInfo/PDB/DIA/DIAEnumInjectedSources.cpp +++ b/llvm/lib/DebugInfo/PDB/DIA/DIAEnumInjectedSources.cpp @@ -30,7 +30,8 @@ DIAEnumInjectedSources::getChildAtIndex(uint32_t Index) const { if (S_OK != Enumerator->Item(Index, &Item)) return nullptr; - return std::unique_ptr<IPDBInjectedSource>(new DIAInjectedSource(Item)); + return std::unique_ptr<IPDBInjectedSource>( + new DIAInjectedSource(Session, Item)); } std::unique_ptr<IPDBInjectedSource> DIAEnumInjectedSources::getNext() { @@ -39,7 +40,8 @@ std::unique_ptr<IPDBInjectedSource> DIAEnumInjectedSources::getNext() { if (S_OK != Enumerator->Next(1, &Item, &NumFetched)) return nullptr; - return std::unique_ptr<IPDBInjectedSource>(new DIAInjectedSource(Item)); + return std::unique_ptr<IPDBInjectedSource>( + new DIAInjectedSource(Session, Item)); } void DIAEnumInjectedSources::reset() { Enumerator->Reset(); } diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIAInjectedSource.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIAInjectedSource.cpp index 1d642f221d7..fbd169524b6 100644 --- a/llvm/lib/DebugInfo/PDB/DIA/DIAInjectedSource.cpp +++ b/llvm/lib/DebugInfo/PDB/DIA/DIAInjectedSource.cpp @@ -16,8 +16,9 @@ using namespace llvm; using namespace llvm::pdb; -DIAInjectedSource::DIAInjectedSource(CComPtr<IDiaInjectedSource> DiaSourceFile) - : SourceFile(DiaSourceFile) {} +DIAInjectedSource::DIAInjectedSource(const DIASession &Session, + CComPtr<IDiaInjectedSource> DiaSourceFile) + : Session(Session), SourceFile(DiaSourceFile) {} uint32_t DIAInjectedSource::getCrc32() const { DWORD Crc; diff --git a/llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp index 54d6835f112..a20b45111cf 100644 --- a/llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp @@ -73,6 +73,5 @@ Error InfoStreamBuilder::commit(const msf::MSFLayout &Layout, if (auto EC = Writer.writeEnum(E)) return EC; } - assert(Writer.bytesRemaining() == 0); return Error::success(); } diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp index 03d9f3d7bed..1cb890ff799 100644 --- a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp @@ -24,8 +24,6 @@ #include "llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h" #include "llvm/Support/BinaryStream.h" #include "llvm/Support/BinaryStreamWriter.h" -#include "llvm/Support/JamCRC.h" -#include "llvm/Support/Path.h" using namespace llvm; using namespace llvm::codeview; @@ -34,8 +32,7 @@ using namespace llvm::pdb; using namespace llvm::support; PDBFileBuilder::PDBFileBuilder(BumpPtrAllocator &Allocator) - : Allocator(Allocator), InjectedSourceHashTraits(Strings), - InjectedSourceTable(2, InjectedSourceHashTraits) {} + : Allocator(Allocator) {} PDBFileBuilder::~PDBFileBuilder() {} @@ -83,45 +80,14 @@ GSIStreamBuilder &PDBFileBuilder::getGsiBuilder() { return *Gsi; } -Expected<uint32_t> PDBFileBuilder::allocateNamedStream(StringRef Name, - uint32_t Size) { +Error PDBFileBuilder::addNamedStream(StringRef Name, uint32_t Size) { auto ExpectedStream = Msf->addStream(Size); - if (ExpectedStream) - NamedStreams.set(Name, *ExpectedStream); - return ExpectedStream; -} - -Error PDBFileBuilder::addNamedStream(StringRef Name, StringRef Data) { - Expected<uint32_t> ExpectedIndex = allocateNamedStream(Name, Data.size()); - if (!ExpectedIndex) - return ExpectedIndex.takeError(); - assert(NamedStreamData.count(*ExpectedIndex) == 0); - NamedStreamData[*ExpectedIndex] = Data; + if (!ExpectedStream) + return ExpectedStream.takeError(); + NamedStreams.set(Name, *ExpectedStream); return Error::success(); } -void PDBFileBuilder::addInjectedSource(StringRef Name, - std::unique_ptr<MemoryBuffer> Buffer) { - // Stream names must be exact matches, since they get looked up in a hash - // table and the hash value is dependent on the exact contents of the string. - // link.exe lowercases a path and converts / to \, so we must do the same. - SmallString<64> VName; - sys::path::native(Name.lower(), VName); - - uint32_t NI = getStringTableBuilder().insert(Name); - uint32_t VNI = getStringTableBuilder().insert(VName); - - InjectedSourceDescriptor Desc; - Desc.Content = std::move(Buffer); - Desc.NameIndex = NI; - Desc.VNameIndex = VNI; - Desc.StreamName = "/src/files/"; - - Desc.StreamName += VName; - - InjectedSources.push_back(std::move(Desc)); -} - Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() { if (Ipi && Ipi->getRecordCount() > 0) { @@ -135,13 +101,15 @@ Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() { uint32_t StringsLen = Strings.calculateSerializedSize(); - Expected<uint32_t> SN = allocateNamedStream("/names", StringsLen); - if (!SN) - return SN.takeError(); - SN = allocateNamedStream("/LinkInfo", 0); - if (!SN) - return SN.takeError(); + if (auto EC = addNamedStream("/names", StringsLen)) + return std::move(EC); + if (auto EC = addNamedStream("/LinkInfo", 0)) + return std::move(EC); + if (Info) { + if (auto EC = Info->finalizeMsfLayout()) + return std::move(EC); + } if (Dbi) { if (auto EC = Dbi->finalizeMsfLayout()) return std::move(EC); @@ -164,46 +132,6 @@ Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() { } } - if (!InjectedSources.empty()) { - for (const auto &IS : InjectedSources) { - JamCRC CRC(0); - CRC.update(makeArrayRef(IS.Content->getBufferStart(), - IS.Content->getBufferSize())); - - SrcHeaderBlockEntry Entry; - ::memset(&Entry, 0, sizeof(SrcHeaderBlockEntry)); - Entry.Size = sizeof(SrcHeaderBlockEntry); - Entry.FileSize = IS.Content->getBufferSize(); - Entry.FileNI = IS.NameIndex; - Entry.VFileNI = IS.VNameIndex; - Entry.IsVirtual = 0; - Entry.Version = - static_cast<uint32_t>(PdbRaw_SrcHeaderBlockVer::SrcVerOne); - Entry.CRC = CRC.getCRC(); - StringRef VName = getStringTableBuilder().getStringForId(IS.VNameIndex); - InjectedSourceTable.set_as(VName, std::move(Entry)); - } - - uint32_t SrcHeaderBlockSize = - sizeof(SrcHeaderBlockHeader) + - InjectedSourceTable.calculateSerializedLength(); - SN = allocateNamedStream("/src/headerblock", SrcHeaderBlockSize); - if (!SN) - return SN.takeError(); - for (const auto &IS : InjectedSources) { - SN = allocateNamedStream(IS.StreamName, IS.Content->getBufferSize()); - if (!SN) - return SN.takeError(); - } - } - - // Do this last, since it relies on the named stream map being complete, and - // that can be updated by previous steps in the finalization. - if (Info) { - if (auto EC = Info->finalizeMsfLayout()) - return std::move(EC); - } - return Msf->build(); } @@ -239,45 +167,6 @@ void PDBFileBuilder::commitFpm(WritableBinaryStream &MsfBuffer, assert(FpmWriter.bytesRemaining() == 0); } -void PDBFileBuilder::commitSrcHeaderBlock(WritableBinaryStream &MsfBuffer, - const msf::MSFLayout &Layout) { - assert(!InjectedSourceTable.empty()); - - uint32_t SN = cantFail(getNamedStreamIndex("/src/headerblock")); - auto Stream = WritableMappedBlockStream::createIndexedStream( - Layout, MsfBuffer, SN, Allocator); - BinaryStreamWriter Writer(*Stream); - - SrcHeaderBlockHeader Header; - ::memset(&Header, 0, sizeof(Header)); - Header.Version = static_cast<uint32_t>(PdbRaw_SrcHeaderBlockVer::SrcVerOne); - Header.Size = Writer.bytesRemaining(); - - cantFail(Writer.writeObject(Header)); - cantFail(InjectedSourceTable.commit(Writer)); - - assert(Writer.bytesRemaining() == 0); -} - -void PDBFileBuilder::commitInjectedSources(WritableBinaryStream &MsfBuffer, - const msf::MSFLayout &Layout) { - if (InjectedSourceTable.empty()) - return; - - commitSrcHeaderBlock(MsfBuffer, Layout); - - for (const auto &IS : InjectedSources) { - uint32_t SN = cantFail(getNamedStreamIndex(IS.StreamName)); - - auto SourceStream = WritableMappedBlockStream::createIndexedStream( - Layout, MsfBuffer, SN, Allocator); - BinaryStreamWriter SourceWriter(*SourceStream); - assert(SourceWriter.bytesRemaining() == IS.Content->getBufferSize()); - cantFail(SourceWriter.writeBytes( - arrayRefFromStringRef(IS.Content->getBuffer()))); - } -} - Error PDBFileBuilder::commit(StringRef Filename) { assert(!Filename.empty()); auto ExpectedLayout = finalizeMsfLayout(); @@ -330,17 +219,6 @@ Error PDBFileBuilder::commit(StringRef Filename) { if (auto EC = Strings.commit(NSWriter)) return EC; - for (const auto &NSE : NamedStreamData) { - if (NSE.second.empty()) - continue; - - auto NS = WritableMappedBlockStream::createIndexedStream( - Layout, Buffer, NSE.first, Allocator); - BinaryStreamWriter NSW(*NS); - if (auto EC = NSW.writeBytes(arrayRefFromStringRef(NSE.second))) - return EC; - } - if (Info) { if (auto EC = Info->commit(Layout, Buffer)) return EC; @@ -373,8 +251,6 @@ Error PDBFileBuilder::commit(StringRef Filename) { InfoStreamHeader *H = reinterpret_cast<InfoStreamHeader *>( FOB->getBufferStart() + InfoStreamFileOffset); - commitInjectedSources(Buffer, Layout); - // Set the build id at the very end, after every other byte of the PDB // has been written. // FIXME: Use a hash of the PDB rather than time(nullptr) for the signature. diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp index 13106ccbc32..ece3e00b1a8 100644 --- a/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp @@ -21,33 +21,10 @@ using namespace llvm::support; using namespace llvm::support::endian; using namespace llvm::pdb; -StringTableHashTraits::StringTableHashTraits(PDBStringTableBuilder &Table) - : Table(&Table) {} - -uint32_t StringTableHashTraits::hashLookupKey(StringRef S) const { - return Table->getIdForString(S); -} - -StringRef StringTableHashTraits::storageKeyToLookupKey(uint32_t Offset) const { - return Table->getStringForId(Offset); -} - -uint32_t StringTableHashTraits::lookupKeyToStorageKey(StringRef S) { - return Table->insert(S); -} - uint32_t PDBStringTableBuilder::insert(StringRef S) { return Strings.insert(S); } -uint32_t PDBStringTableBuilder::getIdForString(StringRef S) const { - return Strings.getIdForString(S); -} - -StringRef PDBStringTableBuilder::getStringForId(uint32_t Id) const { - return Strings.getStringForId(Id); -} - static uint32_t computeBucketCount(uint32_t NumStrings) { // The /names stream is basically an on-disk open-addressing hash table. // Hash collisions are resolved by linear probing. We cannot make diff --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp index d070e5b4aea..365386f0a27 100644 --- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp @@ -90,12 +90,6 @@ Error DumpOutputStyle::dump() { P.NewLine(); } - if (opts::dump::DumpNamedStreams) { - if (auto EC = dumpNamedStreams()) - return EC; - P.NewLine(); - } - if (opts::dump::DumpStringTable) { if (auto EC = dumpStringTable()) return EC; @@ -915,29 +909,6 @@ Error DumpOutputStyle::dumpStringTableFromObj() { return Error::success(); } -Error DumpOutputStyle::dumpNamedStreams() { - printHeader(P, "Named Streams"); - AutoIndent Indent(P, 2); - - if (File.isObj()) { - P.formatLine("Dumping Named Streams is only supported for PDB files."); - return Error::success(); - } - ExitOnError Err("Invalid PDB File: "); - - auto &IS = Err(File.pdb().getPDBInfoStream()); - const NamedStreamMap &NS = IS.getNamedStreams(); - for (const auto &Entry : NS.entries()) { - P.printLine(Entry.getKey()); - AutoIndent Indent2(P, 2); - P.formatLine("Index: {0}", Entry.getValue()); - P.formatLine("Size in bytes: {0}", - File.pdb().getStreamByteSize(Entry.getValue())); - } - - return Error::success(); -} - Error DumpOutputStyle::dumpStringTable() { printHeader(P, "String Table"); diff --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.h b/llvm/tools/llvm-pdbutil/DumpOutputStyle.h index 36d8b13bde0..fad304c470c 100644 --- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.h +++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.h @@ -74,7 +74,6 @@ private: Error dumpStreamSummary(); Error dumpSymbolStats(); Error dumpUdtStats(); - Error dumpNamedStreams(); Error dumpStringTable(); Error dumpStringTableFromPdb(); Error dumpStringTableFromObj(); diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp index b1749d9ded6..25e0ddf5baa 100644 --- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp +++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -534,10 +534,6 @@ cl::opt<bool> JustMyCode("jmc", cl::Optional, cl::cat(FileOptions), cl::sub(DumpSubcommand)); // MISCELLANEOUS OPTIONS -cl::opt<bool> DumpNamedStreams("named-streams", - cl::desc("dump PDB named stream table"), - cl::cat(MiscOptions), cl::sub(DumpSubcommand)); - cl::opt<bool> DumpStringTable("string-table", cl::desc("dump PDB String Table"), cl::cat(MiscOptions), cl::sub(DumpSubcommand)); diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.h b/llvm/tools/llvm-pdbutil/llvm-pdbutil.h index 1c9f299ab1a..3ce03d5880a 100644 --- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.h +++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.h @@ -142,7 +142,6 @@ extern llvm::cl::opt<bool> DumpLines; extern llvm::cl::opt<bool> DumpInlineeLines; extern llvm::cl::opt<bool> DumpXmi; extern llvm::cl::opt<bool> DumpXme; -extern llvm::cl::opt<bool> DumpNamedStreams; extern llvm::cl::opt<bool> DumpStringTable; extern llvm::cl::opt<bool> DumpTypes; extern llvm::cl::opt<bool> DumpTypeData; |