summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2018-03-19 20:41:59 +0000
committerZachary Turner <zturner@google.com>2018-03-19 20:41:59 +0000
commita21558897bd2d068e997cd6dc3d45af3f280cbb8 (patch)
treeb147fa697728704af4f3da547ba6255818a99ce6 /llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
parentbd5ff79dd0b007489d4776ea0cb4c8cb4bed3fcd (diff)
downloadbcm5719-llvm-a21558897bd2d068e997cd6dc3d45af3f280cbb8.tar.gz
bcm5719-llvm-a21558897bd2d068e997cd6dc3d45af3f280cbb8.zip
Revert "Support embedding natvis files in PDBs."
This is causing a test failure on a certain bot, so I'm removing this temporarily until we can figure out the source of the error. llvm-svn: 327903
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp150
1 files changed, 13 insertions, 137 deletions
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.
OpenPOWER on IntegriCloud