diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2017-02-25 17:04:23 +0000 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2017-02-25 17:04:23 +0000 |
commit | 05a75e40da0f83639111687799eaab2c07c00ef0 (patch) | |
tree | 8ade745eed4316647c5098f24acd74af027ff364 /llvm/lib/DebugInfo/CodeView | |
parent | 09ecd3117e151c645d2870409b5a78b2aeac326d (diff) | |
download | llvm-05a75e40da0f83639111687799eaab2c07c00ef0.zip llvm-05a75e40da0f83639111687799eaab2c07c00ef0.tar.gz llvm-05a75e40da0f83639111687799eaab2c07c00ef0.tar.bz2 |
Revert r296215, "[PDB] General improvements to Stream library." and followings.
r296215, "[PDB] General improvements to Stream library."
r296217, "Disable BinaryStreamTest.StreamReaderObject temporarily."
r296220, "Re-enable BinaryStreamTest.StreamReaderObject."
r296244, "[PDB] Disable some tests that are breaking bots."
r296249, "Add static_cast to silence -Wc++11-narrowing."
std::errc::no_buffer_space should be used for OS-oriented errors for socket transmission.
(Seek discussions around llvm/xray.)
I could substitute s/no_buffer_space/others/g, but I revert whole them ATM.
Could we define and use LLVM errors there?
llvm-svn: 296258
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView')
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/CVTypeDumper.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp | 48 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/ModuleSubstream.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp | 32 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp | 40 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp | 15 |
7 files changed, 84 insertions, 73 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/CVTypeDumper.cpp b/llvm/lib/DebugInfo/CodeView/CVTypeDumper.cpp index a945169..f862c20 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) { - BinaryByteStream Stream(Data, llvm::support::little); + msf::ByteStream Stream(Data); CVTypeArray Types; - BinaryStreamReader Reader(Stream); + msf::StreamReader 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 74c60c7..aa06212 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(BinaryStreamReader Reader) { +Error CVTypeVisitor::visitFieldListMemberStream(msf::StreamReader Reader) { FieldListDeserializer Deserializer(Reader); TypeVisitorCallbackPipeline Pipeline; Pipeline.addCallbackToPipeline(Deserializer); @@ -182,7 +182,7 @@ Error CVTypeVisitor::visitFieldListMemberStream(BinaryStreamReader Reader) { TypeLeafKind Leaf; while (!Reader.empty()) { - if (auto EC = Reader.readEnum(Leaf)) + if (auto EC = Reader.readEnum(Leaf, llvm::support::little)) return EC; CVMemberRecord Record; @@ -195,7 +195,7 @@ Error CVTypeVisitor::visitFieldListMemberStream(BinaryStreamReader Reader) { } Error CVTypeVisitor::visitFieldListMemberStream(ArrayRef<uint8_t> Data) { - BinaryByteStream S(Data, llvm::support::little); - BinaryStreamReader SR(S); + msf::ByteStream S(Data); + msf::StreamReader SR(S); return visitFieldListMemberStream(SR); } diff --git a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp index a204d43..fd60059 100644 --- a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp +++ b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp @@ -87,13 +87,14 @@ Error CodeViewRecordIO::mapByteVectorTail(std::vector<uint8_t> &Bytes) { Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd) { if (isWriting()) { - if (auto EC = Writer->writeInteger(TypeInd.getIndex())) + if (auto EC = + Writer->writeInteger(TypeInd.getIndex(), llvm::support::little)) return EC; return Error::success(); } uint32_t I; - if (auto EC = Reader->readInteger(I)) + if (auto EC = Reader->readInteger(I, llvm::support::little)) return EC; TypeInd.setIndex(I); return Error::success(); @@ -145,10 +146,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->writeCString(S)) + if (auto EC = Writer->writeZeroString(S)) return EC; } else { - if (auto EC = Reader->readCString(Value)) + if (auto EC = Reader->readZeroString(Value)) return EC; } return Error::success(); @@ -176,7 +177,7 @@ Error CodeViewRecordIO::mapStringZVectorZ(std::vector<StringRef> &Value) { if (auto EC = mapStringZ(V)) return EC; } - if (auto EC = Writer->writeInteger<uint8_t>(0)) + if (auto EC = Writer->writeInteger<uint8_t>(0, llvm::support::little)) return EC; } else { StringRef S; @@ -194,24 +195,28 @@ 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)) + if (auto EC = + Writer->writeInteger<uint16_t>(LF_CHAR, llvm::support::little)) return EC; - if (auto EC = Writer->writeInteger<int8_t>(Value)) + if (auto EC = Writer->writeInteger<int8_t>(Value, llvm::support::little)) return EC; } else if (Value >= std::numeric_limits<int16_t>::min()) { - if (auto EC = Writer->writeInteger<uint16_t>(LF_SHORT)) + if (auto EC = + Writer->writeInteger<uint16_t>(LF_SHORT, llvm::support::little)) return EC; - if (auto EC = Writer->writeInteger<int16_t>(Value)) + if (auto EC = Writer->writeInteger<int16_t>(Value, llvm::support::little)) return EC; } else if (Value >= std::numeric_limits<int32_t>::min()) { - if (auto EC = Writer->writeInteger<uint16_t>(LF_LONG)) + if (auto EC = + Writer->writeInteger<uint16_t>(LF_LONG, llvm::support::little)) return EC; - if (auto EC = Writer->writeInteger<int32_t>(Value)) + if (auto EC = Writer->writeInteger<int32_t>(Value, llvm::support::little)) return EC; } else { - if (auto EC = Writer->writeInteger<uint16_t>(LF_QUADWORD)) + if (auto EC = + Writer->writeInteger<uint16_t>(LF_QUADWORD, llvm::support::little)) return EC; - if (auto EC = Writer->writeInteger(Value)) + if (auto EC = Writer->writeInteger(Value, llvm::support::little)) return EC; } return Error::success(); @@ -219,22 +224,25 @@ 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)) + if (auto EC = Writer->writeInteger<uint16_t>(Value, llvm::support::little)) return EC; } else if (Value <= std::numeric_limits<uint16_t>::max()) { - if (auto EC = Writer->writeInteger<uint16_t>(LF_USHORT)) + if (auto EC = + Writer->writeInteger<uint16_t>(LF_USHORT, llvm::support::little)) return EC; - if (auto EC = Writer->writeInteger<uint16_t>(Value)) + if (auto EC = Writer->writeInteger<uint16_t>(Value, llvm::support::little)) return EC; } else if (Value <= std::numeric_limits<uint32_t>::max()) { - if (auto EC = Writer->writeInteger<uint16_t>(LF_ULONG)) + if (auto EC = + Writer->writeInteger<uint16_t>(LF_ULONG, llvm::support::little)) return EC; - if (auto EC = Writer->writeInteger<uint32_t>(Value)) + if (auto EC = Writer->writeInteger<uint32_t>(Value, llvm::support::little)) return EC; } else { - if (auto EC = Writer->writeInteger<uint16_t>(LF_UQUADWORD)) + if (auto EC = + Writer->writeInteger<uint16_t>(LF_UQUADWORD, llvm::support::little)) return EC; - if (auto EC = Writer->writeInteger(Value)) + if (auto EC = Writer->writeInteger(Value, llvm::support::little)) return EC; } diff --git a/llvm/lib/DebugInfo/CodeView/ModuleSubstream.cpp b/llvm/lib/DebugInfo/CodeView/ModuleSubstream.cpp index 2dc14b9..74389f6 100644 --- a/llvm/lib/DebugInfo/CodeView/ModuleSubstream.cpp +++ b/llvm/lib/DebugInfo/CodeView/ModuleSubstream.cpp @@ -13,16 +13,18 @@ using namespace llvm; using namespace llvm::codeview; +using namespace llvm::msf; ModuleSubstream::ModuleSubstream() : Kind(ModuleSubstreamKind::None) {} -ModuleSubstream::ModuleSubstream(ModuleSubstreamKind Kind, BinaryStreamRef Data) +ModuleSubstream::ModuleSubstream(ModuleSubstreamKind Kind, + ReadableStreamRef Data) : Kind(Kind), Data(Data) {} -Error ModuleSubstream::initialize(BinaryStreamRef Stream, +Error ModuleSubstream::initialize(ReadableStreamRef Stream, ModuleSubstream &Info) { const ModuleSubsectionHeader *Header; - BinaryStreamReader Reader(Stream); + StreamReader Reader(Stream); if (auto EC = Reader.readObject(Header)) return EC; @@ -40,4 +42,4 @@ uint32_t ModuleSubstream::getRecordLength() const { ModuleSubstreamKind ModuleSubstream::getSubstreamKind() const { return Kind; } -BinaryStreamRef ModuleSubstream::getRecordData() const { return Data; } +ReadableStreamRef ModuleSubstream::getRecordData() const { return Data; } diff --git a/llvm/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp b/llvm/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp index d552665..336fbda 100644 --- a/llvm/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp +++ b/llvm/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp @@ -13,47 +13,49 @@ using namespace llvm; using namespace llvm::codeview; +using namespace llvm::msf; -Error IModuleSubstreamVisitor::visitSymbols(BinaryStreamRef Data) { +Error IModuleSubstreamVisitor::visitSymbols(ReadableStreamRef Data) { return visitUnknown(ModuleSubstreamKind::Symbols, Data); } -Error IModuleSubstreamVisitor::visitLines(BinaryStreamRef Data, +Error IModuleSubstreamVisitor::visitLines(ReadableStreamRef Data, const LineSubstreamHeader *Header, const LineInfoArray &Lines) { return visitUnknown(ModuleSubstreamKind::Lines, Data); } -Error IModuleSubstreamVisitor::visitStringTable(BinaryStreamRef Data) { +Error IModuleSubstreamVisitor::visitStringTable(ReadableStreamRef Data) { return visitUnknown(ModuleSubstreamKind::StringTable, Data); } Error IModuleSubstreamVisitor::visitFileChecksums( - BinaryStreamRef Data, const FileChecksumArray &Checksums) { + ReadableStreamRef Data, const FileChecksumArray &Checksums) { return visitUnknown(ModuleSubstreamKind::FileChecksums, Data); } -Error IModuleSubstreamVisitor::visitFrameData(BinaryStreamRef Data) { +Error IModuleSubstreamVisitor::visitFrameData(ReadableStreamRef Data) { return visitUnknown(ModuleSubstreamKind::FrameData, Data); } -Error IModuleSubstreamVisitor::visitInlineeLines(BinaryStreamRef Data) { +Error IModuleSubstreamVisitor::visitInlineeLines(ReadableStreamRef Data) { return visitUnknown(ModuleSubstreamKind::InlineeLines, Data); } -Error IModuleSubstreamVisitor::visitCrossScopeImports(BinaryStreamRef Data) { +Error IModuleSubstreamVisitor::visitCrossScopeImports(ReadableStreamRef Data) { return visitUnknown(ModuleSubstreamKind::CrossScopeExports, Data); } -Error IModuleSubstreamVisitor::visitCrossScopeExports(BinaryStreamRef Data) { +Error IModuleSubstreamVisitor::visitCrossScopeExports(ReadableStreamRef Data) { return visitUnknown(ModuleSubstreamKind::CrossScopeImports, Data); } -Error IModuleSubstreamVisitor::visitILLines(BinaryStreamRef Data) { +Error IModuleSubstreamVisitor::visitILLines(ReadableStreamRef Data) { return visitUnknown(ModuleSubstreamKind::ILLines, Data); } -Error IModuleSubstreamVisitor::visitFuncMDTokenMap(BinaryStreamRef Data) { +Error IModuleSubstreamVisitor::visitFuncMDTokenMap(ReadableStreamRef Data) { return visitUnknown(ModuleSubstreamKind::FuncMDTokenMap, Data); } -Error IModuleSubstreamVisitor::visitTypeMDTokenMap(BinaryStreamRef Data) { +Error IModuleSubstreamVisitor::visitTypeMDTokenMap(ReadableStreamRef Data) { return visitUnknown(ModuleSubstreamKind::TypeMDTokenMap, Data); } -Error IModuleSubstreamVisitor::visitMergedAssemblyInput(BinaryStreamRef Data) { +Error IModuleSubstreamVisitor::visitMergedAssemblyInput( + ReadableStreamRef Data) { return visitUnknown(ModuleSubstreamKind::MergedAssemblyInput, Data); } -Error IModuleSubstreamVisitor::visitCoffSymbolRVA(BinaryStreamRef Data) { +Error IModuleSubstreamVisitor::visitCoffSymbolRVA(ReadableStreamRef Data) { return visitUnknown(ModuleSubstreamKind::CoffSymbolRVA, Data); } @@ -63,7 +65,7 @@ Error llvm::codeview::visitModuleSubstream(const ModuleSubstream &R, case ModuleSubstreamKind::Symbols: return V.visitSymbols(R.getRecordData()); case ModuleSubstreamKind::Lines: { - BinaryStreamReader Reader(R.getRecordData()); + StreamReader Reader(R.getRecordData()); const LineSubstreamHeader *Header; if (auto EC = Reader.readObject(Header)) return EC; @@ -76,7 +78,7 @@ Error llvm::codeview::visitModuleSubstream(const ModuleSubstream &R, case ModuleSubstreamKind::StringTable: return V.visitStringTable(R.getRecordData()); case ModuleSubstreamKind::FileChecksums: { - BinaryStreamReader Reader(R.getRecordData()); + StreamReader 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 eaa70f2..98599c3 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(BinaryStreamReader &Reader, APSInt &Num) { +Error llvm::codeview::consume(msf::StreamReader &Reader, APSInt &Num) { // Used to avoid overload ambiguity on APInt construtor. bool FalseVal = false; uint16_t Short; - if (auto EC = Reader.readInteger(Short)) + if (auto EC = Reader.readInteger(Short, llvm::support::little)) return EC; if (Short < LF_NUMERIC) { @@ -49,49 +49,49 @@ Error llvm::codeview::consume(BinaryStreamReader &Reader, APSInt &Num) { switch (Short) { case LF_CHAR: { int8_t N; - if (auto EC = Reader.readInteger(N)) + if (auto EC = Reader.readInteger(N, llvm::support::little)) return EC; Num = APSInt(APInt(8, N, true), false); return Error::success(); } case LF_SHORT: { int16_t N; - if (auto EC = Reader.readInteger(N)) + if (auto EC = Reader.readInteger(N, llvm::support::little)) return EC; Num = APSInt(APInt(16, N, true), false); return Error::success(); } case LF_USHORT: { uint16_t N; - if (auto EC = Reader.readInteger(N)) + if (auto EC = Reader.readInteger(N, llvm::support::little)) return EC; Num = APSInt(APInt(16, N, false), true); return Error::success(); } case LF_LONG: { int32_t N; - if (auto EC = Reader.readInteger(N)) + if (auto EC = Reader.readInteger(N, llvm::support::little)) return EC; Num = APSInt(APInt(32, N, true), false); return Error::success(); } case LF_ULONG: { uint32_t N; - if (auto EC = Reader.readInteger(N)) + if (auto EC = Reader.readInteger(N, llvm::support::little)) return EC; Num = APSInt(APInt(32, N, FalseVal), true); return Error::success(); } case LF_QUADWORD: { int64_t N; - if (auto EC = Reader.readInteger(N)) + if (auto EC = Reader.readInteger(N, llvm::support::little)) return EC; Num = APSInt(APInt(64, N, true), false); return Error::success(); } case LF_UQUADWORD: { uint64_t N; - if (auto EC = Reader.readInteger(N)) + if (auto EC = Reader.readInteger(N, llvm::support::little)) return EC; Num = APSInt(APInt(64, N, false), true); return Error::success(); @@ -103,15 +103,15 @@ Error llvm::codeview::consume(BinaryStreamReader &Reader, APSInt &Num) { Error llvm::codeview::consume(StringRef &Data, APSInt &Num) { ArrayRef<uint8_t> Bytes(Data.bytes_begin(), Data.bytes_end()); - BinaryByteStream S(Bytes, llvm::support::little); - BinaryStreamReader SR(S); + msf::ByteStream S(Bytes); + msf::StreamReader 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(BinaryStreamReader &Reader, +Error llvm::codeview::consume_numeric(msf::StreamReader &Reader, uint64_t &Num) { APSInt N; if (auto EC = consume(Reader, N)) @@ -123,27 +123,27 @@ Error llvm::codeview::consume_numeric(BinaryStreamReader &Reader, return Error::success(); } -Error llvm::codeview::consume(BinaryStreamReader &Reader, uint32_t &Item) { - return Reader.readInteger(Item); +Error llvm::codeview::consume(msf::StreamReader &Reader, uint32_t &Item) { + return Reader.readInteger(Item, llvm::support::little); } Error llvm::codeview::consume(StringRef &Data, uint32_t &Item) { ArrayRef<uint8_t> Bytes(Data.bytes_begin(), Data.bytes_end()); - BinaryByteStream S(Bytes, llvm::support::little); - BinaryStreamReader SR(S); + msf::ByteStream S(Bytes); + msf::StreamReader SR(S); auto EC = consume(SR, Item); Data = Data.take_back(SR.bytesRemaining()); return EC; } -Error llvm::codeview::consume(BinaryStreamReader &Reader, int32_t &Item) { - return Reader.readInteger(Item); +Error llvm::codeview::consume(msf::StreamReader &Reader, int32_t &Item) { + return Reader.readInteger(Item, llvm::support::little); } -Error llvm::codeview::consume(BinaryStreamReader &Reader, StringRef &Item) { +Error llvm::codeview::consume(msf::StreamReader &Reader, StringRef &Item) { if (Reader.empty()) return make_error<CodeViewError>(cv_error_code::corrupt_record, "Null terminated string buffer is empty!"); - return Reader.readCString(Item); + return Reader.readZeroString(Item); } diff --git a/llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp b/llvm/lib/DebugInfo/CodeView/TypeSerializer.cpp index 4d0ce9e..00eb667 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)) + if (auto EC = Writer.writeInteger(Pad, llvm::support::little)) return std::move(EC); --PaddingBytes; } @@ -85,8 +85,7 @@ TypeSerializer::addPadding(MutableArrayRef<uint8_t> Record) { TypeSerializer::TypeSerializer(BumpPtrAllocator &Storage) : RecordStorage(Storage), LastTypeIndex(), - RecordBuffer(MaxRecordLength * 2), - Stream(RecordBuffer, llvm::support::little), Writer(Stream), + RecordBuffer(MaxRecordLength * 2), Stream(RecordBuffer), 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, @@ -204,15 +203,15 @@ Error TypeSerializer::visitMemberEnd(CVMemberRecord &Record) { uint8_t *SegmentBytes = RecordStorage.Allocate<uint8_t>(LengthWithSize); auto SavedSegment = MutableArrayRef<uint8_t>(SegmentBytes, LengthWithSize); - MutableBinaryByteStream CS(SavedSegment, llvm::support::little); - BinaryStreamWriter CW(CS); + msf::MutableByteStream CS(SavedSegment); + msf::StreamWriter CW(CS); if (auto EC = CW.writeBytes(CopyData)) return EC; - if (auto EC = CW.writeEnum(TypeLeafKind::LF_INDEX)) + if (auto EC = CW.writeEnum(TypeLeafKind::LF_INDEX, llvm::support::little)) return EC; - if (auto EC = CW.writeInteger<uint16_t>(0)) + if (auto EC = CW.writeInteger<uint16_t>(0, llvm::support::little)) return EC; - if (auto EC = CW.writeInteger<uint32_t>(0xB0C0B0C0)) + if (auto EC = CW.writeInteger<uint32_t>(0xB0C0B0C0, llvm::support::little)) return EC; FieldListSegments.push_back(SavedSegment); |