summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r--llvm/lib/DebugInfo/CodeView/CVTypeDumper.cpp4
-rw-r--r--llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp8
-rw-r--r--llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp48
-rw-r--r--llvm/lib/DebugInfo/CodeView/ModuleSubstream.cpp10
-rw-r--r--llvm/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp32
-rw-r--r--llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp40
-rw-r--r--llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp15
-rw-r--r--llvm/lib/DebugInfo/MSF/BinaryStreamReader.cpp68
-rw-r--r--llvm/lib/DebugInfo/MSF/BinaryStreamWriter.cpp63
-rw-r--r--llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp48
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp32
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp51
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/GSI.cpp12
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/GSI.h16
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/GlobalsStream.cpp2
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/HashTable.cpp24
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/InfoStream.cpp2
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp5
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/ModInfo.cpp9
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/ModStream.cpp10
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp18
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp3
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp17
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp14
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp3
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/StringTable.cpp9
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp9
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/SymbolStream.cpp3
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp5
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp14
30 files changed, 310 insertions, 284 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/CVTypeDumper.cpp b/llvm/lib/DebugInfo/CodeView/CVTypeDumper.cpp
index f862c202b5d..a94516985b8 100644
--- a/llvm/lib/DebugInfo/CodeView/CVTypeDumper.cpp
+++ b/llvm/lib/DebugInfo/CodeView/CVTypeDumper.cpp
@@ -56,9 +56,9 @@ Error CVTypeDumper::dump(const CVTypeArray &Types,
}
Error CVTypeDumper::dump(ArrayRef<uint8_t> Data, TypeVisitorCallbacks &Dumper) {
- msf::ByteStream Stream(Data);
+ BinaryByteStream Stream(Data, llvm::support::little);
CVTypeArray Types;
- msf::StreamReader Reader(Stream);
+ BinaryStreamReader Reader(Stream);
if (auto EC = Reader.readArray(Types, Reader.getLength()))
return EC;
diff --git a/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp b/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
index aa0621273c5..74c60c78b8b 100644
--- a/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
+++ b/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
@@ -174,7 +174,7 @@ Error CVTypeVisitor::visitTypeStream(CVTypeRange Types) {
return Error::success();
}
-Error CVTypeVisitor::visitFieldListMemberStream(msf::StreamReader Reader) {
+Error CVTypeVisitor::visitFieldListMemberStream(BinaryStreamReader Reader) {
FieldListDeserializer Deserializer(Reader);
TypeVisitorCallbackPipeline Pipeline;
Pipeline.addCallbackToPipeline(Deserializer);
@@ -182,7 +182,7 @@ Error CVTypeVisitor::visitFieldListMemberStream(msf::StreamReader Reader) {
TypeLeafKind Leaf;
while (!Reader.empty()) {
- if (auto EC = Reader.readEnum(Leaf, llvm::support::little))
+ if (auto EC = Reader.readEnum(Leaf))
return EC;
CVMemberRecord Record;
@@ -195,7 +195,7 @@ Error CVTypeVisitor::visitFieldListMemberStream(msf::StreamReader Reader) {
}
Error CVTypeVisitor::visitFieldListMemberStream(ArrayRef<uint8_t> Data) {
- msf::ByteStream S(Data);
- msf::StreamReader SR(S);
+ BinaryByteStream S(Data, llvm::support::little);
+ BinaryStreamReader SR(S);
return visitFieldListMemberStream(SR);
}
diff --git a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
index fd60059b5c6..a204d43ba13 100644
--- a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
+++ b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
@@ -87,14 +87,13 @@ Error CodeViewRecordIO::mapByteVectorTail(std::vector<uint8_t> &Bytes) {
Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd) {
if (isWriting()) {
- if (auto EC =
- Writer->writeInteger(TypeInd.getIndex(), llvm::support::little))
+ if (auto EC = Writer->writeInteger(TypeInd.getIndex()))
return EC;
return Error::success();
}
uint32_t I;
- if (auto EC = Reader->readInteger(I, llvm::support::little))
+ if (auto EC = Reader->readInteger(I))
return EC;
TypeInd.setIndex(I);
return Error::success();
@@ -146,10 +145,10 @@ Error CodeViewRecordIO::mapStringZ(StringRef &Value) {
if (isWriting()) {
// Truncate if we attempt to write too much.
StringRef S = Value.take_front(maxFieldLength() - 1);
- if (auto EC = Writer->writeZeroString(S))
+ if (auto EC = Writer->writeCString(S))
return EC;
} else {
- if (auto EC = Reader->readZeroString(Value))
+ if (auto EC = Reader->readCString(Value))
return EC;
}
return Error::success();
@@ -177,7 +176,7 @@ Error CodeViewRecordIO::mapStringZVectorZ(std::vector<StringRef> &Value) {
if (auto EC = mapStringZ(V))
return EC;
}
- if (auto EC = Writer->writeInteger<uint8_t>(0, llvm::support::little))
+ if (auto EC = Writer->writeInteger<uint8_t>(0))
return EC;
} else {
StringRef S;
@@ -195,28 +194,24 @@ Error CodeViewRecordIO::mapStringZVectorZ(std::vector<StringRef> &Value) {
Error CodeViewRecordIO::writeEncodedSignedInteger(const int64_t &Value) {
assert(Value < 0 && "Encoded integer is not signed!");
if (Value >= std::numeric_limits<int8_t>::min()) {
- if (auto EC =
- Writer->writeInteger<uint16_t>(LF_CHAR, llvm::support::little))
+ if (auto EC = Writer->writeInteger<uint16_t>(LF_CHAR))
return EC;
- if (auto EC = Writer->writeInteger<int8_t>(Value, llvm::support::little))
+ if (auto EC = Writer->writeInteger<int8_t>(Value))
return EC;
} else if (Value >= std::numeric_limits<int16_t>::min()) {
- if (auto EC =
- Writer->writeInteger<uint16_t>(LF_SHORT, llvm::support::little))
+ if (auto EC = Writer->writeInteger<uint16_t>(LF_SHORT))
return EC;
- if (auto EC = Writer->writeInteger<int16_t>(Value, llvm::support::little))
+ if (auto EC = Writer->writeInteger<int16_t>(Value))
return EC;
} else if (Value >= std::numeric_limits<int32_t>::min()) {
- if (auto EC =
- Writer->writeInteger<uint16_t>(LF_LONG, llvm::support::little))
+ if (auto EC = Writer->writeInteger<uint16_t>(LF_LONG))
return EC;
- if (auto EC = Writer->writeInteger<int32_t>(Value, llvm::support::little))
+ if (auto EC = Writer->writeInteger<int32_t>(Value))
return EC;
} else {
- if (auto EC =
- Writer->writeInteger<uint16_t>(LF_QUADWORD, llvm::support::little))
+ if (auto EC = Writer->writeInteger<uint16_t>(LF_QUADWORD))
return EC;
- if (auto EC = Writer->writeInteger(Value, llvm::support::little))
+ if (auto EC = Writer->writeInteger(Value))
return EC;
}
return Error::success();
@@ -224,25 +219,22 @@ Error CodeViewRecordIO::writeEncodedSignedInteger(const int64_t &Value) {
Error CodeViewRecordIO::writeEncodedUnsignedInteger(const uint64_t &Value) {
if (Value < LF_NUMERIC) {
- if (auto EC = Writer->writeInteger<uint16_t>(Value, llvm::support::little))
+ if (auto EC = Writer->writeInteger<uint16_t>(Value))
return EC;
} else if (Value <= std::numeric_limits<uint16_t>::max()) {
- if (auto EC =
- Writer->writeInteger<uint16_t>(LF_USHORT, llvm::support::little))
+ if (auto EC = Writer->writeInteger<uint16_t>(LF_USHORT))
return EC;
- if (auto EC = Writer->writeInteger<uint16_t>(Value, llvm::support::little))
+ if (auto EC = Writer->writeInteger<uint16_t>(Value))
return EC;
} else if (Value <= std::numeric_limits<uint32_t>::max()) {
- if (auto EC =
- Writer->writeInteger<uint16_t>(LF_ULONG, llvm::support::little))
+ if (auto EC = Writer->writeInteger<uint16_t>(LF_ULONG))
return EC;
- if (auto EC = Writer->writeInteger<uint32_t>(Value, llvm::support::little))
+ if (auto EC = Writer->writeInteger<uint32_t>(Value))
return EC;
} else {
- if (auto EC =
- Writer->writeInteger<uint16_t>(LF_UQUADWORD, llvm::support::little))
+ if (auto EC = Writer->writeInteger<uint16_t>(LF_UQUADWORD))
return EC;
- if (auto EC = Writer->writeInteger(Value, llvm::support::little))
+ if (auto EC = Writer->writeInteger(Value))
return EC;
}
diff --git a/llvm/lib/DebugInfo/CodeView/ModuleSubstream.cpp b/llvm/lib/DebugInfo/CodeView/ModuleSubstream.cpp
index 74389f6e167..2dc14b92bca 100644
--- a/llvm/lib/DebugInfo/CodeView/ModuleSubstream.cpp
+++ b/llvm/lib/DebugInfo/CodeView/ModuleSubstream.cpp
@@ -13,18 +13,16 @@
using namespace llvm;
using namespace llvm::codeview;
-using namespace llvm::msf;
ModuleSubstream::ModuleSubstream() : Kind(ModuleSubstreamKind::None) {}
-ModuleSubstream::ModuleSubstream(ModuleSubstreamKind Kind,
- ReadableStreamRef Data)
+ModuleSubstream::ModuleSubstream(ModuleSubstreamKind Kind, BinaryStreamRef Data)
: Kind(Kind), Data(Data) {}
-Error ModuleSubstream::initialize(ReadableStreamRef Stream,
+Error ModuleSubstream::initialize(BinaryStreamRef Stream,
ModuleSubstream &Info) {
const ModuleSubsectionHeader *Header;
- StreamReader Reader(Stream);
+ BinaryStreamReader Reader(Stream);
if (auto EC = Reader.readObject(Header))
return EC;
@@ -42,4 +40,4 @@ uint32_t ModuleSubstream::getRecordLength() const {
ModuleSubstreamKind ModuleSubstream::getSubstreamKind() const { return Kind; }
-ReadableStreamRef ModuleSubstream::getRecordData() const { return Data; }
+BinaryStreamRef ModuleSubstream::getRecordData() const { return Data; }
diff --git a/llvm/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp b/llvm/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp
index 336fbda87e3..d552665d9d6 100644
--- a/llvm/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp
+++ b/llvm/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp
@@ -13,49 +13,47 @@
using namespace llvm;
using namespace llvm::codeview;
-using namespace llvm::msf;
-Error IModuleSubstreamVisitor::visitSymbols(ReadableStreamRef Data) {
+Error IModuleSubstreamVisitor::visitSymbols(BinaryStreamRef Data) {
return visitUnknown(ModuleSubstreamKind::Symbols, Data);
}
-Error IModuleSubstreamVisitor::visitLines(ReadableStreamRef Data,
+Error IModuleSubstreamVisitor::visitLines(BinaryStreamRef Data,
const LineSubstreamHeader *Header,
const LineInfoArray &Lines) {
return visitUnknown(ModuleSubstreamKind::Lines, Data);
}
-Error IModuleSubstreamVisitor::visitStringTable(ReadableStreamRef Data) {
+Error IModuleSubstreamVisitor::visitStringTable(BinaryStreamRef Data) {
return visitUnknown(ModuleSubstreamKind::StringTable, Data);
}
Error IModuleSubstreamVisitor::visitFileChecksums(
- ReadableStreamRef Data, const FileChecksumArray &Checksums) {
+ BinaryStreamRef Data, const FileChecksumArray &Checksums) {
return visitUnknown(ModuleSubstreamKind::FileChecksums, Data);
}
-Error IModuleSubstreamVisitor::visitFrameData(ReadableStreamRef Data) {
+Error IModuleSubstreamVisitor::visitFrameData(BinaryStreamRef Data) {
return visitUnknown(ModuleSubstreamKind::FrameData, Data);
}
-Error IModuleSubstreamVisitor::visitInlineeLines(ReadableStreamRef Data) {
+Error IModuleSubstreamVisitor::visitInlineeLines(BinaryStreamRef Data) {
return visitUnknown(ModuleSubstreamKind::InlineeLines, Data);
}
-Error IModuleSubstreamVisitor::visitCrossScopeImports(ReadableStreamRef Data) {
+Error IModuleSubstreamVisitor::visitCrossScopeImports(BinaryStreamRef Data) {
return visitUnknown(ModuleSubstreamKind::CrossScopeExports, Data);
}
-Error IModuleSubstreamVisitor::visitCrossScopeExports(ReadableStreamRef Data) {
+Error IModuleSubstreamVisitor::visitCrossScopeExports(BinaryStreamRef Data) {
return visitUnknown(ModuleSubstreamKind::CrossScopeImports, Data);
}
-Error IModuleSubstreamVisitor::visitILLines(ReadableStreamRef Data) {
+Error IModuleSubstreamVisitor::visitILLines(BinaryStreamRef Data) {
return visitUnknown(ModuleSubstreamKind::ILLines, Data);
}
-Error IModuleSubstreamVisitor::visitFuncMDTokenMap(ReadableStreamRef Data) {
+Error IModuleSubstreamVisitor::visitFuncMDTokenMap(BinaryStreamRef Data) {
return visitUnknown(ModuleSubstreamKind::FuncMDTokenMap, Data);
}
-Error IModuleSubstreamVisitor::visitTypeMDTokenMap(ReadableStreamRef Data) {
+Error IModuleSubstreamVisitor::visitTypeMDTokenMap(BinaryStreamRef Data) {
return visitUnknown(ModuleSubstreamKind::TypeMDTokenMap, Data);
}
-Error IModuleSubstreamVisitor::visitMergedAssemblyInput(
- ReadableStreamRef Data) {
+Error IModuleSubstreamVisitor::visitMergedAssemblyInput(BinaryStreamRef Data) {
return visitUnknown(ModuleSubstreamKind::MergedAssemblyInput, Data);
}
-Error IModuleSubstreamVisitor::visitCoffSymbolRVA(ReadableStreamRef Data) {
+Error IModuleSubstreamVisitor::visitCoffSymbolRVA(BinaryStreamRef Data) {
return visitUnknown(ModuleSubstreamKind::CoffSymbolRVA, Data);
}
@@ -65,7 +63,7 @@ Error llvm::codeview::visitModuleSubstream(const ModuleSubstream &R,
case ModuleSubstreamKind::Symbols:
return V.visitSymbols(R.getRecordData());
case ModuleSubstreamKind::Lines: {
- StreamReader Reader(R.getRecordData());
+ BinaryStreamReader Reader(R.getRecordData());
const LineSubstreamHeader *Header;
if (auto EC = Reader.readObject(Header))
return EC;
@@ -78,7 +76,7 @@ Error llvm::codeview::visitModuleSubstream(const ModuleSubstream &R,
case ModuleSubstreamKind::StringTable:
return V.visitStringTable(R.getRecordData());
case ModuleSubstreamKind::FileChecksums: {
- StreamReader Reader(R.getRecordData());
+ BinaryStreamReader Reader(R.getRecordData());
FileChecksumArray Checksums;
if (auto EC = Reader.readArray(Checksums, Reader.bytesRemaining()))
return EC;
diff --git a/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp b/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp
index 98599c30b9f..eaa70f2b181 100644
--- a/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp
+++ b/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp
@@ -33,11 +33,11 @@ StringRef llvm::codeview::getBytesAsCString(ArrayRef<uint8_t> LeafData) {
return getBytesAsCharacters(LeafData).split('\0').first;
}
-Error llvm::codeview::consume(msf::StreamReader &Reader, APSInt &Num) {
+Error llvm::codeview::consume(BinaryStreamReader &Reader, APSInt &Num) {
// Used to avoid overload ambiguity on APInt construtor.
bool FalseVal = false;
uint16_t Short;
- if (auto EC = Reader.readInteger(Short, llvm::support::little))
+ if (auto EC = Reader.readInteger(Short))
return EC;
if (Short < LF_NUMERIC) {
@@ -49,49 +49,49 @@ Error llvm::codeview::consume(msf::StreamReader &Reader, APSInt &Num) {
switch (Short) {
case LF_CHAR: {
int8_t N;
- if (auto EC = Reader.readInteger(N, llvm::support::little))
+ if (auto EC = Reader.readInteger(N))
return EC;
Num = APSInt(APInt(8, N, true), false);
return Error::success();
}
case LF_SHORT: {
int16_t N;
- if (auto EC = Reader.readInteger(N, llvm::support::little))
+ if (auto EC = Reader.readInteger(N))
return EC;
Num = APSInt(APInt(16, N, true), false);
return Error::success();
}
case LF_USHORT: {
uint16_t N;
- if (auto EC = Reader.readInteger(N, llvm::support::little))
+ if (auto EC = Reader.readInteger(N))
return EC;
Num = APSInt(APInt(16, N, false), true);
return Error::success();
}
case LF_LONG: {
int32_t N;
- if (auto EC = Reader.readInteger(N, llvm::support::little))
+ if (auto EC = Reader.readInteger(N))
return EC;
Num = APSInt(APInt(32, N, true), false);
return Error::success();
}
case LF_ULONG: {
uint32_t N;
- if (auto EC = Reader.readInteger(N, llvm::support::little))
+ if (auto EC = Reader.readInteger(N))
return EC;
Num = APSInt(APInt(32, N, FalseVal), true);
return Error::success();
}
case LF_QUADWORD: {
int64_t N;
- if (auto EC = Reader.readInteger(N, llvm::support::little))
+ if (auto EC = Reader.readInteger(N))
return EC;
Num = APSInt(APInt(64, N, true), false);
return Error::success();
}
case LF_UQUADWORD: {
uint64_t N;
- if (auto EC = Reader.readInteger(N, llvm::support::little))
+ if (auto EC = Reader.readInteger(N))
return EC;
Num = APSInt(APInt(64, N, false), true);
return Error::success();
@@ -103,15 +103,15 @@ Error llvm::codeview::consume(msf::StreamReader &Reader, APSInt &Num) {
Error llvm::codeview::consume(StringRef &Data, APSInt &Num) {
ArrayRef<uint8_t> Bytes(Data.bytes_begin(), Data.bytes_end());
- msf::ByteStream S(Bytes);
- msf::StreamReader SR(S);
+ BinaryByteStream S(Bytes, llvm::support::little);
+ BinaryStreamReader SR(S);
auto EC = consume(SR, Num);
Data = Data.take_back(SR.bytesRemaining());
return EC;
}
/// Decode a numeric leaf value that is known to be a uint64_t.
-Error llvm::codeview::consume_numeric(msf::StreamReader &Reader,
+Error llvm::codeview::consume_numeric(BinaryStreamReader &Reader,
uint64_t &Num) {
APSInt N;
if (auto EC = consume(Reader, N))
@@ -123,27 +123,27 @@ Error llvm::codeview::consume_numeric(msf::StreamReader &Reader,
return Error::success();
}
-Error llvm::codeview::consume(msf::StreamReader &Reader, uint32_t &Item) {
- return Reader.readInteger(Item, llvm::support::little);
+Error llvm::codeview::consume(BinaryStreamReader &Reader, uint32_t &Item) {
+ return Reader.readInteger(Item);
}
Error llvm::codeview::consume(StringRef &Data, uint32_t &Item) {
ArrayRef<uint8_t> Bytes(Data.bytes_begin(), Data.bytes_end());
- msf::ByteStream S(Bytes);
- msf::StreamReader SR(S);
+ BinaryByteStream S(Bytes, llvm::support::little);
+ BinaryStreamReader SR(S);
auto EC = consume(SR, Item);
Data = Data.take_back(SR.bytesRemaining());
return EC;
}
-Error llvm::codeview::consume(msf::StreamReader &Reader, int32_t &Item) {
- return Reader.readInteger(Item, llvm::support::little);
+Error llvm::codeview::consume(BinaryStreamReader &Reader, int32_t &Item) {
+ return Reader.readInteger(Item);
}
-Error llvm::codeview::consume(msf::StreamReader &Reader, StringRef &Item) {
+Error llvm::codeview::consume(BinaryStreamReader &Reader, StringRef &Item) {
if (Reader.empty())
return make_error<CodeViewError>(cv_error_code::corrupt_record,
"Null terminated string buffer is empty!");
- return Reader.readZeroString(Item);
+ return Reader.readCString(Item);
}
diff --git a/llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp b/llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp
index 00eb6671214..4d0ce9e4da9 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp
@@ -76,7 +76,7 @@ TypeSerializer::addPadding(MutableArrayRef<uint8_t> Record) {
int N = PaddingBytes;
while (PaddingBytes > 0) {
uint8_t Pad = static_cast<uint8_t>(LF_PAD0 + PaddingBytes);
- if (auto EC = Writer.writeInteger(Pad, llvm::support::little))
+ if (auto EC = Writer.writeInteger(Pad))
return std::move(EC);
--PaddingBytes;
}
@@ -85,7 +85,8 @@ TypeSerializer::addPadding(MutableArrayRef<uint8_t> Record) {
TypeSerializer::TypeSerializer(BumpPtrAllocator &Storage)
: RecordStorage(Storage), LastTypeIndex(),
- RecordBuffer(MaxRecordLength * 2), Stream(RecordBuffer), Writer(Stream),
+ RecordBuffer(MaxRecordLength * 2),
+ Stream(RecordBuffer, llvm::support::little), Writer(Stream),
Mapping(Writer) {
// RecordBuffer needs to be able to hold enough data so that if we are 1
// byte short of MaxRecordLen, and then we try to write MaxRecordLen bytes,
@@ -203,15 +204,15 @@ Error TypeSerializer::visitMemberEnd(CVMemberRecord &Record) {
uint8_t *SegmentBytes = RecordStorage.Allocate<uint8_t>(LengthWithSize);
auto SavedSegment = MutableArrayRef<uint8_t>(SegmentBytes, LengthWithSize);
- msf::MutableByteStream CS(SavedSegment);
- msf::StreamWriter CW(CS);
+ MutableBinaryByteStream CS(SavedSegment, llvm::support::little);
+ BinaryStreamWriter CW(CS);
if (auto EC = CW.writeBytes(CopyData))
return EC;
- if (auto EC = CW.writeEnum(TypeLeafKind::LF_INDEX, llvm::support::little))
+ if (auto EC = CW.writeEnum(TypeLeafKind::LF_INDEX))
return EC;
- if (auto EC = CW.writeInteger<uint16_t>(0, llvm::support::little))
+ if (auto EC = CW.writeInteger<uint16_t>(0))
return EC;
- if (auto EC = CW.writeInteger<uint32_t>(0xB0C0B0C0, llvm::support::little))
+ if (auto EC = CW.writeInteger<uint32_t>(0xB0C0B0C0))
return EC;
FieldListSegments.push_back(SavedSegment);
diff --git a/llvm/lib/DebugInfo/MSF/BinaryStreamReader.cpp b/llvm/lib/DebugInfo/MSF/BinaryStreamReader.cpp
index 567e6b1270e..ba5fd213c59 100644
--- a/llvm/lib/DebugInfo/MSF/BinaryStreamReader.cpp
+++ b/llvm/lib/DebugInfo/MSF/BinaryStreamReader.cpp
@@ -1,4 +1,4 @@
-//===- StreamReader.cpp - Reads bytes and objects from a stream -----------===//
+//===- BinaryStreamReader.cpp - Reads objects from a binary stream --------===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,53 +10,79 @@
#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
#include "llvm/DebugInfo/MSF/BinaryStreamRef.h"
-#include "llvm/DebugInfo/MSF/MSFError.h"
using namespace llvm;
-using namespace llvm::msf;
-StreamReader::StreamReader(ReadableStreamRef S) : Stream(S), Offset(0) {}
+BinaryStreamReader::BinaryStreamReader(BinaryStreamRef S)
+ : Stream(S), Offset(0) {}
-Error StreamReader::readLongestContiguousChunk(ArrayRef<uint8_t> &Buffer) {
+Error BinaryStreamReader::readLongestContiguousChunk(
+ ArrayRef<uint8_t> &Buffer) {
if (auto EC = Stream.readLongestContiguousChunk(Offset, Buffer))
return EC;
Offset += Buffer.size();
return Error::success();
}
-Error StreamReader::readBytes(ArrayRef<uint8_t> &Buffer, uint32_t Size) {
+Error BinaryStreamReader::readBytes(ArrayRef<uint8_t> &Buffer, uint32_t Size) {
if (auto EC = Stream.readBytes(Offset, Size, Buffer))
return EC;
Offset += Size;
return Error::success();
}
-Error StreamReader::readZeroString(StringRef &Dest) {
+Error BinaryStreamReader::readInteger(uint64_t &Dest, uint32_t ByteSize) {
+ assert(ByteSize == 1 || ByteSize == 2 || ByteSize == 4 || ByteSize == 8);
+ ArrayRef<uint8_t> Bytes;
+
+ if (auto EC = readBytes(Bytes, ByteSize))
+ return EC;
+ switch (ByteSize) {
+ case 1:
+ Dest = Bytes[0];
+ return Error::success();
+ case 2:
+ Dest = llvm::support::endian::read16(Bytes.data(), Stream.getEndian());
+ return Error::success();
+ case 4:
+ Dest = llvm::support::endian::read32(Bytes.data(), Stream.getEndian());
+ return Error::success();
+ case 8:
+ Dest = llvm::support::endian::read64(Bytes.data(), Stream.getEndian());
+ return Error::success();
+ }
+ llvm_unreachable("Unreachable!");
+ return Error::success();
+}
+
+Error BinaryStreamReader::readCString(StringRef &Dest) {
+ // TODO: This could be made more efficient by using readLongestContiguousChunk
+ // and searching for null terminators in the resulting buffer.
+
uint32_t Length = 0;
// First compute the length of the string by reading 1 byte at a time.
uint32_t OriginalOffset = getOffset();
const char *C;
- do {
+ while (true) {
if (auto EC = readObject(C))
return EC;
- if (*C != '\0')
- ++Length;
- } while (*C != '\0');
+ if (*C == '\0')
+ break;
+ ++Length;
+ }
// Now go back and request a reference for that many bytes.
uint32_t NewOffset = getOffset();
setOffset(OriginalOffset);
- ArrayRef<uint8_t> Data;
- if (auto EC = readBytes(Data, Length))
+ if (auto EC = readFixedString(Dest, Length))
return EC;
- Dest = StringRef(reinterpret_cast<const char *>(Data.begin()), Data.size());
// Now set the offset back to where it was after we calculated the length.
setOffset(NewOffset);
return Error::success();
}
-Error StreamReader::readFixedString(StringRef &Dest, uint32_t Length) {
+Error BinaryStreamReader::readFixedString(StringRef &Dest, uint32_t Length) {
ArrayRef<uint8_t> Bytes;
if (auto EC = readBytes(Bytes, Length))
return EC;
@@ -64,26 +90,26 @@ Error StreamReader::readFixedString(StringRef &Dest, uint32_t Length) {
return Error::success();
}
-Error StreamReader::readStreamRef(ReadableStreamRef &Ref) {
+Error BinaryStreamReader::readStreamRef(BinaryStreamRef &Ref) {
return readStreamRef(Ref, bytesRemaining());
}
-Error StreamReader::readStreamRef(ReadableStreamRef &Ref, uint32_t Length) {
+Error BinaryStreamReader::readStreamRef(BinaryStreamRef &Ref, uint32_t Length) {
if (bytesRemaining() < Length)
- return make_error<MSFError>(msf_error_code::insufficient_buffer);
+ return errorCodeToError(make_error_code(std::errc::no_buffer_space));
Ref = Stream.slice(Offset, Length);
Offset += Length;
return Error::success();
}
-Error StreamReader::skip(uint32_t Amount) {
+Error BinaryStreamReader::skip(uint32_t Amount) {
if (Amount > bytesRemaining())
- return make_error<MSFError>(msf_error_code::insufficient_buffer);
+ return errorCodeToError(make_error_code(std::errc::no_buffer_space));
Offset += Amount;
return Error::success();
}
-uint8_t StreamReader::peek() const {
+uint8_t BinaryStreamReader::peek() const {
ArrayRef<uint8_t> Buffer;
auto EC = Stream.readBytes(Offset, 1, Buffer);
assert(!EC && "Cannot peek an empty buffer!");
diff --git a/llvm/lib/DebugInfo/MSF/BinaryStreamWriter.cpp b/llvm/lib/DebugInfo/MSF/BinaryStreamWriter.cpp
index 54415b96c0b..08e4aef6060 100644
--- a/llvm/lib/DebugInfo/MSF/BinaryStreamWriter.cpp
+++ b/llvm/lib/DebugInfo/MSF/BinaryStreamWriter.cpp
@@ -1,4 +1,4 @@
-//===- StreamWrite.cpp - Writes bytes and objects to a stream -------------===//
+//===- BinaryStreamWriter.cpp - Writes objects to a BinaryStream ----------===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,21 +11,42 @@
#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
#include "llvm/DebugInfo/MSF/BinaryStreamRef.h"
-#include "llvm/DebugInfo/MSF/MSFError.h"
using namespace llvm;
-using namespace llvm::msf;
-StreamWriter::StreamWriter(WritableStreamRef S) : Stream(S), Offset(0) {}
+BinaryStreamWriter::BinaryStreamWriter(WritableBinaryStreamRef S)
+ : Stream(S), Offset(0) {}
-Error StreamWriter::writeBytes(ArrayRef<uint8_t> Buffer) {
+Error BinaryStreamWriter::writeBytes(ArrayRef<uint8_t> Buffer) {
if (auto EC = Stream.writeBytes(Offset, Buffer))
return EC;
Offset += Buffer.size();
return Error::success();
}
-Error StreamWriter::writeZeroString(StringRef Str) {
+Error BinaryStreamWriter::writeInteger(uint64_t Value, uint32_t ByteSize) {
+ assert(ByteSize == 1 || ByteSize == 2 || ByteSize == 4 || ByteSize == 8);
+ uint8_t Bytes[8];
+ MutableArrayRef<uint8_t> Buffer(Bytes);
+ Buffer = Buffer.take_front(ByteSize);
+ switch (ByteSize) {
+ case 1:
+ Buffer[0] = static_cast<uint8_t>(Value);
+ break;
+ case 2:
+ llvm::support::endian::write16(Buffer.data(), Value, Stream.getEndian());
+ break;
+ case 4:
+ llvm::support::endian::write32(Buffer.data(), Value, Stream.getEndian());
+ break;
+ case 8:
+ llvm::support::endian::write64(Buffer.data(), Value, Stream.getEndian());
+ break;
+ }
+ return writeBytes(Buffer);
+}
+
+Error BinaryStreamWriter::writeCString(StringRef Str) {
if (auto EC = writeFixedString(Str))
return EC;
if (auto EC = writeObject('\0'))
@@ -34,31 +55,21 @@ Error StreamWriter::writeZeroString(StringRef Str) {
return Error::success();
}
-Error StreamWriter::writeFixedString(StringRef Str) {
- ArrayRef<uint8_t> Bytes(Str.bytes_begin(), Str.bytes_end());
- if (auto EC = Stream.writeBytes(Offset, Bytes))
- return EC;
-
- Offset += Str.size();
- return Error::success();
+Error BinaryStreamWriter::writeFixedString(StringRef Str) {
+ return writeBytes(ArrayRef<uint8_t>(Str.bytes_begin(), Str.bytes_end()));
}
-Error StreamWriter::writeStreamRef(ReadableStreamRef Ref) {
- if (auto EC = writeStreamRef(Ref, Ref.getLength()))
- return EC;
- // Don't increment Offset here, it is done by the overloaded call to
- // writeStreamRef.
- return Error::success();
+Error BinaryStreamWriter::writeStreamRef(BinaryStreamRef Ref) {
+ return writeStreamRef(Ref, Ref.getLength());
}
-Error StreamWriter::writeStreamRef(ReadableStreamRef Ref, uint32_t Length) {
- Ref = Ref.slice(0, Length);
-
- StreamReader SrcReader(Ref);
+Error BinaryStreamWriter::writeStreamRef(BinaryStreamRef Ref, uint32_t Length) {
+ BinaryStreamReader SrcReader(Ref.slice(0, Length));
// This is a bit tricky. If we just call readBytes, we are requiring that it
- // return us the entire stream as a contiguous buffer. For large streams this
- // will allocate a huge amount of space from the pool. Instead, iterate over
- // each contiguous chunk until we've consumed the entire stream.
+ // return us the entire stream as a contiguous buffer. There is no guarantee
+ // this can be satisfied by returning a reference straight from the buffer, as
+ // an implementation may not store all data in a single contiguous buffer. So
+ // we iterate over each contiguous chunk, writing each one in succession.
while (SrcReader.bytesRemaining() > 0) {
ArrayRef<uint8_t> Chunk;
if (auto EC = SrcReader.readLongestContiguousChunk(Chunk))
diff --git a/llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp b/llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp
index e52c88a5bfb..c9ba25c0d7d 100644
--- a/llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp
+++ b/llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp
@@ -47,22 +47,20 @@ static Interval intersect(const Interval &I1, const Interval &I2) {
MappedBlockStream::MappedBlockStream(uint32_t BlockSize, uint32_t NumBlocks,
const MSFStreamLayout &Layout,
- const ReadableStream &MsfData)
+ BinaryStreamRef MsfData)
: BlockSize(BlockSize), NumBlocks(NumBlocks), StreamLayout(Layout),
MsfData(MsfData) {}
std::unique_ptr<MappedBlockStream>
MappedBlockStream::createStream(uint32_t BlockSize, uint32_t NumBlocks,
const MSFStreamLayout &Layout,
- const ReadableStream &MsfData) {
+ BinaryStreamRef MsfData) {
return llvm::make_unique<MappedBlockStreamImpl<MappedBlockStream>>(
BlockSize, NumBlocks, Layout, MsfData);
}
-std::unique_ptr<MappedBlockStream>
-MappedBlockStream::createIndexedStream(const MSFLayout &Layout,
- const ReadableStream &MsfData,
- uint32_t StreamIndex) {
+std::unique_ptr<MappedBlockStream> MappedBlockStream::createIndexedStream(
+ const MSFLayout &Layout, BinaryStreamRef MsfData, uint32_t StreamIndex) {
assert(StreamIndex < Layout.StreamMap.size() && "Invalid stream index");
MSFStreamLayout SL;
SL.Blocks = Layout.StreamMap[StreamIndex];
@@ -73,7 +71,7 @@ MappedBlockStream::createIndexedStream(const MSFLayout &Layout,
std::unique_ptr<MappedBlockStream>
MappedBlockStream::createDirectoryStream(const MSFLayout &Layout,
- const ReadableStream &MsfData) {
+ BinaryStreamRef MsfData) {
MSFStreamLayout SL;
SL.Blocks = Layout.DirectoryBlocks;
SL.Length = Layout.SB->NumDirectoryBytes;
@@ -82,14 +80,14 @@ MappedBlockStream::createDirectoryStream(const MSFLayout &Layout,
std::unique_ptr<MappedBlockStream>
MappedBlockStream::createFpmStream(const MSFLayout &Layout,
- const ReadableStream &MsfData) {
+ BinaryStreamRef MsfData) {
MSFStreamLayout SL;
initializeFpmStreamLayout(Layout, SL);
return createStream(Layout.SB->BlockSize, Layout.SB->NumBlocks, SL, MsfData);
}
Error MappedBlockStream::readBytes(uint32_t Offset, uint32_t Size,
- ArrayRef<uint8_t> &Buffer) const {
+ ArrayRef<uint8_t> &Buffer) {
// Make sure we aren't trying to read beyond the end of the stream.
if (Size > StreamLayout.Length)
return make_error<MSFError>(msf_error_code::insufficient_buffer);
@@ -168,8 +166,8 @@ Error MappedBlockStream::readBytes(uint32_t Offset, uint32_t Size,
return Error::success();
}
-Error MappedBlockStream::readLongestContiguousChunk(
- uint32_t Offset, ArrayRef<uint8_t> &Buffer) const {
+Error MappedBlockStream::readLongestContiguousChunk(uint32_t Offset,
+ ArrayRef<uint8_t> &Buffer) {
// Make sure we aren't trying to read beyond the end of the stream.
if (Offset >= StreamLayout.Length)
return make_error<MSFError>(msf_error_code::insufficient_buffer);
@@ -197,10 +195,10 @@ Error MappedBlockStream::readLongestContiguousChunk(
return Error::success();
}
-uint32_t MappedBlockStream::getLength() const { return StreamLayout.Length; }
+uint32_t MappedBlockStream::getLength() { return StreamLayout.Length; }
bool MappedBlockStream::tryReadContiguously(uint32_t Offset, uint32_t Size,
- ArrayRef<uint8_t> &Buffer) const {
+ ArrayRef<uint8_t> &Buffer) {
if (Size == 0) {
Buffer = ArrayRef<uint8_t>();
return true;
@@ -241,7 +239,7 @@ bool MappedBlockStream::tryReadContiguously(uint32_t Offset, uint32_t Size,
}
Error MappedBlockStream::readBytes(uint32_t Offset,
- MutableArrayRef<uint8_t> Buffer) const {
+ MutableArrayRef<uint8_t> Buffer) {
uint32_t BlockNum = Offset / BlockSize;
uint32_t OffsetInBlock = Offset % BlockSize;
@@ -319,21 +317,21 @@ void MappedBlockStream::fixCacheAfterWrite(uint32_t Offset,
WritableMappedBlockStream::WritableMappedBlockStream(
uint32_t BlockSize, uint32_t NumBlocks, const MSFStreamLayout &Layout,
- const WritableStream &MsfData)
+ WritableBinaryStreamRef MsfData)
: ReadInterface(BlockSize, NumBlocks, Layout, MsfData),
WriteInterface(MsfData) {}
std::unique_ptr<WritableMappedBlockStream>
WritableMappedBlockStream::createStream(uint32_t BlockSize, uint32_t NumBlocks,
const MSFStreamLayout &Layout,
- const WritableStream &MsfData) {
+ WritableBinaryStreamRef MsfData) {
return llvm::make_unique<MappedBlockStreamImpl<WritableMappedBlockStream>>(
BlockSize, NumBlocks, Layout, MsfData);
}
std::unique_ptr<WritableMappedBlockStream>
WritableMappedBlockStream::createIndexedStream(const MSFLayout &Layout,
- const WritableStream &MsfData,
+ WritableBinaryStreamRef MsfData,
uint32_t StreamIndex) {
assert(StreamIndex < Layout.StreamMap.size() && "Invalid stream index");
MSFStreamLayout SL;
@@ -344,7 +342,7 @@ WritableMappedBlockStream::createIndexedStream(const MSFLayout &Layout,
std::unique_ptr<WritableMappedBlockStream>
WritableMappedBlockStream::createDirectoryStream(
- const MSFLayout &Layout, const WritableStream &MsfData) {
+ const MSFLayout &Layout, WritableBinaryStreamRef MsfData) {
MSFStreamLayout SL;
SL.Blocks = Layout.DirectoryBlocks;
SL.Length = Layout.SB->NumDirectoryBytes;
@@ -353,28 +351,28 @@ WritableMappedBlockStream::createDirectoryStream(
std::unique_ptr<WritableMappedBlockStream>
WritableMappedBlockStream::createFpmStream(const MSFLayout &Layout,
- const WritableStream &MsfData) {
+ WritableBinaryStreamRef MsfData) {
MSFStreamLayout SL;
initializeFpmStreamLayout(Layout, SL);
return createStream(Layout.SB->BlockSize, Layout.SB->NumBlocks, SL, MsfData);
}
Error WritableMappedBlockStream::readBytes(uint32_t Offset, uint32_t Size,
- ArrayRef<uint8_t> &Buffer) const {
+ ArrayRef<uint8_t> &Buffer) {
return ReadInterface.readBytes(Offset, Size, Buffer);
}
Error WritableMappedBlockStream::readLongestContiguousChunk(
- uint32_t Offset, ArrayRef<uint8_t> &Buffer) const {
+ uint32_t Offset, ArrayRef<uint8_t> &Buffer) {
return ReadInterface.readLongestContiguousChunk(Offset, Buffer);
}
-uint32_t WritableMappedBlockStream::getLength() const {
+uint32_t WritableMappedBlockStream::getLength() {
return ReadInterface.getLength();
}
Error WritableMappedBlockStream::writeBytes(uint32_t Offset,
- ArrayRef<uint8_t> Buffer) const {
+ ArrayRef<uint8_t> Buffer) {
// Make sure we aren't trying to write beyond the end of the stream.
if (Buffer.size() > getStreamLength())
return make_error<MSFError>(msf_error_code::insufficient_buffer);
@@ -410,6 +408,4 @@ Error WritableMappedBlockStream::writeBytes(uint32_t Offset,
return Error::success();
}
-Error WritableMappedBlockStream::commit() const {
- return WriteInterface.commit();
-}
+Error WritableMappedBlockStream::commit() { return WriteInterface.commit(); }
diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp
index d8169434143..51a868f8770 100644
--- a/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp
@@ -10,6 +10,8 @@
#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/MSF/BinaryStreamArray.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamArray.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h"
@@ -34,7 +36,7 @@ using namespace llvm::support;
template <typename ContribType>
static Error loadSectionContribs(FixedStreamArray<ContribType> &Output,
- StreamReader &Reader) {
+ BinaryStreamReader &Reader) {
if (Reader.bytesRemaining() % sizeof(ContribType) != 0)
return make_error<RawError>(
raw_error_code::corrupt_file,
@@ -52,7 +54,7 @@ DbiStream::DbiStream(PDBFile &File, std::unique_ptr<MappedBlockStream> Stream)
DbiStream::~DbiStream() = default;
Error DbiStream::reload() {
- StreamReader Reader(*Stream);
+ BinaryStreamReader Reader(*Stream);
if (Stream->getLength() < sizeof(DbiStreamHeader))
return make_error<RawError>(raw_error_code::corrupt_file,
@@ -145,7 +147,7 @@ Error DbiStream::reload() {
"Found unexpected bytes in DBI Stream.");
if (ECSubstream.getLength() > 0) {
- StreamReader ECReader(ECSubstream);
+ BinaryStreamReader ECReader(ECSubstream);
if (auto EC = ECNames.load(ECReader))
return EC;
}
@@ -207,16 +209,16 @@ PDB_Machine DbiStream::getMachineType() const {
return static_cast<PDB_Machine>(Machine);
}
-msf::FixedStreamArray<object::coff_section> DbiStream::getSectionHeaders() {
+FixedStreamArray<object::coff_section> DbiStream::getSectionHeaders() {
return SectionHeaders;
}
-msf::FixedStreamArray<object::FpoData> DbiStream::getFpoRecords() {
+FixedStreamArray<object::FpoData> DbiStream::getFpoRecords() {
return FpoRecords;
}
ArrayRef<ModuleInfoEx> DbiStream::modules() const { return ModuleInfos; }
-msf::FixedStreamArray<SecMapEntry> DbiStream::getSectionMap() const {
+FixedStreamArray<SecMapEntry> DbiStream::getSectionMap() const {
return SectionMap;
}
@@ -235,8 +237,8 @@ Error DbiStream::initializeSectionContributionData() {
if (SecContrSubstream.getLength() == 0)
return Error::success();
- StreamReader SCReader(SecContrSubstream);
- if (auto EC = SCReader.readEnum(SectionContribVersion, llvm::support::little))
+ BinaryStreamReader SCReader(SecContrSubstream);
+ if (auto EC = SCReader.readEnum(SectionContribVersion))
return EC;
if (SectionContribVersion == DbiSecContribVer60)
@@ -254,7 +256,7 @@ Error DbiStream::initializeModInfoArray() {
// Since each ModInfo in the stream is a variable length, we have to iterate
// them to know how many there actually are.
- StreamReader Reader(ModInfoSubstream);
+ BinaryStreamReader Reader(ModInfoSubstream);
VarStreamArray<ModInfo> ModInfoArray;
if (auto EC = Reader.readArray(ModInfoArray, ModInfoSubstream.getLength()))
@@ -284,7 +286,7 @@ Error DbiStream::initializeSectionHeadersData() {
"Corrupted section header stream.");
size_t NumSections = StreamLen / sizeof(object::coff_section);
- msf::StreamReader Reader(*SHS);
+ BinaryStreamReader Reader(*SHS);
if (auto EC = Reader.readArray(SectionHeaders, NumSections))
return make_error<RawError>(raw_error_code::corrupt_file,
"Could not read a bitmap.");
@@ -316,7 +318,7 @@ Error DbiStream::initializeFpoRecords() {
"Corrupted New FPO stream.");
size_t NumRecords = StreamLen / sizeof(object::FpoData);
- msf::StreamReader Reader(*FS);
+ BinaryStreamReader Reader(*FS);
if (auto EC = Reader.readArray(FpoRecords, NumRecords))
return make_error<RawError>(raw_error_code::corrupt_file,
"Corrupted New FPO stream.");
@@ -328,7 +330,7 @@ Error DbiStream::initializeSectionMapData() {
if (SecMapSubstream.getLength() == 0)
return Error::success();
- StreamReader SMReader(SecMapSubstream);
+ BinaryStreamReader SMReader(SecMapSubstream);
const SecMapHeader *Header;
if (auto EC = SMReader.readObject(Header))
return EC;
@@ -342,7 +344,7 @@ Error DbiStream::initializeFileInfo() {
return Error::success();
const FileInfoSubstreamHeader *FH;
- StreamReader FISR(FileInfoSubstream);
+ BinaryStreamReader FISR(FileInfoSubstream);
if (auto EC = FISR.readObject(FH))
return EC;
@@ -411,14 +413,14 @@ uint32_t DbiStream::getDebugStreamIndex(DbgHeaderType Type) const {
}
Expected<StringRef> DbiStream::getFileNameForIndex(uint32_t Index) const {
- StreamReader Names(NamesBuffer);
+ BinaryStreamReader Names(NamesBuffer);
if (Index >= FileNameOffsets.size())
return make_error<RawError>(raw_error_code::index_out_of_bounds);
uint32_t FileOffset = FileNameOffsets[Index];
Names.setOffset(FileOffset);
StringRef Name;
- if (auto EC = Names.readZeroString(Name))
+ if (auto EC = Names.readCString(Name))
return std::move(EC);
return Name;
}
diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
index 60687ac23b0..ac40330c5dc 100644
--- a/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
@@ -11,6 +11,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/DebugInfo/MSF/BinaryStreamWriter.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamWriter.h"
#include "llvm/DebugInfo/MSF/MSFBuilder.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
@@ -153,18 +154,19 @@ Error DbiStreamBuilder::generateModiSubstream() {
uint32_t Size = calculateModiSubstreamSize();
auto Data = Allocator.Allocate<uint8_t>(Size);
- ModInfoBuffer = MutableByteStream(MutableArrayRef<uint8_t>(Data, Size));
+ ModInfoBuffer = MutableBinaryByteStream(MutableArrayRef<uint8_t>(Data, Size),
+ llvm::support::little);
- StreamWriter ModiWriter(ModInfoBuffer);
+ BinaryStreamWriter ModiWriter(ModInfoBuffer);
for (const auto &M : ModuleInfoList) {
ModuleInfoHeader Layout = {};
Layout.ModDiStream = kInvalidStreamIndex;
Layout.NumFiles = M->SourceFiles.size();
if (auto EC = ModiWriter.writeObject(Layout))
return EC;
- if (auto EC = ModiWriter.writeZeroString(M->Mod))
+ if (auto EC = ModiWriter.writeCString(M->Mod))
return EC;
- if (auto EC = ModiWriter.writeZeroString(M->Obj))
+ if (auto EC = ModiWriter.writeCString(M->Obj))
return EC;
}
if (ModiWriter.bytesRemaining() > sizeof(uint32_t))
@@ -179,29 +181,26 @@ Error DbiStreamBuilder::generateFileInfoSubstream() {
auto Data = Allocator.Allocate<uint8_t>(Size);
uint32_t NamesOffset = Size - NameSize;
- FileInfoBuffer = MutableByteStream(MutableArrayRef<uint8_t>(Data, Size));
+ FileInfoBuffer = MutableBinaryByteStream(MutableArrayRef<uint8_t>(Data, Size),
+ llvm::support::little);
- WritableStreamRef MetadataBuffer =
- WritableStreamRef(FileInfoBuffer).keep_front(NamesOffset);
- StreamWriter MetadataWriter(MetadataBuffer);
+ WritableBinaryStreamRef MetadataBuffer =
+ WritableBinaryStreamRef(FileInfoBuffer).keep_front(NamesOffset);
+ BinaryStreamWriter MetadataWriter(MetadataBuffer);
uint16_t ModiCount = std::min<uint32_t>(UINT16_MAX, ModuleInfos.size());
uint16_t FileCount = std::min<uint32_t>(UINT16_MAX, SourceFileNames.size());
- if (auto EC = MetadataWriter.writeInteger(
- ModiCount, llvm::support::little)) // NumModules
+ if (auto EC = MetadataWriter.writeInteger(ModiCount)) // NumModules
return EC;
- if (auto EC = MetadataWriter.writeInteger(
- FileCount, llvm::support::little)) // NumSourceFiles
+ if (auto EC = MetadataWriter.writeInteger(FileCount)) // NumSourceFiles
return EC;
for (uint16_t I = 0; I < ModiCount; ++I) {
- if (auto EC = MetadataWriter.writeInteger(
- I, llvm::support::little)) // Mod Indices
+ if (auto EC = MetadataWriter.writeInteger(I)) // Mod Indices
return EC;
}
for (const auto MI : ModuleInfoList) {
FileCount = static_cast<uint16_t>(MI->SourceFiles.size());
- if (auto EC = MetadataWriter.writeInteger(
- FileCount, llvm::support::little)) // Mod File Counts
+ if (auto EC = MetadataWriter.writeInteger(FileCount)) // Mod File Counts
return EC;
}
@@ -209,11 +208,11 @@ Error DbiStreamBuilder::generateFileInfoSubstream() {
// A side effect of this is that this will actually compute the various
// file name offsets, so we can then go back and write the FileNameOffsets
// array to the other substream.
- NamesBuffer = WritableStreamRef(FileInfoBuffer).drop_front(NamesOffset);
- StreamWriter NameBufferWriter(NamesBuffer);
+ NamesBuffer = WritableBinaryStreamRef(FileInfoBuffer).drop_front(NamesOffset);
+ BinaryStreamWriter NameBufferWriter(NamesBuffer);
for (auto &Name : SourceFileNames) {
Name.second = NameBufferWriter.getOffset();
- if (auto EC = NameBufferWriter.writeZeroString(Name.getKey()))
+ if (auto EC = NameBufferWriter.writeCString(Name.getKey()))
return EC;
}
@@ -223,8 +222,7 @@ Error DbiStreamBuilder::generateFileInfoSubstream() {
if (Result == SourceFileNames.end())
return make_error<RawError>(raw_error_code::no_entry,
"The source file was not found.");
- if (auto EC = MetadataWriter.writeInteger(Result->second,
- llvm::support::little))
+ if (auto EC = MetadataWriter.writeInteger(Result->second))
return EC;
}
}
@@ -363,14 +361,14 @@ std::vector<SecMapEntry> DbiStreamBuilder::createSectionMap(
}
Error DbiStreamBuilder::commit(const msf::MSFLayout &Layout,
- const msf::WritableStream &Buffer) {
+ WritableBinaryStreamRef Buffer) {
if (auto EC = finalize())
return EC;
auto InfoS =
WritableMappedBlockStream::createIndexedStream(Layout, Buffer, StreamDBI);
- StreamWriter Writer(*InfoS);
+ BinaryStreamWriter Writer(*InfoS);
if (auto EC = Writer.writeObject(*Header))
return EC;
@@ -378,7 +376,7 @@ Error DbiStreamBuilder::commit(const msf::MSFLayout &Layout,
return EC;
if (!SectionContribs.empty()) {
- if (auto EC = Writer.writeEnum(DbiSecContribVer60, llvm::support::little))
+ if (auto EC = Writer.writeEnum(DbiSecContribVer60))
return EC;
if (auto EC = Writer.writeArray(SectionContribs))
return EC;
@@ -397,8 +395,7 @@ Error DbiStreamBuilder::commit(const msf::MSFLayout &Layout,
return EC;
for (auto &Stream : DbgStreams)
- if (auto EC =
- Writer.writeInteger(Stream.StreamNumber, llvm::support::little))
+ if (auto EC = Writer.writeInteger(Stream.StreamNumber))
return EC;
for (auto &Stream : DbgStreams) {
@@ -406,7 +403,7 @@ Error DbiStreamBuilder::commit(const msf::MSFLayout &Layout,
continue;
auto WritableStream = WritableMappedBlockStream::createIndexedStream(
Layout, Buffer, Stream.StreamNumber);
- StreamWriter DbgStreamWriter(*WritableStream);
+ BinaryStreamWriter DbgStreamWriter(*WritableStream);
if (auto EC = DbgStreamWriter.writeArray(Stream.Data))
return EC;
}
diff --git a/llvm/lib/DebugInfo/PDB/Native/GSI.cpp b/llvm/lib/DebugInfo/PDB/Native/GSI.cpp
index 5a727910e20..3a7e1e1529f 100644
--- a/llvm/lib/DebugInfo/PDB/Native/GSI.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/GSI.cpp
@@ -28,9 +28,9 @@ static Error checkHashHdrVersion(const GSIHashHeader *HashHdr) {
return Error::success();
}
-Error readGSIHashBuckets(
- msf::FixedStreamArray<support::ulittle32_t> &HashBuckets,
- const GSIHashHeader *HashHdr, msf::StreamReader &Reader) {
+Error readGSIHashBuckets(FixedStreamArray<support::ulittle32_t> &HashBuckets,
+ const GSIHashHeader *HashHdr,
+ BinaryStreamReader &Reader) {
if (auto EC = checkHashHdrVersion(HashHdr))
return EC;
@@ -57,7 +57,7 @@ Error readGSIHashBuckets(
}
Error readGSIHashHeader(const GSIHashHeader *&HashHdr,
- msf::StreamReader &Reader) {
+ BinaryStreamReader &Reader) {
if (Reader.readObject(HashHdr))
return make_error<RawError>(raw_error_code::corrupt_file,
"Stream does not contain a GSIHashHeader.");
@@ -70,9 +70,9 @@ Error readGSIHashHeader(const GSIHashHeader *&HashHdr,
return Error::success();
}
-Error readGSIHashRecords(msf::FixedStreamArray<PSHashRecord> &HashRecords,
+Error readGSIHashRecords(FixedStreamArray<PSHashRecord> &HashRecords,
const GSIHashHeader *HashHdr,
- msf::StreamReader &Reader) {
+ BinaryStreamReader &Reader) {
if (auto EC = checkHashHdrVersion(HashHdr))
return EC;
diff --git a/llvm/lib/DebugInfo/PDB/Native/GSI.h b/llvm/lib/DebugInfo/PDB/Native/GSI.h
index 5c5596c0484..f47321a2f14 100644
--- a/llvm/lib/DebugInfo/PDB/Native/GSI.h
+++ b/llvm/lib/DebugInfo/PDB/Native/GSI.h
@@ -33,9 +33,7 @@
namespace llvm {
-namespace msf {
-class StreamReader;
-}
+class BinaryStreamReader;
namespace pdb {
@@ -56,14 +54,14 @@ struct GSIHashHeader {
support::ulittle32_t NumBuckets;
};
-Error readGSIHashBuckets(
- msf::FixedStreamArray<support::ulittle32_t> &HashBuckets,
- const GSIHashHeader *HashHdr, msf::StreamReader &Reader);
+Error readGSIHashBuckets(FixedStreamArray<support::ulittle32_t> &HashBuckets,
+ const GSIHashHeader *HashHdr,
+ BinaryStreamReader &Reader);
Error readGSIHashHeader(const GSIHashHeader *&HashHdr,
- msf::StreamReader &Reader);
-Error readGSIHashRecords(msf::FixedStreamArray<PSHashRecord> &HashRecords,
+ BinaryStreamReader &Reader);
+Error readGSIHashRecords(FixedStreamArray<PSHashRecord> &HashRecords,
const GSIHashHeader *HashHdr,
- msf::StreamReader &Reader);
+ BinaryStreamReader &Reader);
}
}
diff --git a/llvm/lib/DebugInfo/PDB/Native/GlobalsStream.cpp b/llvm/lib/DebugInfo/PDB/Native/GlobalsStream.cpp
index d5c80ba42b5..7d6d39d43d2 100644
--- a/llvm/lib/DebugInfo/PDB/Native/GlobalsStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/GlobalsStream.cpp
@@ -23,7 +23,7 @@ GlobalsStream::GlobalsStream(std::unique_ptr<MappedBlockStream> Stream)
GlobalsStream::~GlobalsStream() = default;
Error GlobalsStream::reload() {
- StreamReader Reader(*Stream);
+ BinaryStreamReader Reader(*Stream);
const GSIHashHeader *HashHdr;
if (auto EC = readGSIHashHeader(HashHdr, Reader))
diff --git a/llvm/lib/DebugInfo/PDB/Native/HashTable.cpp b/llvm/lib/DebugInfo/PDB/Native/HashTable.cpp
index dd95c078d7e..ebf8c9c04db 100644
--- a/llvm/lib/DebugInfo/PDB/Native/HashTable.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/HashTable.cpp
@@ -22,7 +22,7 @@ HashTable::HashTable() : HashTable(8) {}
HashTable::HashTable(uint32_t Capacity) { Buckets.resize(Capacity); }
-Error HashTable::load(msf::StreamReader &Stream) {
+Error HashTable::load(BinaryStreamReader &Stream) {
const Header *H;
if (auto EC = Stream.readObject(H))
return EC;
@@ -48,9 +48,9 @@ Error HashTable::load(msf::StreamReader &Stream) {
"Present bit vector interesects deleted!");
for (uint32_t P : Present) {
- if (auto EC = Stream.readInteger(Buckets[P].first, llvm::support::little))
+ if (auto EC = Stream.readInteger(Buckets[P].first))
return EC;
- if (auto EC = Stream.readInteger(Buckets[P].second, llvm::support::little))
+ if (auto EC = Stream.readInteger(Buckets[P].second))
return EC;
}
@@ -77,7 +77,7 @@ uint32_t HashTable::calculateSerializedLength() const {
return Size;
}
-Error HashTable::commit(msf::StreamWriter &Writer) const {
+Error HashTable::commit(BinaryStreamWriter &Writer) const {
Header H;
H.Size = size();
H.Capacity = capacity();
@@ -91,9 +91,9 @@ Error HashTable::commit(msf::StreamWriter &Writer) const {
return EC;
for (const auto &Entry : *this) {
- if (auto EC = Writer.writeInteger(Entry.first, llvm::support::little))
+ if (auto EC = Writer.writeInteger(Entry.first))
return EC;
- if (auto EC = Writer.writeInteger(Entry.second, llvm::support::little))
+ if (auto EC = Writer.writeInteger(Entry.second))
return EC;
}
return Error::success();
@@ -209,10 +209,10 @@ void HashTable::grow() {
assert(size() == S);
}
-Error HashTable::readSparseBitVector(msf::StreamReader &Stream,
+Error HashTable::readSparseBitVector(BinaryStreamReader &Stream,
SparseBitVector<> &V) {
uint32_t NumWords;
- if (auto EC = Stream.readInteger(NumWords, llvm::support::little))
+ if (auto EC = Stream.readInteger(NumWords))
return joinErrors(
std::move(EC),
make_error<RawError>(raw_error_code::corrupt_file,
@@ -220,7 +220,7 @@ Error HashTable::readSparseBitVector(msf::StreamReader &Stream,
for (uint32_t I = 0; I != NumWords; ++I) {
uint32_t Word;
- if (auto EC = Stream.readInteger(Word, llvm::support::little))
+ if (auto EC = Stream.readInteger(Word))
return joinErrors(std::move(EC),
make_error<RawError>(raw_error_code::corrupt_file,
"Expected hash table word"));
@@ -231,11 +231,11 @@ Error HashTable::readSparseBitVector(msf::StreamReader &Stream,
return Error::success();
}
-Error HashTable::writeSparseBitVector(msf::StreamWriter &Writer,
+Error HashTable::writeSparseBitVector(BinaryStreamWriter &Writer,
SparseBitVector<> &Vec) {
int ReqBits = Vec.find_last() + 1;
uint32_t NumWords = alignTo(ReqBits, sizeof(uint32_t)) / sizeof(uint32_t);
- if (auto EC = Writer.writeInteger(NumWords, llvm::support::little))
+ if (auto EC = Writer.writeInteger(NumWords))
return joinErrors(
std::move(EC),
make_error<RawError>(raw_error_code::corrupt_file,
@@ -248,7 +248,7 @@ Error HashTable::writeSparseBitVector(msf::StreamWriter &Writer,
if (Vec.test(Idx))
Word |= (1 << WordIdx);
}
- if (auto EC = Writer.writeInteger(Word, llvm::support::little))
+ if (auto EC = Writer.writeInteger(Word))
return joinErrors(std::move(EC), make_error<RawError>(
raw_error_code::corrupt_file,
"Could not write linear map word"));
diff --git a/llvm/lib/DebugInfo/PDB/Native/InfoStream.cpp b/llvm/lib/DebugInfo/PDB/Native/InfoStream.cpp
index 692099256d8..9c4fca7aa5e 100644
--- a/llvm/lib/DebugInfo/PDB/Native/InfoStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/InfoStream.cpp
@@ -26,7 +26,7 @@ InfoStream::InfoStream(std::unique_ptr<MappedBlockStream> Stream)
: Stream(std::move(Stream)) {}
Error InfoStream::reload() {
- StreamReader Reader(*Stream);
+ BinaryStreamReader Reader(*Stream);
const InfoStreamHeader *H;
if (auto EC = Reader.readObject(H))
diff --git a/llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp
index 0b6a563b5a9..db7e18df1ab 100644
--- a/llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp
@@ -10,6 +10,7 @@
#include "llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h"
#include "llvm/DebugInfo/MSF/BinaryStreamWriter.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamWriter.h"
#include "llvm/DebugInfo/MSF/MSFBuilder.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
@@ -44,10 +45,10 @@ Error InfoStreamBuilder::finalizeMsfLayout() {
}
Error InfoStreamBuilder::commit(const msf::MSFLayout &Layout,
- const msf::WritableStream &Buffer) const {
+ WritableBinaryStreamRef Buffer) const {
auto InfoS =
WritableMappedBlockStream::createIndexedStream(Layout, Buffer, StreamPDB);
- StreamWriter Writer(*InfoS);
+ BinaryStreamWriter Writer(*InfoS);
InfoStreamHeader H;
H.Age = Age;
diff --git a/llvm/lib/DebugInfo/PDB/Native/ModInfo.cpp b/llvm/lib/DebugInfo/PDB/Native/ModInfo.cpp
index 501188e96f6..5e229663844 100644
--- a/llvm/lib/DebugInfo/PDB/Native/ModInfo.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/ModInfo.cpp
@@ -16,7 +16,6 @@
#include <cstdint>
using namespace llvm;
-using namespace llvm::msf;
using namespace llvm::pdb;
using namespace llvm::support;
@@ -26,15 +25,15 @@ ModInfo::ModInfo(const ModInfo &Info) = default;
ModInfo::~ModInfo() = default;
-Error ModInfo::initialize(ReadableStreamRef Stream, ModInfo &Info) {
- StreamReader Reader(Stream);
+Error ModInfo::initialize(BinaryStreamRef Stream, ModInfo &Info) {
+ BinaryStreamReader Reader(Stream);
if (auto EC = Reader.readObject(Info.Layout))
return EC;
- if (auto EC = Reader.readZeroString(Info.ModuleName))
+ if (auto EC = Reader.readCString(Info.ModuleName))
return EC;
- if (auto EC = Reader.readZeroString(Info.ObjFileName))
+ if (auto EC = Reader.readCString(Info.ObjFileName))
return EC;
return Error::success();
}
diff --git a/llvm/lib/DebugInfo/PDB/Native/ModStream.cpp b/llvm/lib/DebugInfo/PDB/Native/ModStream.cpp
index 9f035cf3e94..df9ec818a1d 100644
--- a/llvm/lib/DebugInfo/PDB/Native/ModStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/ModStream.cpp
@@ -31,7 +31,7 @@ ModStream::ModStream(const ModInfo &Module,
ModStream::~ModStream() = default;
Error ModStream::reload() {
- StreamReader Reader(*Stream);
+ BinaryStreamReader Reader(*Stream);
uint32_t SymbolSize = Mod.getSymbolDebugInfoByteSize();
uint32_t C11Size = Mod.getLineInfoByteSize();
@@ -41,9 +41,9 @@ Error ModStream::reload() {
return make_error<RawError>(raw_error_code::corrupt_file,
"Module has both C11 and C13 line info");
- ReadableStreamRef S;
+ BinaryStreamRef S;
- if (auto EC = Reader.readInteger(Signature, llvm::support::little))
+ if (auto EC = Reader.readInteger(Signature))
return EC;
if (auto EC = Reader.readArray(SymbolsSubstream, SymbolSize - 4))
return EC;
@@ -53,12 +53,12 @@ Error ModStream::reload() {
if (auto EC = Reader.readStreamRef(C13LinesSubstream, C13Size))
return EC;
- StreamReader LineReader(C13LinesSubstream);
+ BinaryStreamReader LineReader(C13LinesSubstream);
if (auto EC = LineReader.readArray(LineInfo, LineReader.bytesRemaining()))
return EC;
uint32_t GlobalRefsSize;
- if (auto EC = Reader.readInteger(GlobalRefsSize, llvm::support::little))
+ if (auto EC = Reader.readInteger(GlobalRefsSize))
return EC;
if (auto EC = Reader.readStreamRef(GlobalRefsSubstream, GlobalRefsSize))
return EC;
diff --git a/llvm/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp b/llvm/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp
index ceeca10c5c5..1fa9bc443ec 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp
@@ -21,23 +21,22 @@
#include <cstdint>
using namespace llvm;
-using namespace llvm::msf;
using namespace llvm::pdb;
NamedStreamMap::NamedStreamMap() = default;
-Error NamedStreamMap::load(StreamReader &Stream) {
+Error NamedStreamMap::load(BinaryStreamReader &Stream) {
Mapping.clear();
FinalizedHashTable.clear();
FinalizedInfo.reset();
uint32_t StringBufferSize;
- if (auto EC = Stream.readInteger(StringBufferSize, llvm::support::little))
+ if (auto EC = Stream.readInteger(StringBufferSize))
return joinErrors(std::move(EC),
make_error<RawError>(raw_error_code::corrupt_file,
"Expected string buffer size"));
- msf::ReadableStreamRef StringsBuffer;
+ BinaryStreamRef StringsBuffer;
if (auto EC = Stream.readStreamRef(StringsBuffer, StringBufferSize))
return EC;
@@ -51,11 +50,11 @@ Error NamedStreamMap::load(StreamReader &Stream) {
std::tie(NameOffset, NameIndex) = Entry;
// Compute the offset of the start of the string relative to the stream.
- msf::StreamReader NameReader(StringsBuffer);
+ BinaryStreamReader NameReader(StringsBuffer);
NameReader.setOffset(NameOffset);
// Pump out our c-string from the stream.
StringRef Str;
- if (auto EC = NameReader.readZeroString(Str))
+ if (auto EC = NameReader.readCString(Str))
return joinErrors(std::move(EC),
make_error<RawError>(raw_error_code::corrupt_file,
"Expected name map name"));
@@ -67,17 +66,16 @@ Error NamedStreamMap::load(StreamReader &Stream) {
return Error::success();
}
-Error NamedStreamMap::commit(msf::StreamWriter &Writer) const {
+Error NamedStreamMap::commit(BinaryStreamWriter &Writer) const {
assert(FinalizedInfo.hasValue());
// The first field is the number of bytes of string data.
- if (auto EC = Writer.writeInteger(FinalizedInfo->StringDataBytes,
- llvm::support::little))
+ if (auto EC = Writer.writeInteger(FinalizedInfo->StringDataBytes))
return EC;
// Now all of the string data itself.
for (const auto &Item : Mapping) {
- if (auto EC = Writer.writeZeroString(Item.getKey()))
+ if (auto EC = Writer.writeCString(Item.getKey()))
return EC;
}
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
index 4c858253b79..dff53344545 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
@@ -45,7 +45,8 @@ Error NativeSession::createFromPdb(StringRef Path,
return make_error<GenericError>(generic_error_code::invalid_path);
std::unique_ptr<MemoryBuffer> Buffer = std::move(*ErrorOrBuffer);
- auto Stream = llvm::make_unique<MemoryBufferByteStream>(std::move(Buffer));
+ auto Stream = llvm::make_unique<MemoryBufferByteStream>(
+ std::move(Buffer), llvm::support::little);
auto Allocator = llvm::make_unique<BumpPtrAllocator>();
auto File = llvm::make_unique<PDBFile>(Path, std::move(Stream), *Allocator);
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp
index e1cf9102773..7e4f1652114 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp
@@ -11,8 +11,11 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/DebugInfo/MSF/BinaryStream.h"
+#include "llvm/DebugInfo/MSF/BinaryStream.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamArray.h"
#include "llvm/DebugInfo/MSF/BinaryStreamArray.h"
#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
#include "llvm/DebugInfo/MSF/MSFCommon.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
@@ -39,7 +42,7 @@ namespace {
typedef FixedStreamArray<support::ulittle32_t> ulittle_array;
} // end anonymous namespace
-PDBFile::PDBFile(StringRef Path, std::unique_ptr<ReadableStream> PdbFileBuffer,
+PDBFile::PDBFile(StringRef Path, std::unique_ptr<BinaryStream> PdbFileBuffer,
BumpPtrAllocator &Allocator)
: FilePath(Path), Allocator(Allocator), Buffer(std::move(PdbFileBuffer)) {}
@@ -113,7 +116,7 @@ Error PDBFile::setBlockData(uint32_t BlockIndex, uint32_t Offset,
}
Error PDBFile::parseFileHeaders() {
- StreamReader Reader(*Buffer);
+ BinaryStreamReader Reader(*Buffer);
// Initialize SB.
const msf::SuperBlock *SB = nullptr;
@@ -147,7 +150,7 @@ Error PDBFile::parseFileHeaders() {
// See the function fpmPn() for more information:
// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/msf/msf.cpp#L489
auto FpmStream = MappedBlockStream::createFpmStream(ContainerLayout, *Buffer);
- StreamReader FpmReader(*FpmStream);
+ BinaryStreamReader FpmReader(*FpmStream);
ArrayRef<uint8_t> FpmBytes;
if (auto EC = FpmReader.readBytes(FpmBytes,
msf::getFullFpmByteSize(ContainerLayout)))
@@ -185,8 +188,8 @@ Error PDBFile::parseStreamData() {
// subclass of IPDBStreamData which only accesses the fields that have already
// been parsed, we can avoid this and reuse MappedBlockStream.
auto DS = MappedBlockStream::createDirectoryStream(ContainerLayout, *Buffer);
- StreamReader Reader(*DS);
- if (auto EC = Reader.readInteger(NumStreams, llvm::support::little))
+ BinaryStreamReader Reader(*DS);
+ if (auto EC = Reader.readInteger(NumStreams))
return EC;
if (auto EC = Reader.readArray(ContainerLayout.StreamSizes, NumStreams))
@@ -350,7 +353,7 @@ Expected<StringTable &> PDBFile::getStringTable() {
if (!NS)
return NS.takeError();
- StreamReader Reader(**NS);
+ BinaryStreamReader Reader(**NS);
auto N = llvm::make_unique<StringTable>();
if (auto EC = N->load(Reader))
return std::move(EC);
@@ -403,7 +406,7 @@ bool PDBFile::hasStringTable() {
/// contain the stream returned by createIndexedStream().
Expected<std::unique_ptr<MappedBlockStream>>
PDBFile::safelyCreateIndexedStream(const MSFLayout &Layout,
- const ReadableStream &MsfData,
+ BinaryStreamRef MsfData,
uint32_t StreamIndex) const {
if (StreamIndex >= getNumStreams())
return make_error<RawError>(raw_error_code::no_stream);
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
index fde61ddc650..298382fdc7d 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
@@ -12,6 +12,8 @@
#include "llvm/ADT/BitVector.h"
#include "llvm/DebugInfo/MSF/BinaryStream.h"
+#include "llvm/DebugInfo/MSF/BinaryStream.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamWriter.h"
#include "llvm/DebugInfo/MSF/BinaryStreamWriter.h"
#include "llvm/DebugInfo/MSF/MSFBuilder.h"
#include "llvm/DebugInfo/PDB/GenericError.h"
@@ -118,8 +120,9 @@ Error PDBFileBuilder::commit(StringRef Filename) {
if (OutFileOrError.getError())
return llvm::make_error<pdb::GenericError>(generic_error_code::invalid_path,
Filename);
- FileBufferByteStream Buffer(std::move(*OutFileOrError));
- StreamWriter Writer(Buffer);
+ FileBufferByteStream Buffer(std::move(*OutFileOrError),
+ llvm::support::little);
+ BinaryStreamWriter Writer(Buffer);
if (auto EC = Writer.writeObject(*Layout.SB))
return EC;
@@ -131,9 +134,8 @@ Error PDBFileBuilder::commit(StringRef Filename) {
auto DirStream =
WritableMappedBlockStream::createDirectoryStream(Layout, Buffer);
- StreamWriter DW(*DirStream);
- if (auto EC = DW.writeInteger<uint32_t>(Layout.StreamSizes.size(),
- llvm::support::little))
+ BinaryStreamWriter DW(*DirStream);
+ if (auto EC = DW.writeInteger<uint32_t>(Layout.StreamSizes.size()))
return EC;
if (auto EC = DW.writeArray(Layout.StreamSizes))
@@ -150,7 +152,7 @@ Error PDBFileBuilder::commit(StringRef Filename) {
auto NS = WritableMappedBlockStream::createIndexedStream(Layout, Buffer,
StringTableStreamNo);
- StreamWriter NSWriter(*NS);
+ BinaryStreamWriter NSWriter(*NS);
if (auto EC = Strings.commit(NSWriter))
return EC;
diff --git a/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp b/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp
index 57b77b8254d..fe85a329a58 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp
@@ -27,6 +27,7 @@
#include "llvm/ADT/iterator_range.h"
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
#include "llvm/DebugInfo/PDB/Native/RawError.h"
@@ -69,7 +70,7 @@ uint32_t PublicsStream::getAddrMap() const { return Header->AddrMap; }
// we skip over the hash table which we believe contains information about
// public symbols.
Error PublicsStream::reload() {
- StreamReader Reader(*Stream);
+ BinaryStreamReader Reader(*Stream);
// Check stream size.
if (Reader.bytesRemaining() < sizeof(HeaderInfo) + sizeof(GSIHashHeader))
diff --git a/llvm/lib/DebugInfo/PDB/Native/StringTable.cpp b/llvm/lib/DebugInfo/PDB/Native/StringTable.cpp
index c81bff48191..79a78c92598 100644
--- a/llvm/lib/DebugInfo/PDB/Native/StringTable.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/StringTable.cpp
@@ -17,13 +17,12 @@
#include "llvm/Support/Endian.h"
using namespace llvm;
-using namespace llvm::msf;
using namespace llvm::support;
using namespace llvm::pdb;
StringTable::StringTable() : Signature(0), HashVersion(0), NameCount(0) {}
-Error StringTable::load(StreamReader &Stream) {
+Error StringTable::load(BinaryStreamReader &Stream) {
const StringTableHeader *H;
if (auto EC = Stream.readObject(H))
return EC;
@@ -55,7 +54,7 @@ Error StringTable::load(StreamReader &Stream) {
return make_error<RawError>(raw_error_code::corrupt_file,
"Missing name count");
- if (auto EC = Stream.readInteger(NameCount, llvm::support::little))
+ if (auto EC = Stream.readInteger(NameCount))
return EC;
return Error::success();
}
@@ -68,9 +67,9 @@ StringRef StringTable::getStringForID(uint32_t ID) const {
// the starting offset of the string we're looking for. So just seek into
// the desired offset and a read a null terminated stream from that offset.
StringRef Result;
- StreamReader NameReader(NamesBuffer);
+ BinaryStreamReader NameReader(NamesBuffer);
NameReader.setOffset(ID);
- if (auto EC = NameReader.readZeroString(Result))
+ if (auto EC = NameReader.readCString(Result))
consumeError(std::move(EC));
return Result;
}
diff --git a/llvm/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp
index 8fad775ecdc..9df97c9753e 100644
--- a/llvm/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp
@@ -52,7 +52,7 @@ uint32_t StringTableBuilder::finalize() {
return Size;
}
-Error StringTableBuilder::commit(msf::StreamWriter &Writer) const {
+Error StringTableBuilder::commit(BinaryStreamWriter &Writer) const {
// Write a header
StringTableHeader H;
H.Signature = StringTableSignature;
@@ -67,14 +67,14 @@ Error StringTableBuilder::commit(msf::StreamWriter &Writer) const {
StringRef S = Pair.first;
uint32_t Offset = Pair.second;
Writer.setOffset(StringStart + Offset);
- if (auto EC = Writer.writeZeroString(S))
+ if (auto EC = Writer.writeCString(S))
return EC;
}
Writer.setOffset(StringStart + StringSize);
// Write a hash table.
uint32_t BucketCount = computeBucketCount(Strings.size());
- if (auto EC = Writer.writeInteger(BucketCount, llvm::support::little))
+ if (auto EC = Writer.writeInteger(BucketCount))
return EC;
std::vector<ulittle32_t> Buckets(BucketCount);
@@ -96,8 +96,7 @@ Error StringTableBuilder::commit(msf::StreamWriter &Writer) const {
if (auto EC = Writer.writeArray(ArrayRef<ulittle32_t>(Buckets)))
return EC;
- if (auto EC = Writer.writeInteger(static_cast<uint32_t>(Strings.size()),
- llvm::support::little))
+ if (auto EC = Writer.writeInteger(static_cast<uint32_t>(Strings.size())))
return EC;
return Error::success();
}
diff --git a/llvm/lib/DebugInfo/PDB/Native/SymbolStream.cpp b/llvm/lib/DebugInfo/PDB/Native/SymbolStream.cpp
index 3f0e07a99e1..e0b8924c306 100644
--- a/llvm/lib/DebugInfo/PDB/Native/SymbolStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/SymbolStream.cpp
@@ -17,6 +17,7 @@
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
#include "llvm/DebugInfo/PDB/Native/RawError.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
#include "llvm/Support/Endian.h"
using namespace llvm;
@@ -30,7 +31,7 @@ SymbolStream::SymbolStream(std::unique_ptr<MappedBlockStream> Stream)
SymbolStream::~SymbolStream() {}
Error SymbolStream::reload() {
- StreamReader Reader(*Stream);
+ BinaryStreamReader Reader(*Stream);
if (auto EC = Reader.readArray(SymbolRecords, Stream->getLength()))
return EC;
diff --git a/llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp b/llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp
index 8f9dd0a793b..954374ca4df 100644
--- a/llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp
@@ -14,6 +14,7 @@
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
+#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
#include "llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h"
@@ -54,7 +55,7 @@ Error TpiStream::verifyHashValues() {
}
Error TpiStream::reload() {
- StreamReader Reader(*Stream);
+ BinaryStreamReader Reader(*Stream);
if (Reader.bytesRemaining() < sizeof(TpiStreamHeader))
return make_error<RawError>(raw_error_code::corrupt_file,
@@ -93,7 +94,7 @@ Error TpiStream::reload() {
auto HS = MappedBlockStream::createIndexedStream(
Pdb.getMsfLayout(), Pdb.getMsfBuffer(), Header->HashStreamIndex);
- StreamReader HSR(*HS);
+ BinaryStreamReader HSR(*HS);
uint32_t NumHashValues =
Header->HashValueBuffer.Length / sizeof(ulittle32_t);
diff --git a/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
index 29c1ec00fc7..7d532ee56d8 100644
--- a/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
@@ -34,7 +34,8 @@ using namespace llvm::pdb;
using namespace llvm::support;
TpiStreamBuilder::TpiStreamBuilder(MSFBuilder &Msf, uint32_t StreamIdx)
- : Msf(Msf), Allocator(Msf.getAllocator()), Header(nullptr), Idx(StreamIdx) {
+ : Msf(Msf), Allocator(Msf.getAllocator()),
+ TypeRecordStream(llvm::support::little), Header(nullptr), Idx(StreamIdx) {
}
TpiStreamBuilder::~TpiStreamBuilder() = default;
@@ -82,7 +83,7 @@ Error TpiStreamBuilder::finalize() {
return Error::success();
}
-uint32_t TpiStreamBuilder::calculateSerializedLength() const {
+uint32_t TpiStreamBuilder::calculateSerializedLength() {
return sizeof(TpiStreamHeader) + TypeRecordStream.getLength();
}
@@ -113,19 +114,20 @@ Error TpiStreamBuilder::finalizeMsfLayout() {
}
ArrayRef<uint8_t> Bytes(reinterpret_cast<const uint8_t *>(HashBuffer.data()),
HashBufferSize);
- HashValueStream = llvm::make_unique<ByteStream>(Bytes);
+ HashValueStream =
+ llvm::make_unique<BinaryByteStream>(Bytes, llvm::support::little);
return Error::success();
}
Error TpiStreamBuilder::commit(const msf::MSFLayout &Layout,
- const msf::WritableStream &Buffer) {
+ WritableBinaryStreamRef Buffer) {
if (auto EC = finalize())
return EC;
auto InfoS =
WritableMappedBlockStream::createIndexedStream(Layout, Buffer, Idx);
- StreamWriter Writer(*InfoS);
+ BinaryStreamWriter Writer(*InfoS);
if (auto EC = Writer.writeObject(*Header))
return EC;
@@ -136,7 +138,7 @@ Error TpiStreamBuilder::commit(const msf::MSFLayout &Layout,
if (HashStreamIndex != kInvalidStreamIndex) {
auto HVS = WritableMappedBlockStream::createIndexedStream(Layout, Buffer,
HashStreamIndex);
- StreamWriter HW(*HVS);
+ BinaryStreamWriter HW(*HVS);
if (auto EC = HW.writeStreamRef(*HashValueStream))
return EC;
}
OpenPOWER on IntegriCloud