summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-01-20 22:42:09 +0000
committerZachary Turner <zturner@google.com>2017-01-20 22:42:09 +0000
commit760ad4da6006422c5a6097232b5ffc72d6b906dd (patch)
treeb0f54c3f60c0a83538c23b3f3cfab7f0b23fcc1f /llvm/lib/DebugInfo/PDB
parent60667ca0b2b95ee25dace3f8627feda5a904cd8f (diff)
downloadbcm5719-llvm-760ad4da6006422c5a6097232b5ffc72d6b906dd.tar.gz
bcm5719-llvm-760ad4da6006422c5a6097232b5ffc72d6b906dd.zip
[pdb] Write the Named Stream mapping to Yaml and binary.
Differential Revision: https://reviews.llvm.org/D28919 llvm-svn: 292665
Diffstat (limited to 'llvm/lib/DebugInfo/PDB')
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp4
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp12
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp34
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/StringTableBuilder.cpp9
4 files changed, 47 insertions, 12 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp
index 9334d2a6a23..9abcfbf0244 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp
@@ -75,3 +75,7 @@ uint32_t InfoStream::getSignature() const { return Signature; }
uint32_t InfoStream::getAge() const { return Age; }
PDB_UniqueId InfoStream::getGuid() const { return Guid; }
+
+const NamedStreamMap &InfoStream::getNamedStreams() const {
+ return NamedStreams;
+}
diff --git a/llvm/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp
index 4485c83dc05..4d8eb85814d 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp
@@ -13,6 +13,8 @@
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/MSF/StreamWriter.h"
#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
+#include "llvm/DebugInfo/PDB/Raw/NamedStreamMap.h"
+#include "llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
#include "llvm/DebugInfo/PDB/Raw/RawTypes.h"
@@ -21,8 +23,10 @@ using namespace llvm::codeview;
using namespace llvm::msf;
using namespace llvm::pdb;
-InfoStreamBuilder::InfoStreamBuilder(msf::MSFBuilder &Msf)
- : Msf(Msf), Ver(PdbRaw_ImplVer::PdbImplVC70), Sig(-1), Age(0) {}
+InfoStreamBuilder::InfoStreamBuilder(msf::MSFBuilder &Msf,
+ NamedStreamMap &NamedStreams)
+ : Msf(Msf), Ver(PdbRaw_ImplVer::PdbImplVC70), Sig(-1), Age(0),
+ NamedStreams(NamedStreams) {}
void InfoStreamBuilder::setVersion(PdbRaw_ImplVer V) { Ver = V; }
@@ -32,10 +36,6 @@ void InfoStreamBuilder::setAge(uint32_t A) { Age = A; }
void InfoStreamBuilder::setGuid(PDB_UniqueId G) { Guid = G; }
-NamedStreamMap &InfoStreamBuilder::getNamedStreamsBuilder() {
- return NamedStreams;
-}
-
Error InfoStreamBuilder::finalizeMsfLayout() {
uint32_t Length = sizeof(InfoStreamHeader) + NamedStreams.finalize();
if (auto EC = Msf.setStreamSize(StreamPDB, Length))
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
index 6fec0e32a8a..cfd5ba6b83e 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
@@ -20,6 +20,7 @@
#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
#include "llvm/DebugInfo/PDB/Raw/InfoStreamBuilder.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
+#include "llvm/DebugInfo/PDB/Raw/StringTableBuilder.h"
#include "llvm/DebugInfo/PDB/Raw/TpiStream.h"
#include "llvm/DebugInfo/PDB/Raw/TpiStreamBuilder.h"
@@ -44,7 +45,7 @@ MSFBuilder &PDBFileBuilder::getMsfBuilder() { return *Msf; }
InfoStreamBuilder &PDBFileBuilder::getInfoBuilder() {
if (!Info)
- Info = llvm::make_unique<InfoStreamBuilder>(*Msf);
+ Info = llvm::make_unique<InfoStreamBuilder>(*Msf, NamedStreams);
return *Info;
}
@@ -66,7 +67,26 @@ TpiStreamBuilder &PDBFileBuilder::getIpiBuilder() {
return *Ipi;
}
-Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() const {
+StringTableBuilder &PDBFileBuilder::getStringTableBuilder() { return Strings; }
+
+Error PDBFileBuilder::addNamedStream(StringRef Name, uint32_t Size) {
+ auto ExpectedStream = Msf->addStream(Size);
+ if (!ExpectedStream)
+ return ExpectedStream.takeError();
+ NamedStreams.set(Name, *ExpectedStream);
+ return Error::success();
+}
+
+Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() {
+ uint32_t StringTableSize = Strings.finalize();
+
+ if (auto EC = addNamedStream("/names", StringTableSize))
+ return std::move(EC);
+ if (auto EC = addNamedStream("/LinkInfo", 0))
+ return std::move(EC);
+ if (auto EC = addNamedStream("/src/headerblock", 0))
+ return std::move(EC);
+
if (Info) {
if (auto EC = Info->finalizeMsfLayout())
return std::move(EC);
@@ -124,6 +144,16 @@ Error PDBFileBuilder::commit(StringRef Filename) {
return EC;
}
+ uint32_t StringTableStreamNo = 0;
+ if (!NamedStreams.get("/names", StringTableStreamNo))
+ return llvm::make_error<pdb::RawError>(raw_error_code::no_stream);
+
+ auto NS = WritableMappedBlockStream::createIndexedStream(Layout, Buffer,
+ StringTableStreamNo);
+ StreamWriter NSWriter(*NS);
+ if (auto EC = Strings.commit(NSWriter))
+ return EC;
+
if (Info) {
if (auto EC = Info->commit(Layout, Buffer))
return EC;
diff --git a/llvm/lib/DebugInfo/PDB/Raw/StringTableBuilder.cpp b/llvm/lib/DebugInfo/PDB/Raw/StringTableBuilder.cpp
index 7284582d01a..5ae74471a1a 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/StringTableBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/StringTableBuilder.cpp
@@ -38,16 +38,17 @@ static uint32_t computeBucketCount(uint32_t NumStrings) {
return (NumStrings + 1) * 1.25;
}
-uint32_t StringTableBuilder::calculateSerializedLength() const {
+uint32_t StringTableBuilder::finalize() {
uint32_t Size = 0;
Size += sizeof(StringTableHeader);
Size += StringSize;
- Size += 4; // Hash table begins with 4-byte size field.
+ Size += sizeof(uint32_t); // Hash table begins with 4-byte size field.
uint32_t BucketCount = computeBucketCount(Strings.size());
- Size += BucketCount * 4;
+ Size += BucketCount * sizeof(uint32_t);
- Size += 4; // The /names stream ends with the number of strings.
+ Size +=
+ sizeof(uint32_t); // The /names stream ends with the number of strings.
return Size;
}
OpenPOWER on IntegriCloud